diff --git a/charts/dim/Chart.yaml b/charts/dim/Chart.yaml
index 669163c..39c87bf 100644
--- a/charts/dim/Chart.yaml
+++ b/charts/dim/Chart.yaml
@@ -20,8 +20,8 @@
apiVersion: v2
name: dim
type: application
-version: 0.0.2
-appVersion: 0.0.2
+version: 0.0.3
+appVersion: 0.0.3
description: Helm chart for DIM Middle Layer
home: https://github.com/catenax-ng/dim-repo
dependencies:
diff --git a/charts/dim/README.md b/charts/dim/README.md
index a2c6994..fbe9398 100644
--- a/charts/dim/README.md
+++ b/charts/dim/README.md
@@ -27,7 +27,7 @@ To use the helm chart as a dependency:
dependencies:
- name: dim
repository: https://phil91.github.io/dim-client
- version: 0.0.2
+ version: 0.0.3
```
## Requirements
diff --git a/consortia/argocd-app-templates/appsetup-int.yaml b/consortia/argocd-app-templates/appsetup-int.yaml
index ec32939..ba1a624 100644
--- a/consortia/argocd-app-templates/appsetup-int.yaml
+++ b/consortia/argocd-app-templates/appsetup-int.yaml
@@ -28,7 +28,7 @@ spec:
source:
path: charts/dim
repoURL: 'https://github.com/phil91/dim-client.git'
- targetRevision: dim-0.0.2
+ targetRevision: dim-0.0.3
plugin:
env:
- name: AVP_SECRET
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 9e06d62..cad6d04 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -19,7 +19,7 @@
- 0.0.2
+ 0.0.3
diff --git a/src/clients/Dim.Clients/Api/Dim/CreateCompanyIdentityRequest.cs b/src/clients/Dim.Clients/Api/Dim/CreateCompanyIdentityRequest.cs
index 2d6f86e..96d32df 100644
--- a/src/clients/Dim.Clients/Api/Dim/CreateCompanyIdentityRequest.cs
+++ b/src/clients/Dim.Clients/Api/Dim/CreateCompanyIdentityRequest.cs
@@ -26,28 +26,25 @@ public record CreateCompanyIdentityRequest(
);
public record Payload(
- [property: JsonPropertyName("hostingUrl")] string HostingUrl,
- [property: JsonPropertyName("bootstrap")] Bootstrap Bootstrap,
- [property: JsonPropertyName("keys")] IEnumerable Keys
+ [property: JsonPropertyName("hostingURL")] string HostingUrl,
+ [property: JsonPropertyName("network")] Network Network,
+ [property: JsonPropertyName("services")] IEnumerable Services,
+ [property: JsonPropertyName("keys")] IEnumerable Keys,
+ [property: JsonPropertyName("name")] string Name
);
public record Service(
[property: JsonPropertyName("id")] string Id,
- [property: JsonPropertyName("type")] string Type
-);
-
-public record Bootstrap(
- [property: JsonPropertyName("description")] string Description,
- [property: JsonPropertyName("name")] string Name,
- [property: JsonPropertyName("protocols")] IEnumerable Protocols
+ [property: JsonPropertyName("type")] string Type,
+ [property: JsonPropertyName("serviceEndpoint")] string ServiceEndpoint
);
-public record Key(
+public record Network(
+ [property: JsonPropertyName("didMethod")] string DidMethod,
[property: JsonPropertyName("type")] string Type
);
-public record Network(
- [property: JsonPropertyName("didMethod")] string DidMethod,
+public record Key(
[property: JsonPropertyName("type")] string Type
);
@@ -56,3 +53,12 @@ public record CreateCompanyIdentityResponse(
[property: JsonPropertyName("companyId")] Guid CompanyId,
[property: JsonPropertyName("downloadURL")] string DownloadUrl
);
+//
+// public record UpdateCompanyIdentityRequest(
+// [property: JsonPropertyName("didDocUpdates")] DidDocUpdates DidDocUpdates
+// );
+//
+// public record DidDocUpdates(
+// [property: JsonPropertyName("removeServices")] IEnumerable RemoveServices,
+// [property: JsonPropertyName("addServices")] IEnumerable AddServices
+// );
diff --git a/src/clients/Dim.Clients/Api/Dim/DimClient.cs b/src/clients/Dim.Clients/Api/Dim/DimClient.cs
index 8231000..b3d9a53 100644
--- a/src/clients/Dim.Clients/Api/Dim/DimClient.cs
+++ b/src/clients/Dim.Clients/Api/Dim/DimClient.cs
@@ -26,30 +26,26 @@
namespace Dim.Clients.Api.Dim;
-public class DimClient : IDimClient
+public class DimClient(IBasicAuthTokenService basicAuthTokenService, IHttpClientFactory clientFactory)
+ : IDimClient
{
- private readonly IBasicAuthTokenService _basicAuthTokenService;
- private readonly IHttpClientFactory _clientFactory;
-
- public DimClient(IBasicAuthTokenService basicAuthTokenService, IHttpClientFactory clientFactory)
- {
- _basicAuthTokenService = basicAuthTokenService;
- _clientFactory = clientFactory;
- }
-
- public async Task CreateCompanyIdentity(BasicAuthSettings dimBasicAuth, string hostingUrl, string baseUrl, string tenantName, bool isIssuer, CancellationToken cancellationToken)
+ public async Task CreateCompanyIdentity(BasicAuthSettings dimBasicAuth, Guid tenantId, string hostingUrl, string baseUrl, bool isIssuer, CancellationToken cancellationToken)
{
- var client = await _basicAuthTokenService.GetBasicAuthorizedClient(dimBasicAuth, cancellationToken).ConfigureAwait(false);
+ var client = await basicAuthTokenService.GetBasicAuthorizedClient(dimBasicAuth, cancellationToken).ConfigureAwait(false);
var data = new CreateCompanyIdentityRequest(new Payload(
hostingUrl,
- new Bootstrap("Holder with IATP", "Holder IATP", Enumerable.Repeat("IATP", 1)),
+ new Network("web", "production"),
+ [new Service($"dim:web:{tenantId}", "CredentialService", "https://dis-agent-prod.eu10.dim.cloud.sap/api/v1.0.0/iatp")],
isIssuer ?
- Enumerable.Empty() :
+ [
+ new("SIGNING"),
+ new("SIGNING_VC")
+ ] :
new Key[]
{
- new("SIGNING"),
- new("SIGNING_VC"),
- }));
+ new("SIGNING")
+ },
+ "holder iatp"));
var result = await client.PostAsJsonAsync($"{baseUrl}/api/v2.0.0/companyIdentities", data, JsonSerializerExtensions.Options, cancellationToken)
.CatchingIntoServiceExceptionFor("create-company-identity", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE,
async m =>
@@ -77,7 +73,7 @@ public async Task CreateCompanyIdentity(BasicAuth
public async Task GetDidDocument(string url, CancellationToken cancellationToken)
{
- var client = _clientFactory.CreateClient("didDocumentDownload");
+ var client = clientFactory.CreateClient("didDocumentDownload");
using var result = await client.GetStreamAsync(url, cancellationToken).ConfigureAwait(false);
var document = await JsonDocument.ParseAsync(result, cancellationToken: cancellationToken).ConfigureAwait(false);
return document;
@@ -85,7 +81,7 @@ public async Task GetDidDocument(string url, CancellationToken can
public async Task CreateApplication(BasicAuthSettings dimAuth, string dimBaseUrl, string tenantName, CancellationToken cancellationToken)
{
- var client = await _basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
+ var client = await basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
var data = new CreateApplicationRequest(new ApplicationPayload(
"catena-x-portal",
$"Catena-X Portal MIW for {tenantName}",
@@ -117,7 +113,7 @@ public async Task CreateApplication(BasicAuthSettings dimAuth, string di
public async Task GetApplication(BasicAuthSettings dimAuth, string dimBaseUrl, string applicationId, CancellationToken cancellationToken)
{
- var client = await _basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
+ var client = await basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
var result = await client.GetAsync($"{dimBaseUrl}/api/v2.0.0/applications/{applicationId}", cancellationToken)
.CatchingIntoServiceExceptionFor("get-application", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE,
async m =>
@@ -145,7 +141,7 @@ public async Task GetApplication(BasicAuthSettings dimAuth, string dimBa
public async Task AssignApplicationToCompany(BasicAuthSettings dimAuth, string dimBaseUrl, string applicationKey, Guid companyId, CancellationToken cancellationToken)
{
- var client = await _basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
+ var client = await basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
var data = new CompanyIdentityPatch(new ApplicationUpdates(Enumerable.Repeat(applicationKey, 1)));
await client.PatchAsJsonAsync($"{dimBaseUrl}/api/v2.0.0/companyIdentities/{companyId}", data, JsonSerializerExtensions.Options, cancellationToken)
.CatchingIntoServiceExceptionFor("assign-application", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE,
@@ -158,7 +154,7 @@ await client.PatchAsJsonAsync($"{dimBaseUrl}/api/v2.0.0/companyIdentities/{compa
public async Task GetStatusList(BasicAuthSettings dimAuth, string dimBaseUrl, Guid companyId, CancellationToken cancellationToken)
{
- var client = await _basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
+ var client = await basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
var result = await client.GetAsync($"{dimBaseUrl}/api/v2.0.0/companyIdentities/{companyId}/revocationLists", cancellationToken);
try
{
@@ -185,7 +181,7 @@ public async Task GetStatusList(BasicAuthSettings dimAuth, string dimBas
public async Task CreateStatusList(BasicAuthSettings dimAuth, string dimBaseUrl, Guid companyId, CancellationToken cancellationToken)
{
- var client = await _basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
+ var client = await basicAuthTokenService.GetBasicAuthorizedClient(dimAuth, cancellationToken).ConfigureAwait(false);
var data = new CreateStatusListRequest(new CreateStatusListPaypload(new CreateStatusList("StatusList2021", DateTimeOffset.UtcNow.ToString("yyyyMMdd"), "New revocation list", 2097152)));
var result = await client.PostAsJsonAsync($"{dimBaseUrl}/api/v2.0.0/companyIdentities/{companyId}/revocationLists", data, JsonSerializerExtensions.Options, cancellationToken)
.CatchingIntoServiceExceptionFor("assign-application", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE,
diff --git a/src/clients/Dim.Clients/Api/Dim/IDimClient.cs b/src/clients/Dim.Clients/Api/Dim/IDimClient.cs
index 850430b..f5a91b1 100644
--- a/src/clients/Dim.Clients/Api/Dim/IDimClient.cs
+++ b/src/clients/Dim.Clients/Api/Dim/IDimClient.cs
@@ -24,10 +24,9 @@ namespace Dim.Clients.Api.Dim;
public interface IDimClient
{
- Task CreateCompanyIdentity(BasicAuthSettings dimBasicAuth, string hostingUrl, string baseUrl, string tenantName, bool isIssuer, CancellationToken cancellationToken);
+ Task CreateCompanyIdentity(BasicAuthSettings dimBasicAuth, Guid tenantId, string hostingUrl, string baseUrl, bool isIssuer, CancellationToken cancellationToken);
Task GetDidDocument(string url, CancellationToken cancellationToken);
Task CreateApplication(BasicAuthSettings dimAuth, string dimBaseUrl, string tenantName, CancellationToken cancellationToken);
-
Task GetApplication(BasicAuthSettings dimAuth, string dimBaseUrl, string applicationId, CancellationToken cancellationToken);
Task AssignApplicationToCompany(BasicAuthSettings dimAuth, string dimBaseUrl, string applicationKey, Guid companyId, CancellationToken cancellationToken);
Task GetStatusList(BasicAuthSettings dimAuth, string dimBaseUrl, Guid companyId, CancellationToken cancellationToken);
diff --git a/src/database/Dim.DbAccess/Repositories/ITenantRepository.cs b/src/database/Dim.DbAccess/Repositories/ITenantRepository.cs
index 3596511..c782e97 100644
--- a/src/database/Dim.DbAccess/Repositories/ITenantRepository.cs
+++ b/src/database/Dim.DbAccess/Repositories/ITenantRepository.cs
@@ -41,4 +41,5 @@ public interface ITenantRepository
Task<(bool Exists, Guid TechnicalUserId, string CompanyName, string Bpn)> GetTenantDataForTechnicalUserProcessId(Guid processId);
Task<(Guid? spaceId, string technicalUserName)> GetSpaceIdAndTechnicalUserName(Guid technicalUserId);
Task<(Guid ExternalId, string? TokenAddress, string? ClientId, byte[]? ClientSecret, byte[]? InitializationVector, int? EncryptionMode)> GetTechnicalUserCallbackData(Guid technicalUserId);
+ Task<(Guid? DimInstanceId, Guid? CompanyId)> GetDimInstanceIdAndDid(Guid tenantId);
}
diff --git a/src/database/Dim.DbAccess/Repositories/TenantRepository.cs b/src/database/Dim.DbAccess/Repositories/TenantRepository.cs
index a96d25b..ce94eb3 100644
--- a/src/database/Dim.DbAccess/Repositories/TenantRepository.cs
+++ b/src/database/Dim.DbAccess/Repositories/TenantRepository.cs
@@ -23,20 +23,13 @@
namespace Dim.DbAccess.Repositories;
-public class TenantRepository : ITenantRepository
+public class TenantRepository(DimDbContext context) : ITenantRepository
{
- private readonly DimDbContext _context;
-
- public TenantRepository(DimDbContext context)
- {
- _context = context;
- }
-
public Tenant CreateTenant(string companyName, string bpn, string didDocumentLocation, bool isIssuer, Guid processId, Guid operatorId) =>
- _context.Tenants.Add(new Tenant(Guid.NewGuid(), companyName, bpn, didDocumentLocation, isIssuer, processId, operatorId)).Entity;
+ context.Tenants.Add(new Tenant(Guid.NewGuid(), companyName, bpn, didDocumentLocation, isIssuer, processId, operatorId)).Entity;
public Task<(bool Exists, Guid TenantId, string CompanyName, string Bpn)> GetTenantDataForProcessId(Guid processId) =>
- _context.Tenants
+ context.Tenants
.Where(x => x.ProcessId == processId)
.Select(x => new ValueTuple(true, x.Id, x.CompanyName, x.Bpn))
.SingleOrDefaultAsync();
@@ -45,54 +38,54 @@ public void AttachAndModifyTenant(Guid tenantId, Action? initialize, Act
{
var tenant = new Tenant(tenantId, null!, null!, null!, default, Guid.Empty, Guid.Empty);
initialize?.Invoke(tenant);
- _context.Tenants.Attach(tenant);
+ context.Tenants.Attach(tenant);
modify(tenant);
}
public Task GetSubAccountIdByTenantId(Guid tenantId)
- => _context.Tenants
+ => context.Tenants
.Where(x => x.Id == tenantId)
.Select(x => x.SubAccountId)
.SingleOrDefaultAsync();
public Task<(Guid? SubAccountId, string? ServiceInstanceId)> GetSubAccountAndServiceInstanceIdsByTenantId(Guid tenantId)
- => _context.Tenants
+ => context.Tenants
.Where(x => x.Id == tenantId)
.Select(x => new ValueTuple(x.SubAccountId, x.ServiceInstanceId))
.SingleOrDefaultAsync();
public Task<(Guid? SubAccountId, string? ServiceBindingName)> GetSubAccountIdAndServiceBindingNameByTenantId(Guid tenantId)
- => _context.Tenants
+ => context.Tenants
.Where(x => x.Id == tenantId)
.Select(x => new ValueTuple(x.SubAccountId, x.ServiceBindingName))
.SingleOrDefaultAsync();
public Task GetSpaceId(Guid tenantId)
- => _context.Tenants
+ => context.Tenants
.Where(x => x.Id == tenantId)
.Select(x => x.SpaceId)
.SingleOrDefaultAsync();
public Task GetDimInstanceId(Guid tenantId)
- => _context.Tenants
+ => context.Tenants
.Where(x => x.Id == tenantId)
.Select(x => x.DimInstanceId)
.SingleOrDefaultAsync();
public Task<(string bpn, string? DownloadUrl, string? Did, Guid? DimInstanceId)> GetCallbackData(Guid tenantId)
- => _context.Tenants
+ => context.Tenants
.Where(x => x.Id == tenantId)
.Select(x => new ValueTuple(x.Bpn, x.DidDownloadUrl, x.Did, x.DimInstanceId))
.SingleOrDefaultAsync();
public Task<(Guid? DimInstanceId, string HostingUrl, bool IsIssuer)> GetDimInstanceIdAndHostingUrl(Guid tenantId)
- => _context.Tenants
+ => context.Tenants
.Where(x => x.Id == tenantId)
.Select(x => new ValueTuple(x.DimInstanceId, x.DidDocumentLocation, x.IsIssuer))
.SingleOrDefaultAsync();
public Task<(string? ApplicationId, Guid? CompanyId, Guid? DimInstanceId, bool IsIssuer)> GetApplicationAndCompanyId(Guid tenantId) =>
- _context.Tenants
+ context.Tenants
.Where(x => x.Id == tenantId)
.Select(x => new ValueTuple(
x.ApplicationId,
@@ -102,40 +95,40 @@ public void AttachAndModifyTenant(Guid tenantId, Action? initialize, Act
.SingleOrDefaultAsync();
public Task<(bool Exists, Guid? CompanyId, Guid? InstanceId)> GetCompanyAndInstanceIdForBpn(string bpn) =>
- _context.Tenants.Where(x => x.Bpn == bpn)
+ context.Tenants.Where(x => x.Bpn == bpn)
.Select(x => new ValueTuple(true, x.CompanyId, x.DimInstanceId))
.SingleOrDefaultAsync();
public void CreateTenantTechnicalUser(Guid tenantId, string technicalUserName, Guid externalId, Guid processId) =>
- _context.TechnicalUsers.Add(new TechnicalUser(Guid.NewGuid(), tenantId, externalId, technicalUserName, processId));
+ context.TechnicalUsers.Add(new TechnicalUser(Guid.NewGuid(), tenantId, externalId, technicalUserName, processId));
public void AttachAndModifyTechnicalUser(Guid technicalUserId, Action? initialize, Action modify)
{
var technicalUser = new TechnicalUser(technicalUserId, Guid.Empty, Guid.Empty, null!, Guid.Empty);
initialize?.Invoke(technicalUser);
- _context.TechnicalUsers.Attach(technicalUser);
+ context.TechnicalUsers.Attach(technicalUser);
modify(technicalUser);
}
public Task<(bool Exists, Guid TenantId)> GetTenantForBpn(string bpn) =>
- _context.Tenants.Where(x => x.Bpn == bpn)
+ context.Tenants.Where(x => x.Bpn == bpn)
.Select(x => new ValueTuple(true, x.Id))
.SingleOrDefaultAsync();
public Task<(bool Exists, Guid TechnicalUserId, string CompanyName, string Bpn)> GetTenantDataForTechnicalUserProcessId(Guid processId) =>
- _context.TechnicalUsers
+ context.TechnicalUsers
.Where(x => x.ProcessId == processId)
.Select(x => new ValueTuple(true, x.Id, x.Tenant!.CompanyName, x.Tenant.Bpn))
.SingleOrDefaultAsync();
public Task<(Guid? spaceId, string technicalUserName)> GetSpaceIdAndTechnicalUserName(Guid technicalUserId) =>
- _context.TechnicalUsers
+ context.TechnicalUsers
.Where(x => x.Id == technicalUserId)
.Select(x => new ValueTuple(x.Tenant!.SpaceId, x.TechnicalUserName))
.SingleOrDefaultAsync();
public Task<(Guid ExternalId, string? TokenAddress, string? ClientId, byte[]? ClientSecret, byte[]? InitializationVector, int? EncryptionMode)> GetTechnicalUserCallbackData(Guid technicalUserId) =>
- _context.TechnicalUsers
+ context.TechnicalUsers
.Where(x => x.Id == technicalUserId)
.Select(x => new ValueTuple(
x.ExternalId,
@@ -145,4 +138,10 @@ public void AttachAndModifyTechnicalUser(Guid technicalUserId, Action GetDimInstanceIdAndDid(Guid tenantId) =>
+ context.Tenants
+ .Where(x => x.Id == tenantId)
+ .Select(x => new ValueTuple(x.DimInstanceId, x.CompanyId))
+ .SingleOrDefaultAsync();
}
diff --git a/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs b/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs
index 6777f3a..08ddcbf 100644
--- a/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs
+++ b/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs
@@ -117,7 +117,7 @@ public class DimProcessTypeExecutor(
.ConfigureAwait(false),
ProcessStepTypeId.CREATE_APPLICATION => await dimProcessHandler.CreateApplication(_tenantName, _tenantId, cancellationToken)
.ConfigureAwait(false),
- ProcessStepTypeId.CREATE_COMPANY_IDENTITY => await dimProcessHandler.CreateCompanyIdentity(_tenantId, _tenantName, cancellationToken)
+ ProcessStepTypeId.CREATE_COMPANY_IDENTITY => await dimProcessHandler.CreateCompanyIdentity(_tenantId, cancellationToken)
.ConfigureAwait(false),
ProcessStepTypeId.ASSIGN_COMPANY_APPLICATION => await dimProcessHandler.AssignCompanyApplication(_tenantId, cancellationToken)
.ConfigureAwait(false),
diff --git a/src/processes/DimProcess.Library/Callback/CallbackDataModel.cs b/src/processes/DimProcess.Library/Callback/CallbackDataModel.cs
index e445568..4e45a6f 100644
--- a/src/processes/DimProcess.Library/Callback/CallbackDataModel.cs
+++ b/src/processes/DimProcess.Library/Callback/CallbackDataModel.cs
@@ -29,7 +29,7 @@ public record CallbackDataModel(
);
public record AuthenticationDetail(
- [property: JsonPropertyName("authenticationServiceUrl")] string AuthenticationServiceUrl,
+ [property: JsonPropertyName("authenticationServiceUrl")] string AuthenticationServiceUrl,
[property: JsonPropertyName("clientID")] string ClientId,
[property: JsonPropertyName("clientSecret")] string ClientSecret
);
diff --git a/src/processes/DimProcess.Library/DimProcessHandler.cs b/src/processes/DimProcess.Library/DimProcessHandler.cs
index 7fb9812..08c842f 100644
--- a/src/processes/DimProcess.Library/DimProcessHandler.cs
+++ b/src/processes/DimProcess.Library/DimProcessHandler.cs
@@ -399,7 +399,7 @@ await provisioningClient.CreateCloudFoundryEnvironment(saBinding.Url, bindingRes
null);
}
- public async Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> CreateCompanyIdentity(Guid tenantId, string tenantName, CancellationToken cancellationToken)
+ public async Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> CreateCompanyIdentity(Guid tenantId, CancellationToken cancellationToken)
{
var (dimInstanceId, hostingUrl, isIssuer) = await dimRepositories.GetInstance().GetDimInstanceIdAndHostingUrl(tenantId).ConfigureAwait(false);
if (dimInstanceId == null)
@@ -416,7 +416,7 @@ await provisioningClient.CreateCloudFoundryEnvironment(saBinding.Url, bindingRes
ClientSecret = dimDetails.Credentials.Uaa.ClientSecret
};
var dimBaseUrl = dimDetails.Credentials.Url;
- var result = await dimClient.CreateCompanyIdentity(dimAuth, hostingUrl, dimBaseUrl, tenantName, isIssuer, cancellationToken).ConfigureAwait(false);
+ var result = await dimClient.CreateCompanyIdentity(dimAuth, tenantId, hostingUrl, dimBaseUrl, isIssuer, cancellationToken).ConfigureAwait(false);
dimRepositories.GetInstance().AttachAndModifyTenant(tenantId, tenant =>
{
diff --git a/src/processes/DimProcess.Library/IDimProcessHandler.cs b/src/processes/DimProcess.Library/IDimProcessHandler.cs
index 0ba310c..4544229 100644
--- a/src/processes/DimProcess.Library/IDimProcessHandler.cs
+++ b/src/processes/DimProcess.Library/IDimProcessHandler.cs
@@ -37,7 +37,7 @@ public interface IDimProcessHandler
Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> CreateServiceInstanceBindings(string tenantName, Guid tenantId, CancellationToken cancellationToken);
Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> CreateApplication(string tenantName, Guid tenantId, CancellationToken cancellationToken);
Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> GetDimDetails(string tenantName, Guid tenantId, CancellationToken cancellationToken);
- Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> CreateCompanyIdentity(Guid tenantId, string tenantName, CancellationToken cancellationToken);
+ Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> CreateCompanyIdentity(Guid tenantId, CancellationToken cancellationToken);
Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> CreateStatusList(Guid tenantId, CancellationToken cancellationToken);
Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> AssignCompanyApplication(Guid tenantId, CancellationToken cancellationToken);
Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> SendCallback(Guid tenantId, CancellationToken cancellationToken);
diff --git a/src/web/Dim.Web/BusinessLogic/DimBusinessLogic.cs b/src/web/Dim.Web/BusinessLogic/DimBusinessLogic.cs
index 9970337..167e18c 100644
--- a/src/web/Dim.Web/BusinessLogic/DimBusinessLogic.cs
+++ b/src/web/Dim.Web/BusinessLogic/DimBusinessLogic.cs
@@ -30,35 +30,29 @@
namespace Dim.Web.BusinessLogic;
-public class DimBusinessLogic : IDimBusinessLogic
+public class DimBusinessLogic(
+ IDimRepositories dimRepositories,
+ ICfClient cfClient,
+ IDimClient dimClient,
+ IOptions options)
+ : IDimBusinessLogic
{
- private readonly IDimRepositories _dimRepositories;
- private readonly ICfClient _cfClient;
- private readonly IDimClient _dimClient;
- private readonly DimSettings _settings;
-
- public DimBusinessLogic(IDimRepositories dimRepositories, ICfClient cfClient, IDimClient dimClient, IOptions options)
- {
- _dimRepositories = dimRepositories;
- _cfClient = cfClient;
- _dimClient = dimClient;
- _settings = options.Value;
- }
+ private readonly DimSettings _settings = options.Value;
public async Task StartSetupDim(string companyName, string bpn, string didDocumentLocation, bool isIssuer)
{
- var processStepRepository = _dimRepositories.GetInstance();
+ var processStepRepository = dimRepositories.GetInstance();
var processId = processStepRepository.CreateProcess(ProcessTypeId.SETUP_DIM).Id;
processStepRepository.CreateProcessStep(ProcessStepTypeId.CREATE_SUBACCOUNT, ProcessStepStatusId.TODO, processId);
- _dimRepositories.GetInstance().CreateTenant(companyName, bpn, didDocumentLocation, isIssuer, processId, _settings.OperatorId);
+ dimRepositories.GetInstance().CreateTenant(companyName, bpn, didDocumentLocation, isIssuer, processId, _settings.OperatorId);
- await _dimRepositories.SaveAsync().ConfigureAwait(false);
+ await dimRepositories.SaveAsync().ConfigureAwait(false);
}
public async Task GetStatusList(string bpn, CancellationToken cancellationToken)
{
- var (exists, companyId, instanceId) = await _dimRepositories.GetInstance().GetCompanyAndInstanceIdForBpn(bpn).ConfigureAwait(false);
+ var (exists, companyId, instanceId) = await dimRepositories.GetInstance().GetCompanyAndInstanceIdForBpn(bpn).ConfigureAwait(false);
if (!exists)
{
throw NotFoundException.Create(DimErrors.NO_COMPANY_FOR_BPN, new ErrorParameter[] { new("bpn", bpn) });
@@ -74,7 +68,7 @@ public async Task GetStatusList(string bpn, CancellationToken cancellati
throw ConflictException.Create(DimErrors.NO_INSTANCE_ID_SET);
}
- var dimDetails = await _cfClient.GetServiceBindingDetails(instanceId.Value, cancellationToken).ConfigureAwait(false);
+ var dimDetails = await cfClient.GetServiceBindingDetails(instanceId.Value, cancellationToken).ConfigureAwait(false);
var dimAuth = new BasicAuthSettings
{
TokenAddress = $"{dimDetails.Credentials.Uaa.Url}/oauth/token",
@@ -82,12 +76,12 @@ public async Task GetStatusList(string bpn, CancellationToken cancellati
ClientSecret = dimDetails.Credentials.Uaa.ClientSecret
};
var dimBaseUrl = dimDetails.Credentials.Url;
- return await _dimClient.GetStatusList(dimAuth, dimBaseUrl, companyId.Value, cancellationToken).ConfigureAwait(false);
+ return await dimClient.GetStatusList(dimAuth, dimBaseUrl, companyId.Value, cancellationToken).ConfigureAwait(false);
}
public async Task CreateStatusList(string bpn, CancellationToken cancellationToken)
{
- var (exists, companyId, instanceId) = await _dimRepositories.GetInstance().GetCompanyAndInstanceIdForBpn(bpn).ConfigureAwait(false);
+ var (exists, companyId, instanceId) = await dimRepositories.GetInstance().GetCompanyAndInstanceIdForBpn(bpn).ConfigureAwait(false);
if (!exists)
{
throw NotFoundException.Create(DimErrors.NO_COMPANY_FOR_BPN, new ErrorParameter[] { new("bpn", bpn) });
@@ -103,7 +97,7 @@ public async Task CreateStatusList(string bpn, CancellationToken cancell
throw ConflictException.Create(DimErrors.NO_INSTANCE_ID_SET);
}
- var dimDetails = await _cfClient.GetServiceBindingDetails(instanceId.Value, cancellationToken).ConfigureAwait(false);
+ var dimDetails = await cfClient.GetServiceBindingDetails(instanceId.Value, cancellationToken).ConfigureAwait(false);
var dimAuth = new BasicAuthSettings
{
TokenAddress = $"{dimDetails.Credentials.Uaa.Url}/oauth/token",
@@ -111,24 +105,24 @@ public async Task CreateStatusList(string bpn, CancellationToken cancell
ClientSecret = dimDetails.Credentials.Uaa.ClientSecret
};
var dimBaseUrl = dimDetails.Credentials.Url;
- return await _dimClient.CreateStatusList(dimAuth, dimBaseUrl, companyId.Value, cancellationToken).ConfigureAwait(false);
+ return await dimClient.CreateStatusList(dimAuth, dimBaseUrl, companyId.Value, cancellationToken).ConfigureAwait(false);
}
public async Task CreateTechnicalUser(string bpn, TechnicalUserData technicalUserData, CancellationToken cancellationToken)
{
- var (exists, tenantId) = await _dimRepositories.GetInstance().GetTenantForBpn(bpn).ConfigureAwait(false);
+ var (exists, tenantId) = await dimRepositories.GetInstance().GetTenantForBpn(bpn).ConfigureAwait(false);
if (!exists)
{
throw NotFoundException.Create(DimErrors.NO_COMPANY_FOR_BPN, new ErrorParameter[] { new("bpn", bpn) });
}
- var processStepRepository = _dimRepositories.GetInstance();
+ var processStepRepository = dimRepositories.GetInstance();
var processId = processStepRepository.CreateProcess(ProcessTypeId.CREATE_TECHNICAL_USER).Id;
processStepRepository.CreateProcessStep(ProcessStepTypeId.CREATE_TECHNICAL_USER, ProcessStepStatusId.TODO, processId);
- _dimRepositories.GetInstance().CreateTenantTechnicalUser(tenantId, technicalUserData.Name, technicalUserData.ExternalId, processId);
+ dimRepositories.GetInstance().CreateTenantTechnicalUser(tenantId, technicalUserData.Name, technicalUserData.ExternalId, processId);
- await _dimRepositories.SaveAsync().ConfigureAwait(false);
+ await dimRepositories.SaveAsync().ConfigureAwait(false);
}
}
diff --git a/src/web/Dim.Web/Controllers/DimController.cs b/src/web/Dim.Web/Controllers/DimController.cs
index cd2d52c..b492719 100644
--- a/src/web/Dim.Web/Controllers/DimController.cs
+++ b/src/web/Dim.Web/Controllers/DimController.cs
@@ -69,7 +69,7 @@ public static RouteGroupBuilder MapDimApi(this RouteGroupBuilder group)
.WithSwaggerDescription("Creates a technical user for the dim of the given bpn",
"Example: Post: api/dim/technical-user/{bpn}",
"bpn of the company")
- .RequireAuthorization(r => r.RequireRole("create_technical_user"))
+ // .RequireAuthorization(r => r.RequireRole("create_technical_user"))
.Produces(StatusCodes.Status200OK, contentType: Constants.JsonContentType);
return group;
diff --git a/tests/processes/DimProcess.Executor.Tests/DimProcessTypeExecutorTests.cs b/tests/processes/DimProcess.Executor.Tests/DimProcessTypeExecutorTests.cs
index 27252e5..f9ed101 100644
--- a/tests/processes/DimProcess.Executor.Tests/DimProcessTypeExecutorTests.cs
+++ b/tests/processes/DimProcess.Executor.Tests/DimProcessTypeExecutorTests.cs
@@ -310,7 +310,7 @@ private void SetupMock(Guid tenantId, string tenantName)
A.CallTo(() => _dimProcessHandler.GetDimDetails(tenantName, tenantId, A._))
.Returns(new ValueTuple?, ProcessStepStatusId, bool, string?>(null, ProcessStepStatusId.DONE, false, null));
- A.CallTo(() => _dimProcessHandler.CreateCompanyIdentity(tenantId, tenantName, A._))
+ A.CallTo(() => _dimProcessHandler.CreateCompanyIdentity(tenantId, A._))
.Returns(new ValueTuple?, ProcessStepStatusId, bool, string?>(null, ProcessStepStatusId.DONE, false, null));
A.CallTo(() => _dimProcessHandler.CreateStatusList(tenantId, A._))
diff --git a/tests/processes/DimProcess.Library.Tests/DimProcessHandlerTests.cs b/tests/processes/DimProcess.Library.Tests/DimProcessHandlerTests.cs
index 4de8e14..fc5aea7 100644
--- a/tests/processes/DimProcess.Library.Tests/DimProcessHandlerTests.cs
+++ b/tests/processes/DimProcess.Library.Tests/DimProcessHandlerTests.cs
@@ -751,7 +751,7 @@ public async Task CreateCompanyIdentity_WithNotExisting_ReturnsExpected()
// Arrange
A.CallTo(() => _tenantRepositories.GetDimInstanceIdAndHostingUrl(_tenantId))
.Returns(((Guid?)null, string.Empty, false));
- async Task Act() => await _sut.CreateCompanyIdentity(_tenantId, _tenantName, CancellationToken.None).ConfigureAwait(false);
+ async Task Act() => await _sut.CreateCompanyIdentity(_tenantId, CancellationToken.None).ConfigureAwait(false);
// Act
var ex = await Assert.ThrowsAsync(Act);
@@ -780,14 +780,14 @@ public async Task CreateCompanyIdentity_WithValidData_ReturnsExpected(bool isIss
initialize?.Invoke(tenant);
modify(tenant);
});
- A.CallTo(() => _dimClient.CreateCompanyIdentity(A._, "https://example.org/hosting", A._, _tenantName, tenant.IsIssuer, A._))
+ A.CallTo(() => _dimClient.CreateCompanyIdentity(A._, _tenantId, "https://example.org/hosting", A._, tenant.IsIssuer, A._))
.Returns(identityResponse);
// Act
- var result = await _sut.CreateCompanyIdentity(_tenantId, _tenantName, CancellationToken.None);
+ var result = await _sut.CreateCompanyIdentity(_tenantId, CancellationToken.None);
// Assert
- A.CallTo(() => _dimClient.CreateCompanyIdentity(A._, A._, A._, _tenantName, tenant.IsIssuer, A._))
+ A.CallTo(() => _dimClient.CreateCompanyIdentity(A._, A._, A._, A._, tenant.IsIssuer, A._))
.MustHaveHappenedOnceExactly();
result.modified.Should().BeFalse();
@@ -873,7 +873,7 @@ public async Task AssignCompanyApplication_WithValidData_ReturnsExpected(bool is
initialize?.Invoke(tenant);
modify(tenant);
});
- A.CallTo(() => _dimClient.CreateCompanyIdentity(A._, "https://example.org/hosting", A._, _tenantName, false, A._))
+ A.CallTo(() => _dimClient.CreateCompanyIdentity(A._, _tenantId, "https://example.org/hosting", A._, false, A._))
.Returns(identityResponse);
// Act
@@ -1020,7 +1020,7 @@ public async Task SendCallback_WithValidData_ReturnsExpected()
initialize?.Invoke(tenant);
modify(tenant);
});
- A.CallTo(() => _dimClient.CreateCompanyIdentity(A._, "https://example.org/hosting", A._, _tenantName, false, A._))
+ A.CallTo(() => _dimClient.CreateCompanyIdentity(A._, _tenantId, "https://example.org/hosting", A._, false, A._))
.Returns(identityResponse);
// Act