Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lagt til mulighet for å bygge en dev configuration via fluent builder #171

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion KS.Fiks.IO.Client/Configuration/ApiConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ public class ApiConfiguration
public const string ProdHost = "api.fiks.ks.no";
public const string TestHost = "api.fiks.test.ks.no";
private const string DefaultScheme = "https";

private const int DefaultPort = 443;

public ApiConfiguration(string scheme = null, string host = null, int? port = null)
Expand Down
10 changes: 10 additions & 0 deletions KS.Fiks.IO.Client/Configuration/FiksIOConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,15 @@ public static MaskinportenClientConfiguration CreateMaskinportenTestConfig(strin
numberOfSecondsLeftBeforeExpire: 10,
certificate: certificate);
}

public static MaskinportenClientConfiguration CreateMaskinportenDevConfig(string audience, string tokenEndpoint, string issuer, X509Certificate2 certificate)
{
return new MaskinportenClientConfiguration(
audience: audience,
tokenEndpoint: tokenEndpoint,
issuer: issuer, // KS issuer name
numberOfSecondsLeftBeforeExpire: 10,
certificate: certificate);
}
}
}
18 changes: 13 additions & 5 deletions KS.Fiks.IO.Client/Configuration/FiksIOConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ public FiksIOConfiguration BuildProdConfiguration()
maskinportenConfiguration: FiksIOConfiguration.CreateMaskinportenProdConfig(maskinportenIssuer, maskinportenCertificate));
}

public FiksIOConfiguration BuildDevConfiguration(string amqpHost, string apiHost, string maskinportenAudience, string maskinportenTokenEndpoint)
{
ValidateConfigurations();

return new FiksIOConfiguration(
amqpConfiguration: new AmqpConfiguration(amqpHost, applicationName: amqpApplicationName, prefetchCount: amqpPrefetchCount, keepAlive: ampqKeepAlive),
apiConfiguration: new ApiConfiguration(host: apiHost),
asiceSigningConfiguration: _asiceSigningConfiguration,
integrasjonConfiguration: _integrasjonConfiguration,
kontoConfiguration: _kontoConfiguration,
maskinportenConfiguration: FiksIOConfiguration.CreateMaskinportenDevConfig(maskinportenAudience, maskinportenTokenEndpoint, maskinportenIssuer, maskinportenCertificate));
}

public FiksIOConfigurationBuilder WithMaskinportenConfiguration(X509Certificate2 certificate, string issuer)
{
maskinportenIssuer = issuer;
Expand Down Expand Up @@ -104,11 +117,6 @@ public FiksIOConfigurationBuilder WithAmqpConfiguration(string applicationName,
return this;
}

public FiksIOConfigurationBuilder WithApiConfiguration(string hostName, int hostPort)
{
return this;
}

private void ValidateConfigurations()
{
if (string.IsNullOrEmpty(maskinportenIssuer) || maskinportenCertificate == null)
Expand Down