-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DMS-380] DMS-337 DMS-380 E2E Testing Validation for Vendors (#368)
* Add script for starting the config service * Add required e2e project files * Add vendors feature file * Update build script for including the docker containers for E2E * update scope * Include client role * create network * Fix config docker image name
- Loading branch information
Showing
13 changed files
with
945 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# ----------------- | ||
# Postgres database | ||
# ----------------- | ||
POSTGRES_PASSWORD=abcdefgh1! | ||
POSTGRES_DB_NAME=edfi_configurationservice | ||
POSTGRES_PORT=5435 | ||
|
||
# -------- | ||
# Keycloak | ||
# -------- | ||
|
||
KEYCLOAK_ADMIN=admin | ||
KEYCLOAK_ADMIN_PASSWORD=admin | ||
KEYCLOAK_PORT=8045 | ||
|
||
# -------------- | ||
# Config Service | ||
# -------------- | ||
|
||
DMS_CONFIG_ASPNETCORE_HTTP_PORTS=8081 | ||
DMS_CONFIG_DATASTORE=postgresql | ||
DMS_CONFIG_DATABASE_CONNECTION_STRING=host=dms-postgresql;port=5432;username=postgres;password=${POSTGRES_PASSWORD};database=${POSTGRES_DB_NAME}; | ||
DMS_CONFIG_IDENTITY_ALLOW_REGISTRATION=true | ||
DMS_CONFIG_IDENTITY_SERVICE_ROLE=config-service-app | ||
DMS_CONFIG_IDENTITY_CLIENT_ROLE=dms-client | ||
DMS_CONFIG_IDENTITY_AUTHORITY=http://dms-keycloak:8080/realms/edfi | ||
DMS_CONFIG_IDENTITY_AUDIENCE=account | ||
KEYCLOAK_URL=http://dms-keycloak:8080 | ||
KEYCLOAK_REALM=edfi | ||
DMS_CONFIG_IDENTITY_CLIENT_ID=DmsConfigurationService | ||
DMS_CONFIG_IDENTITY_CLIENT_SECRET=s3creT@09 | ||
DMS_CONFIG_IDENTITY_REQUIRE_HTTPS=false | ||
DMS_CONFIG_IDENTITY_ROLE_CLAIM_TYPE=http://schemas\\.microsoft\\.com/ws/2008/06/identity/claims/role | ||
DMS_CONFIG_IDENTITY_SCOPE=edfi_admin_api/full_access | ||
DMS_CONFIG_LOG_LEVEL=Information | ||
DMS_CONFIG_DEPLOY_DATABASE=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Licensed to the Ed-Fi Alliance under one or more agreements. | ||
# 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. | ||
|
||
[CmdletBinding()] | ||
param ( | ||
# Stop services instead of starting them | ||
[Switch] | ||
$d, | ||
|
||
# Delete volumes after stopping services | ||
[Switch] | ||
$v, | ||
|
||
# Environment file | ||
[string] | ||
$EnvironmentFile = "./.env", | ||
|
||
# Force a rebuild | ||
[Switch] | ||
$r | ||
) | ||
|
||
$files = @( | ||
"-f", | ||
"postgresql.yml", | ||
"-f", | ||
"local-config.yml", | ||
"-f", | ||
"keycloak.yml" | ||
) | ||
|
||
if ($d) { | ||
if ($v) { | ||
Write-Output "Shutting down with volume delete" | ||
docker compose $files down -v | ||
} | ||
else { | ||
Write-Output "Shutting down" | ||
docker compose $files down | ||
} | ||
} | ||
else { | ||
|
||
$existingNetwork = docker network ls --filter name="dms" -q | ||
if (! $existingNetwork) { | ||
docker network create dms | ||
} | ||
|
||
$upArgs = @( | ||
"--detach" | ||
) | ||
if ($r) { $upArgs += @("--build") } | ||
|
||
Write-Output "Starting locally-built DMS config service" | ||
|
||
docker compose $files --env-file $EnvironmentFile up $upArgs | ||
|
||
if ($LASTEXITCODE -ne 0) { | ||
throw "Unable to start local Docker environment, with exit code $LASTEXITCODE." | ||
} | ||
|
||
Start-Sleep 20 | ||
./setup-keycloak.ps1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...ests/EdFi.DmsConfigurationService.Tests.E2E/EdFi.DmsConfigurationService.Tests.E2E.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="FluentAssertions" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="Microsoft.Playwright.NUnit" /> | ||
<PackageReference Include="Npgsql" /> | ||
<PackageReference Include="NUnit" /> | ||
<PackageReference Include="NUnit.Analyzers" /> | ||
<PackageReference Include="NUnit3TestAdapter" /> | ||
<PackageReference Include="Reqnroll" /> | ||
<PackageReference Include="Reqnroll.NUnit" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="NUnit.Framework" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Extensions\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
84 changes: 84 additions & 0 deletions
84
src/config/tests/EdFi.DmsConfigurationService.Tests.E2E/Extensions/DataTableRowExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// 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.Globalization; | ||
using System.Text.Encodings.Web; | ||
using System.Text.Json; | ||
using Reqnroll; | ||
|
||
namespace EdFi.DmsConfigurationService.Tests.E2E.Extensions; | ||
|
||
internal static class DataTableRowExtensions | ||
{ | ||
public static string Parse(this DataTableRow dataRow) | ||
{ | ||
var options = new JsonSerializerOptions | ||
{ | ||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, | ||
WriteIndented = true | ||
}; | ||
|
||
var rowDict = new Dictionary<string, object>(); | ||
foreach (var column in dataRow.Keys) | ||
{ | ||
rowDict[column] = ConvertValueToCorrectType(dataRow[column]); | ||
} | ||
|
||
return JsonSerializer.Serialize(rowDict, options); | ||
} | ||
|
||
private static object ConvertValueToCorrectType(string value) | ||
{ | ||
// When other data type treated as string (ex: CalenderCode: "255901107") | ||
if (value.StartsWith('"') && value.EndsWith('"')) | ||
{ | ||
return value.Trim('"'); | ||
} | ||
|
||
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intValue)) | ||
{ | ||
return intValue; | ||
} | ||
|
||
if ( | ||
decimal.TryParse( | ||
value, | ||
NumberStyles.Number, | ||
CultureInfo.InvariantCulture, | ||
out var decimalValue | ||
) | ||
) | ||
{ | ||
return decimalValue; | ||
} | ||
|
||
if ( | ||
DateTime.TryParse( | ||
value, | ||
CultureInfo.InvariantCulture, | ||
DateTimeStyles.None, | ||
out var dateTimeValue | ||
) | ||
) | ||
{ | ||
return dateTimeValue.Date.ToString("yyyy-MM-dd"); | ||
} | ||
|
||
if (bool.TryParse(value, out var boolValue)) | ||
{ | ||
return boolValue; | ||
} | ||
|
||
if (value.StartsWith('[') && value.EndsWith(']') || value.StartsWith('{') && value.EndsWith('}')) | ||
{ | ||
using var document = | ||
JsonDocument.Parse(value) ?? throw new InvalidOperationException($"Error while parsing {value}"); | ||
|
||
return document.RootElement.Clone(); | ||
} | ||
|
||
return value; | ||
} | ||
} |
Oops, something went wrong.