Skip to content

Commit

Permalink
Merge pull request #21 from Worth-NL/fix/Configuration_RenameAndFixTests
Browse files Browse the repository at this point in the history
Add NOTIFYNL component to OMC_API_BASEURL configuration
  • Loading branch information
Thomas-M-Krystyan authored Apr 10, 2024
2 parents e3fcaca + dc63954 commit bf3563e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Documentation/OMC - Documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OMC Documentation

v.1.6.6
v.1.6.6.1

© 2024, Worth Systems.

Expand Down Expand Up @@ -36,7 +36,7 @@ OMC (Output Management Component) is a central point and the common hub of the c
| OMC_AUTHORIZATION_JWT_USERID | string | false | Cannot be missing and have null or empty value | The OMC JWT tokens are generated by OMC and authorized by Open services. New JWT token has to be generated manually, using OMC dedicated library, if the token validity expire (by default it is 60 minutes) |
| OMC_AUTHORIZATION_JWT_USERNAME | string | false | Cannot be missing and have null or empty value | The OMC JWT tokens are generated by OMC and authorized by Open services. New JWT token has to be generated manually, using OMC dedicated library, if the token validity expire (by default it is 60 minutes) |
| --- | --- | --- | --- | --- |
| OMC_API_BASEURL | string | false | Cannot be missing and have null or empty value | The domain where your Notify API instance is listening (e.g.: "https://api.notifynl.nl") |
| OMC_API_BASEURL_NOTIFYNL | string | false | Cannot be missing and have null or empty value | The domain where your Notify API instance is listening (e.g.: "https://api.notifynl.nl") |
| --- | --- | --- | --- | --- |
| USER_AUTHORIZATION_JWT_SECRET | string | true | Cannot be missing and have null or empty value | Internal implementation of Open services is regulating this. Better to use something longer as well. |
| USER_AUTHORIZATION_JWT_ISSUER | string | true | Cannot be missing and have null or empty value | Something identifying OpenZaak / OpenKlant / OpenNotificatie services (token is shared between of them) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,40 @@ public OmcComponent(ILoadersContext loadersContext, string parentName)
/// </summary>
internal sealed record ApiComponent
{
private readonly ILoadersContext _loadersContext;
private readonly string _currentPath;
/// <inheritdoc cref="BaseUrlComponent"/>
internal BaseUrlComponent BaseUrl { get; }

/// <summary>
/// Initializes a new instance of the <see cref="ApiComponent"/> class.
/// </summary>
internal ApiComponent(ILoadersContext loadersContext, string parentPath)
{
this._loadersContext = loadersContext;
this._currentPath = loadersContext.GetPathWithNode(parentPath, nameof(API));
string currentPath = loadersContext.GetPathWithNode(parentPath, nameof(API));

this.BaseUrl = new BaseUrlComponent(loadersContext, currentPath);
}

/// <summary>
/// The "Base URL" part of the configuration.
/// </summary>
internal sealed record BaseUrlComponent
{
private readonly ILoadersContext _loadersContext;
private readonly string _currentPath;

/// <inheritdoc cref="ILoadingService.GetData{TData}(string)"/>
internal string BaseUrl()
=> GetValue(this._loadersContext, this._currentPath, nameof(BaseUrl));
/// <summary>
/// Initializes a new instance of the <see cref="BaseUrlComponent"/> class.
/// </summary>
public BaseUrlComponent(ILoadersContext loadersContext, string parentPath)
{
this._loadersContext = loadersContext;
this._currentPath = loadersContext.GetPathWithNode(parentPath, nameof(BaseUrl));
}

/// <inheritdoc cref="ILoadingService.GetData{TData}(string)"/>
internal string NotifyNL()
=> GetValue(this._loadersContext, this._currentPath, nameof(NotifyNL));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion EventsHandler/Api/EventsHandler/Constants/DefaultValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class ApiController
{
internal const string Route = "[controller]";

internal const string Version = "1.66";
internal const string Version = "1.661";
}
#endregion

Expand Down
4 changes: 2 additions & 2 deletions EventsHandler/Api/EventsHandler/Controllers/TestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async Task<IActionResult> HealthCheckAsync()
try
{
// Health Check URL
string healthCheckUrl = $"{this._configuration.OMC.API.BaseUrl()}/_status?simple=true";
string healthCheckUrl = $"{this._configuration.OMC.API.BaseUrl.NotifyNL()}/_status?simple=true";

// Request
using var httpClient = new HttpClient();
Expand Down Expand Up @@ -247,7 +247,7 @@ private async Task<IActionResult> SendAsync(
{
// Initialize the .NET client of "NotifyNL" API service
var notifyClient = new NotificationClient( // TODO: Client to be resolved by IClientFactory (to be testable)
this._configuration.OMC.API.BaseUrl(),
this._configuration.OMC.API.BaseUrl.NotifyNL(),
this._configuration.User.API.Key.NotifyNL());

// Determine template type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ INotifyClient IHttpClientFactory<INotifyClient, string>.GetHttpClient(string org

return new NotifyClientDecorator(
new NotificationClient(
baseUrl: this._configuration.OMC.API.BaseUrl(), // The base URL to "Notify NL" API Service
apiKey: this._configuration.User.API.Key.NotifyNL())); // 3rd party-specific "Notify NL" API Key
baseUrl: this._configuration.OMC.API.BaseUrl.NotifyNL(), // The base URL to "Notify NL" API Service
apiKey: this._configuration.User.API.Key.NotifyNL())); // 3rd party-specific "Notify NL" API Key
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void WebApiConfiguration_InEnvironmentMode_ForAllValidVariables_ReadsProp
Assert.That(notifyJwt.UserName(), Is.Not.Null.Or.Empty);

// API | BaseUrl
Assert.That(configuration.OMC.API.BaseUrl(), Is.Not.Null.Or.Empty);
Assert.That(configuration.OMC.API.BaseUrl.NotifyNL(), Is.Not.Null.Or.Empty);

// Authorization | JWT | User
var userJwt = configuration.User.Authorization.JWT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal static ILoadingService GetEnvironmentLoader(bool isValid = true)
{ "OMC_AUTHORIZATION_JWT_USERID", isValid ? testValue : string.Empty },
{ "OMC_AUTHORIZATION_JWT_USERNAME", isValid ? testValue : string.Empty },

{ "OMC_API_BASEURL", isValid ? "https://www.test.nl/" : string.Empty },
{ "OMC_API_BASEURL_NOTIFYNL", isValid ? "https://www.test.nl/" : string.Empty },

{ "USER_AUTHORIZATION_JWT_SECRET", isValid ? testValue : string.Empty },
{ "USER_AUTHORIZATION_JWT_ISSUER", isValid ? testValue : string.Empty },
Expand Down Expand Up @@ -109,8 +109,9 @@ internal static ILoadingService GetEnvironmentLoader(bool isValid = true)
("OMC_AUTHORIZATION_JWT", "UserId", "OMC_AUTHORIZATION_JWT_USERID"),
("OMC_AUTHORIZATION_JWT", "UserName", "OMC_AUTHORIZATION_JWT_USERNAME"),

("OMC", "API", "OMC_API"),
("OMC_API", "BaseUrl", "OMC_API_BASEURL"),
("OMC", "API", "OMC_API"),
("OMC_API", "BaseUrl", "OMC_API_BASEURL"),
("OMC_API_BASEURL", "NotifyNL", "OMC_API_BASEURL_NOTIFYNL"),

("USER_AUTHORIZATION", "JWT", "USER_AUTHORIZATION_JWT"),
("USER_AUTHORIZATION_JWT", "Secret", "USER_AUTHORIZATION_JWT_SECRET"),
Expand Down

0 comments on commit bf3563e

Please sign in to comment.