Disable place_order without Enova credentials
This commit is contained in:
@@ -25,7 +25,9 @@ var tests = new (string Name, Func<Task> Run)[]
|
||||
("Brak waluty zwraca stabilny błąd", MissingCurrency),
|
||||
("Waluta inna niż PLN jest odrzucana", UnsupportedCurrency),
|
||||
("Brak katalogu Enovy jest wykrywany", MissingEnovaDirectory),
|
||||
("Sekrety są odczytywane z pliku konfiguracji", SecretsComeFromConfigurationFile)
|
||||
("Sekrety są odczytywane z pliku konfiguracji", SecretsComeFromConfigurationFile),
|
||||
("Brak danych operatora wyłącza place_order", MissingCredentialsDisablePlaceOrder),
|
||||
("Częściowe dane operatora wyłączają place_order", PartialCredentialsDisablePlaceOrder)
|
||||
};
|
||||
|
||||
var failures = 0;
|
||||
@@ -214,7 +216,10 @@ static Task SecretsComeFromConfigurationFile()
|
||||
|
||||
var runtime = ServiceSettings.Load(path).ResolveRuntimeSettings();
|
||||
|
||||
AssertEqual("haslo-z-pliku", runtime.EnovaConfiguration.Connection.Password, "hasło operatora");
|
||||
AssertEqual(
|
||||
"haslo-z-pliku",
|
||||
runtime.EnovaConfiguration?.Connection.Password,
|
||||
"hasło operatora");
|
||||
AssertEqual(
|
||||
"Server=db;Database=enova;User ID=user;Password=sql-z-pliku",
|
||||
runtime.SqlConnectionString,
|
||||
@@ -227,6 +232,47 @@ static Task SecretsComeFromConfigurationFile()
|
||||
}
|
||||
}
|
||||
|
||||
static Task MissingCredentialsDisablePlaceOrder()
|
||||
{
|
||||
var runtime = LoadRuntimeSettings(string.Empty);
|
||||
AssertEqual(null, runtime.EnovaConfiguration, "konfiguracja endpointu place_order");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
static Task PartialCredentialsDisablePlaceOrder()
|
||||
{
|
||||
var runtime = LoadRuntimeSettings("\"operator\": \"Administrator\",");
|
||||
AssertEqual(null, runtime.EnovaConfiguration, "konfiguracja endpointu place_order");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
static RuntimeSettings LoadRuntimeSettings(string credentialsJson)
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"enova-settings-{Guid.NewGuid():N}.json");
|
||||
try
|
||||
{
|
||||
File.WriteAllText(path, $$"""
|
||||
{
|
||||
"portal": "demo",
|
||||
"wamp": { "serverUrl": "ws://localhost:8080/" },
|
||||
"enova": {
|
||||
"installationPath": "C:/Enova",
|
||||
"database": "Firma demo",
|
||||
{{credentialsJson}}
|
||||
"documentDefinition": "ZO"
|
||||
},
|
||||
"sql": { "connectionString": "Server=db;Database=enova;User ID=user;Password=secret" }
|
||||
}
|
||||
""");
|
||||
|
||||
return ServiceSettings.Load(path).ResolveRuntimeSettings();
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
|
||||
static RpcInvocation CreateInvocation() => new(
|
||||
[],
|
||||
new Dictionary<string, object?>
|
||||
|
||||
Reference in New Issue
Block a user