Read Enova credentials from configuration file
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using SmartB2B.Enova.Contracts;
|
||||
using SmartB2B.Enova.Service.Configuration;
|
||||
using SmartB2B.Enova.Service.Orders;
|
||||
using SmartB2B.Enova.Service.Rpc;
|
||||
using SmartB2B.Enova.Service.Runtime;
|
||||
@@ -23,7 +24,8 @@ var tests = new (string Name, Func<Task> Run)[]
|
||||
("Warstwa WAMP wysyła wynik jako kwargs", WampKeywordWireResult),
|
||||
("Brak waluty zwraca stabilny błąd", MissingCurrency),
|
||||
("Waluta inna niż PLN jest odrzucana", UnsupportedCurrency),
|
||||
("Brak katalogu Enovy jest wykrywany", MissingEnovaDirectory)
|
||||
("Brak katalogu Enovy jest wykrywany", MissingEnovaDirectory),
|
||||
("Sekrety są odczytywane z pliku konfiguracji", SecretsComeFromConfigurationFile)
|
||||
};
|
||||
|
||||
var failures = 0;
|
||||
@@ -179,6 +181,52 @@ static Task MissingEnovaDirectory()
|
||||
}
|
||||
}
|
||||
|
||||
static Task SecretsComeFromConfigurationFile()
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"enova-settings-{Guid.NewGuid():N}.json");
|
||||
try
|
||||
{
|
||||
File.WriteAllText(path, """
|
||||
{
|
||||
"portal": "demo",
|
||||
"wamp": {
|
||||
"serverUrl": "ws://localhost:8080/",
|
||||
"reconnectDelaySeconds": 10
|
||||
},
|
||||
"enova": {
|
||||
"installationPath": "C:/Enova",
|
||||
"database": "Firma demo",
|
||||
"operator": "Administrator",
|
||||
"password": "haslo-z-pliku",
|
||||
"documentDefinition": "ZO",
|
||||
"saveMode": "Buffer"
|
||||
},
|
||||
"sql": {
|
||||
"connectionString": "Server=db;Database=enova;User ID=user;Password=sql-z-pliku",
|
||||
"commandTimeoutSeconds": 30
|
||||
},
|
||||
"diagnostics": {
|
||||
"logDirectory": "C:/logs",
|
||||
"logPrefix": "test"
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
var runtime = ServiceSettings.Load(path).ResolveRuntimeSettings();
|
||||
|
||||
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,
|
||||
"connection string SQL");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
|
||||
static RpcInvocation CreateInvocation() => new(
|
||||
[],
|
||||
new Dictionary<string, object?>
|
||||
|
||||
Reference in New Issue
Block a user