Skip to content

Commit

Permalink
use proper cqe version number, use switch expression syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
simpat-adam committed Jan 12, 2024
1 parent 4ccb187 commit 25571a7
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class OdsSecurityVersionResolverTests
.DetermineSecurityModel().ShouldBe(EdFiOdsSecurityModelCompatibility.ThreeThroughFive);

[Test]
public static void ShouldReturnV3_5ForOdsV53Cqe() => new OdsSecurityVersionResolver("5.3cqe")
public static void ShouldReturnV3_5ForOdsV53Cqe() => new OdsSecurityVersionResolver("5.3-cqe")
.DetermineSecurityModel().ShouldBe(EdFiOdsSecurityModelCompatibility.FiveThreeCqe);

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using System.Runtime.CompilerServices;
using log4net;

namespace EdFi.Ods.AdminApi.Infrastructure;
Expand All @@ -29,19 +30,20 @@ public OdsSecurityVersionResolver(string odsApiVersion)

private EdFiOdsSecurityModelCompatibility InitializeModelVersion()
{
switch (_odsApiVersion)
try
{
case "5.3":
return EdFiOdsSecurityModelCompatibility.ThreeThroughFive;
case "5.3cqe":
return EdFiOdsSecurityModelCompatibility.FiveThreeCqe;
case "6.0":
case "6.1":
return EdFiOdsSecurityModelCompatibility.Six;
default:
_log.Error("OdsApiVersion not configured. Valid values are 5.3, 5.3cqe, 6.0 and 6.1");
throw new Exception("OdsApiVersion not configured. Valid values are 5.3, 5.3cqe, 6.0 and 6.1");

return _odsApiVersion switch
{
"5.3" => EdFiOdsSecurityModelCompatibility.ThreeThroughFive,
"5.3-cqe" => EdFiOdsSecurityModelCompatibility.FiveThreeCqe,
"6.0" => EdFiOdsSecurityModelCompatibility.Six,
"6.1" => EdFiOdsSecurityModelCompatibility.Six,
};
}
catch (SwitchExpressionException)
{
_log.Error("OdsApiVersion not configured. Valid values are 5.3, 5.3-cqe, 6.0 and 6.1");
throw new Exception("OdsApiVersion not configured. Valid values are 5.3, 5.3-cqe, 6.0 and 6.1");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Application/EdFi.Ods.AdminApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ProductionApiUrl": "http://localhost:54746",
"ApiStartupType": "SharedInstance",
"PathBase": "",
"OdsApiVersion": "5.3cqe"
"OdsApiVersion": "6.1"
},
"Authentication": {
"Authority": "",
Expand Down
2 changes: 1 addition & 1 deletion Application/EdFi.Ods.AdminApi/env.example.dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
API_MODE=<API Mode Eg. SharedInstance, YearSpecific, DistrictSpecific>
ODS_VIRTUAL_NAME=<virtual name for the ods endpoint>
ADMIN_API_VIRTUAL_NAME=<virtual name for the Admin API endpoint>
ODS_API_VERSION=<Version number of ODS API eg. 5.3, 5.3cqe, 6.0, 6.1>
ODS_API_VERSION=<Version number of ODS API eg. 5.3, 5.3-cqe, 6.0, 6.1>

# For Authentication
AUTHORITY=<Authentication Authority Appsetting Eg. https://localhost:443>
Expand Down
2 changes: 1 addition & 1 deletion Docker/Settings/mssql/env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
API_MODE=<API Mode Eg. SharedInstance, YearSpecific, DistrictSpecific>
ADMIN_API_VIRTUAL_NAME=<virtual name for the Admin API endpoint>
ODS_API_VERSION=<Version number of ODS API eg. 5.3, 5.3cqe, 6.0, 6.1>
ODS_API_VERSION=<Version number of ODS API eg. 5.3, 5.3-cqe, 6.0, 6.1>

# For Authentication
AUTHORITY=<Authentication Authority Appsetting Eg. https://localhost:443>
Expand Down
2 changes: 1 addition & 1 deletion Docker/Settings/pgsql/env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
API_MODE=<API Mode Eg. SharedInstance, YearSpecific, DistrictSpecific>
ADMIN_API_VIRTUAL_NAME=<virtual name for the Admin API endpoint>
ODS_API_VERSION=<Version number of ODS API eg. 5.3, 5.3cqe, 6.0, 6.1>
ODS_API_VERSION=<Version number of ODS API eg. 5.3, 5.3-cqe, 6.0, 6.1>

# For Authentication
AUTHORITY=<Authentication Authority Appsetting Eg. https://localhost:443>
Expand Down
4 changes: 2 additions & 2 deletions Installer.AdminApi/Install-AdminApi.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ function Install-EdFiOdsAdminApi {
[string]
$CertThumbprint,

# ODS / API version. Valid values are 5.3, 5.3cqe, 6.0, 6.1. Default: "6.1"
# ODS / API version. Valid values are 5.3, 5.3-cqe, 6.0, 6.1. Default: "6.1"
[Parameter(Mandatory=$true)]
[ValidateSet('5.3', '5.3cqe', '6.0', '6.1')]
[ValidateSet('5.3', '5.3-cqe', '6.0', '6.1')]
[string]
$OdsApiVersion,

Expand Down
2 changes: 1 addition & 1 deletion Installer.AdminApi/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ $p = @{
}

if ([string]::IsNullOrWhiteSpace($p.OdsApiVersion)) {
Write-Error "ODS API Version has not been configured. Edit install.ps1 to pass in a valid version number for the ODS API. Valid versions are 5.3, 5.3cqe, 6.0 and 6.1"
Write-Error "ODS API Version has not been configured. Edit install.ps1 to pass in a valid version number for the ODS API. Valid versions are 5.3, 5.3-cqe, 6.0 and 6.1"
}
elseif ([string]::IsNullOrWhiteSpace($p.AuthenticationSettings.Authority) -or [string]::IsNullOrWhiteSpace($p.AuthenticationSettings.IssuerUrl) -or [string]::IsNullOrWhiteSpace($p.AuthenticationSettings.SigningKey) -or $p.AuthenticationSettings.AllowRegistration -isnot [bool]) {
Write-Error "Authentication Settings have not been configured correctly. Edit install.ps1 to pass in valid authentication settings for Admin Api."
Expand Down

0 comments on commit 25571a7

Please # to comment.