diff --git a/DEPENDENCIES b/DEPENDENCIES index 89e2e7268c..ecdca2db7b 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -2,6 +2,7 @@ nuget/nuget/-/AutoFixture.AutoFakeItEasy/4.18.1, MIT, approved, #10064 nuget/nuget/-/AutoFixture.Xunit/4.18.1, MIT, approved, #10082 nuget/nuget/-/AutoFixture/4.18.1, MIT, approved, #10057 nuget/nuget/-/BouncyCastle.Cryptography/2.2.1, MIT AND Apache-2.0 AND BSD-3-Clause AND LicenseRef-Permission-Notice, approved, #10066 +nuget/nuget/-/BouncyCastle.Cryptography/2.4.0, MIT AND Apache-2.0 AND BSD-3-Clause AND LicenseRef-scancode-ietf-trust, approved, #15706 nuget/nuget/-/Castle.Core/5.1.1, Apache-2.0, approved, #13966 nuget/nuget/-/EFCore.NamingConventions/8.0.3, Apache-2.0, approved, #13983 nuget/nuget/-/FakeItEasy/8.1.0, MIT, approved, #13970 @@ -17,7 +18,7 @@ nuget/nuget/-/JsonSchema.Net/6.0.5, MIT AND OFL-1.1 AND CC-BY-SA-4.0, approved, nuget/nuget/-/Laraue.EfCoreTriggers.Common/8.0.3, MIT, approved, #13968 nuget/nuget/-/Laraue.EfCoreTriggers.PostgreSql/8.0.3, MIT, approved, #13984 nuget/nuget/-/MailKit/4.3.0, MIT AND LicenseRef-scancode-ietf AND LicenseRef-scancode-ietf-trust AND (BSD-3-Clause AND LicenseRef-scancode-ietf-trust), approved, #13986 -nuget/nuget/-/MimeKit/4.3.0, MIT AND FSFULLRWD AND LicenseRef-scancode-ietf AND LicenseRef-scancode-ietf-trust AND (BSD-3-Clause AND LicenseRef-scancode-ietf-trust) AND BSD-3-Clause AND MS-PL AND CC-BY-SA-4.0 AND LicenseRef-MIT-style AND CC-PDDC AND GPL-2.0-only, approved, #13987 +nuget/nuget/-/MimeKit/4.7.1, MIT AND FSFULLRWD AND LicenseRef-scancode-ietf AND LicenseRef-scancode-ietf-trust AND (BSD-3-Clause AND LicenseRef-scancode-ietf-trust) AND BSD-3-Clause AND MS-PL AND CC-BY-SA-4.0 AND LicenseRef-MIT-style AND CC-PDDC AND GPL-2.0-only, approved, #15705 nuget/nuget/-/Mono.TextTemplating/2.2.1, MIT, approved, #15073 nuget/nuget/-/NHamcrest/3.4.0, MIT, approved, #13964 nuget/nuget/-/NJsonSchema/10.9.0, MIT, approved, #9300 @@ -41,7 +42,7 @@ nuget/nuget/-/Serilog.Enrichers.Thread/3.1.0, Apache-2.0, approved, clearlydefin nuget/nuget/-/Serilog.Extensions.Hosting/8.0.0, Apache-2.0, approved, #13962 nuget/nuget/-/Serilog.Extensions.Logging/8.0.0, Apache-2.0, approved, #13985 nuget/nuget/-/Serilog.Formatting.Compact/2.0.0, Apache-2.0, approved, #13981 -nuget/nuget/-/Serilog.Settings.Configuration/8.0.0, Apache-2.0, approved, #13988 +nuget/nuget/-/Serilog.Settings.Configuration/8.0.2, Apache-2.0, approved, #13988 nuget/nuget/-/Serilog.Sinks.Console/5.0.0, Apache-2.0, approved, #13980 nuget/nuget/-/Serilog.Sinks.Console/5.0.1, Apache-2.0, approved, #13980 nuget/nuget/-/Serilog.Sinks.Debug/2.0.0, Apache-2.0, approved, clearlydefined diff --git a/src/administration/Administration.Service/Administration.Service.csproj b/src/administration/Administration.Service/Administration.Service.csproj index ab35766c6a..b65072ca07 100644 --- a/src/administration/Administration.Service/Administration.Service.csproj +++ b/src/administration/Administration.Service/Administration.Service.csproj @@ -33,7 +33,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/externalsystems/BpnDidResolver.Library/BpnDidResolver.Library.csproj b/src/externalsystems/BpnDidResolver.Library/BpnDidResolver.Library.csproj index 4fc146abb0..cd3b267855 100644 --- a/src/externalsystems/BpnDidResolver.Library/BpnDidResolver.Library.csproj +++ b/src/externalsystems/BpnDidResolver.Library/BpnDidResolver.Library.csproj @@ -34,8 +34,4 @@ - - - - diff --git a/src/externalsystems/Custodian.Library/Custodian.Library.csproj b/src/externalsystems/Custodian.Library/Custodian.Library.csproj index 7897a90efb..e5eb3aae37 100644 --- a/src/externalsystems/Custodian.Library/Custodian.Library.csproj +++ b/src/externalsystems/Custodian.Library/Custodian.Library.csproj @@ -34,8 +34,4 @@ - - - - diff --git a/src/externalsystems/Dim.Library/BusinessLogic/DimBusinessLogic.cs b/src/externalsystems/Dim.Library/BusinessLogic/DimBusinessLogic.cs index be307c7423..34cf42c3a1 100644 --- a/src/externalsystems/Dim.Library/BusinessLogic/DimBusinessLogic.cs +++ b/src/externalsystems/Dim.Library/BusinessLogic/DimBusinessLogic.cs @@ -103,20 +103,22 @@ private async Task CreateWalletInternal(Guid applicationId, CancellationToken ca public async Task ProcessDimResponse(string bpn, DimWalletData data, CancellationToken cancellationToken) { - var (exists, companyId, companyApplicationStatusIds) = await _portalRepositories.GetInstance().GetCompanyIdByBpn(bpn).ConfigureAwait(ConfigureAwaitOptions.None); - if (!exists) + var companySubmittedApplicationIds = await _portalRepositories.GetInstance().GetCompanySubmittedApplicationIdsByBpn(bpn).ToListAsync(cancellationToken).ConfigureAwait(false); + if (companySubmittedApplicationIds.Count == 0) { throw new NotFoundException($"No company found for bpn {bpn}"); } - if (companyApplicationStatusIds.Count() != 1) + var companyApplicationIds = companySubmittedApplicationIds.SelectMany(x => x.SubmittedApplicationIds.Select(applicationId => (x.CompanyId, ApplicationId: applicationId))); + if (companyApplicationIds.Count() != 1) { throw new ConflictException($"There must be exactly one company application in state {CompanyApplicationStatusId.SUBMITTED}"); } + var (companyId, applicationId) = companyApplicationIds.First(); var context = await _checklistService .VerifyChecklistEntryAndProcessSteps( - companyApplicationStatusIds.Single(), + applicationId, ApplicationChecklistEntryTypeId.IDENTITY_WALLET, [ApplicationChecklistEntryStatusId.IN_PROGRESS], ProcessStepTypeId.AWAIT_DIM_RESPONSE, diff --git a/src/externalsystems/Dim.Library/Dim.Library.csproj b/src/externalsystems/Dim.Library/Dim.Library.csproj index cc8062c9af..37c1be9825 100644 --- a/src/externalsystems/Dim.Library/Dim.Library.csproj +++ b/src/externalsystems/Dim.Library/Dim.Library.csproj @@ -36,7 +36,6 @@ - diff --git a/src/externalsystems/IssuerComponent.Library/IssuerComponent.Library.csproj b/src/externalsystems/IssuerComponent.Library/IssuerComponent.Library.csproj index d09333b64d..ec06ac80dd 100644 --- a/src/externalsystems/IssuerComponent.Library/IssuerComponent.Library.csproj +++ b/src/externalsystems/IssuerComponent.Library/IssuerComponent.Library.csproj @@ -36,7 +36,6 @@ - diff --git a/src/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogic.cs b/src/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogic.cs index 3165fe22d8..06c9539def 100644 --- a/src/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogic.cs +++ b/src/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogic.cs @@ -82,10 +82,11 @@ await _offerProviderService } return ( - new[] { + [ data.IsSingleInstance ? ProcessStepTypeId.SINGLE_INSTANCE_SUBSCRIPTION_DETAILS_CREATION : - ProcessStepTypeId.START_AUTOSETUP }, + ProcessStepTypeId.START_AUTOSETUP + ], triggerProvider ? ProcessStepStatusId.DONE : ProcessStepStatusId.SKIPPED, true, null); @@ -100,6 +101,15 @@ await _offerProviderService throw new NotFoundException($"OfferSubscription {offerSubscriptionId} does not exist"); } + if (string.IsNullOrWhiteSpace(data.CallbackUrl)) + { + return ( + null, + ProcessStepStatusId.SKIPPED, + true, + null); + } + if (data.Status != OfferSubscriptionStatusId.ACTIVE) { throw new ConflictException("offer subscription should be active"); @@ -110,11 +120,6 @@ await _offerProviderService throw new ConflictException("Client should be set"); } - if (string.IsNullOrWhiteSpace(data.CallbackUrl)) - { - throw new ConflictException("Callback Url should be set here"); - } - if (data.ServiceAccounts.Count() > 1) { throw new ConflictException("There should be not more than one service account for the offer subscription"); @@ -123,16 +128,22 @@ await _offerProviderService CallbackTechnicalUserInfoData? technicalUserInfoData = null; if (data.ServiceAccounts.Count() == 1) { - var serviceAccount = data.ServiceAccounts.FirstOrDefault(); + var serviceAccount = data.ServiceAccounts.First(); if (serviceAccount.TechnicalClientId == null) { throw new ConflictException($"ClientId of serviceAccount {serviceAccount.TechnicalUserId} should be set"); } - var internalClientId = await _provisioningManager.GetIdOfCentralClientAsync(serviceAccount.TechnicalClientId).ConfigureAwait(ConfigureAwaitOptions.None); - var authData = await _provisioningManager.GetCentralClientAuthDataAsync(internalClientId).ConfigureAwait(ConfigureAwaitOptions.None); + async Task GetServiceAccountSecret(string technicalClientId) + { + var internalClientId = await _provisioningManager.GetIdOfCentralClientAsync(technicalClientId).ConfigureAwait(ConfigureAwaitOptions.None); + var authData = await _provisioningManager.GetCentralClientAuthDataAsync(internalClientId).ConfigureAwait(ConfigureAwaitOptions.None); + return authData.Secret; + } technicalUserInfoData = new CallbackTechnicalUserInfoData( serviceAccount.TechnicalUserId, - authData.Secret, + serviceAccount.CompanyServiceAccountKindId == CompanyServiceAccountKindId.INTERNAL + ? await GetServiceAccountSecret(serviceAccount.TechnicalClientId).ConfigureAwait(ConfigureAwaitOptions.None) + : null, serviceAccount.TechnicalClientId); } @@ -141,7 +152,7 @@ await _offerProviderService new CallbackClientInfoData(data.ClientId) ); await _offerProviderService - .TriggerOfferProviderCallback(callbackData, data.CallbackUrl!, cancellationToken) + .TriggerOfferProviderCallback(callbackData, data.CallbackUrl, cancellationToken) .ConfigureAwait(ConfigureAwaitOptions.None); return ( diff --git a/src/externalsystems/Provisioning.Library/Provisioning.Library.csproj b/src/externalsystems/Provisioning.Library/Provisioning.Library.csproj index 48ab19660f..69cb28def5 100644 --- a/src/externalsystems/Provisioning.Library/Provisioning.Library.csproj +++ b/src/externalsystems/Provisioning.Library/Provisioning.Library.csproj @@ -36,8 +36,4 @@ - - - - diff --git a/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs b/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs index 1cf3479903..5ded118ed5 100644 --- a/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs +++ b/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs @@ -52,7 +52,7 @@ public Task RegisterConnectorAsync( if (_settings.ClearinghouseConnectDisabled) { return new IApplicationChecklistService.WorkerChecklistProcessStepExecutionResult( - ProcessStepStatusId.DONE, + ProcessStepStatusId.SKIPPED, entry => entry.ApplicationChecklistEntryStatusId = ApplicationChecklistEntryStatusId.DONE, new[] { ProcessStepTypeId.ACTIVATE_APPLICATION }, null, diff --git a/src/framework/Framework.Async/Directory.Build.props b/src/framework/Framework.Async/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.Async/Directory.Build.props +++ b/src/framework/Framework.Async/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.Cors/Directory.Build.props b/src/framework/Framework.Cors/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.Cors/Directory.Build.props +++ b/src/framework/Framework.Cors/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.DBAccess/Directory.Build.props b/src/framework/Framework.DBAccess/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.DBAccess/Directory.Build.props +++ b/src/framework/Framework.DBAccess/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.DBAccess/Framework.DBAccess.csproj b/src/framework/Framework.DBAccess/Framework.DBAccess.csproj index 451ad0082f..2591988d67 100644 --- a/src/framework/Framework.DBAccess/Framework.DBAccess.csproj +++ b/src/framework/Framework.DBAccess/Framework.DBAccess.csproj @@ -61,6 +61,6 @@ - + diff --git a/src/framework/Framework.DateTimeProvider/Directory.Build.props b/src/framework/Framework.DateTimeProvider/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.DateTimeProvider/Directory.Build.props +++ b/src/framework/Framework.DateTimeProvider/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.DateTimeProvider/Framework.DateTimeProvider.csproj b/src/framework/Framework.DateTimeProvider/Framework.DateTimeProvider.csproj index 404d94047d..a3637fe2cc 100644 --- a/src/framework/Framework.DateTimeProvider/Framework.DateTimeProvider.csproj +++ b/src/framework/Framework.DateTimeProvider/Framework.DateTimeProvider.csproj @@ -62,6 +62,6 @@ - + diff --git a/src/framework/Framework.DependencyInjection/Directory.Build.props b/src/framework/Framework.DependencyInjection/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.DependencyInjection/Directory.Build.props +++ b/src/framework/Framework.DependencyInjection/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.DependencyInjection/Framework.DependencyInjection.csproj b/src/framework/Framework.DependencyInjection/Framework.DependencyInjection.csproj index 9b6bd40067..80ee0736f8 100644 --- a/src/framework/Framework.DependencyInjection/Framework.DependencyInjection.csproj +++ b/src/framework/Framework.DependencyInjection/Framework.DependencyInjection.csproj @@ -63,7 +63,7 @@ - + diff --git a/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props b/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props +++ b/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.ErrorHandling.Web/Directory.Build.props b/src/framework/Framework.ErrorHandling.Web/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.ErrorHandling.Web/Directory.Build.props +++ b/src/framework/Framework.ErrorHandling.Web/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.ErrorHandling/Directory.Build.props b/src/framework/Framework.ErrorHandling/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.ErrorHandling/Directory.Build.props +++ b/src/framework/Framework.ErrorHandling/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.HttpClientExtensions/Directory.Build.props b/src/framework/Framework.HttpClientExtensions/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.HttpClientExtensions/Directory.Build.props +++ b/src/framework/Framework.HttpClientExtensions/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.HttpClientExtensions/Framework.HttpClientExtensions.csproj b/src/framework/Framework.HttpClientExtensions/Framework.HttpClientExtensions.csproj index 18dff34d72..8a5faa4690 100644 --- a/src/framework/Framework.HttpClientExtensions/Framework.HttpClientExtensions.csproj +++ b/src/framework/Framework.HttpClientExtensions/Framework.HttpClientExtensions.csproj @@ -63,7 +63,7 @@ - + diff --git a/src/framework/Framework.IO/Directory.Build.props b/src/framework/Framework.IO/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.IO/Directory.Build.props +++ b/src/framework/Framework.IO/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.Linq/Directory.Build.props b/src/framework/Framework.Linq/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.Linq/Directory.Build.props +++ b/src/framework/Framework.Linq/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.Logging/Directory.Build.props b/src/framework/Framework.Logging/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.Logging/Directory.Build.props +++ b/src/framework/Framework.Logging/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.Logging/Framework.Logging.csproj b/src/framework/Framework.Logging/Framework.Logging.csproj index 630a79429b..3bd553213f 100644 --- a/src/framework/Framework.Logging/Framework.Logging.csproj +++ b/src/framework/Framework.Logging/Framework.Logging.csproj @@ -70,7 +70,7 @@ - + diff --git a/src/framework/Framework.Models/Directory.Build.props b/src/framework/Framework.Models/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.Models/Directory.Build.props +++ b/src/framework/Framework.Models/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.Seeding/Directory.Build.props b/src/framework/Framework.Seeding/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.Seeding/Directory.Build.props +++ b/src/framework/Framework.Seeding/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.Seeding/Framework.Seeding.csproj b/src/framework/Framework.Seeding/Framework.Seeding.csproj index bd26565e2a..a2557a068a 100644 --- a/src/framework/Framework.Seeding/Framework.Seeding.csproj +++ b/src/framework/Framework.Seeding/Framework.Seeding.csproj @@ -65,10 +65,9 @@ - - - - + + + diff --git a/src/framework/Framework.Swagger/Directory.Build.props b/src/framework/Framework.Swagger/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.Swagger/Directory.Build.props +++ b/src/framework/Framework.Swagger/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.Token/Directory.Build.props b/src/framework/Framework.Token/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.Token/Directory.Build.props +++ b/src/framework/Framework.Token/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/framework/Framework.Web/Directory.Build.props b/src/framework/Framework.Web/Directory.Build.props index 8791cee03b..7ec978c602 100644 --- a/src/framework/Framework.Web/Directory.Build.props +++ b/src/framework/Framework.Web/Directory.Build.props @@ -19,7 +19,7 @@ - 2.4.0 + 2.4.2 diff --git a/src/keycloak/Keycloak.Factory/Keycloak.Factory.csproj b/src/keycloak/Keycloak.Factory/Keycloak.Factory.csproj index 00dfc031c1..f4a6ed483e 100644 --- a/src/keycloak/Keycloak.Factory/Keycloak.Factory.csproj +++ b/src/keycloak/Keycloak.Factory/Keycloak.Factory.csproj @@ -33,7 +33,7 @@ - + diff --git a/src/mailing/Mailing.SendMail/Mailing.SendMail.csproj b/src/mailing/Mailing.SendMail/Mailing.SendMail.csproj index f969188e74..382f69d5df 100644 --- a/src/mailing/Mailing.SendMail/Mailing.SendMail.csproj +++ b/src/mailing/Mailing.SendMail/Mailing.SendMail.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/mailing/Mailing.Template/Mailing.Template.csproj b/src/mailing/Mailing.Template/Mailing.Template.csproj index 0ae3f39ac0..491d1d1385 100644 --- a/src/mailing/Mailing.Template/Mailing.Template.csproj +++ b/src/mailing/Mailing.Template/Mailing.Template.csproj @@ -27,8 +27,8 @@ - - + + diff --git a/src/maintenance/Maintenance.App/Maintenance.App.csproj b/src/maintenance/Maintenance.App/Maintenance.App.csproj index 1a82379e8a..40d65b3fbc 100644 --- a/src/maintenance/Maintenance.App/Maintenance.App.csproj +++ b/src/maintenance/Maintenance.App/Maintenance.App.csproj @@ -32,7 +32,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -40,7 +40,6 @@ - diff --git a/src/marketplace/Apps.Service/Apps.Service.csproj b/src/marketplace/Apps.Service/Apps.Service.csproj index 95d9db80ed..084d6c2092 100644 --- a/src/marketplace/Apps.Service/Apps.Service.csproj +++ b/src/marketplace/Apps.Service/Apps.Service.csproj @@ -29,7 +29,7 @@ True - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs index a29edfcc7e..7cbe89b75a 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs @@ -230,7 +230,7 @@ public IAsyncEnumerable GetAppAgreement(Guid appId) => /// public Task GetSubscriptionDetailForProvider(Guid appId, Guid subscriptionId) => - _offerService.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, _settings.CompanyAdminRoles); + _offerService.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, _settings.CompanyAdminRoles, new WalletConfigData(_settings.IssuerDid, _settings.BpnDidResolverUrl, _settings.DecentralIdentityManagementAuthUrl)); /// public Task GetSubscriptionDetailForSubscriber(Guid appId, Guid subscriptionId) => diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppsSettings.cs b/src/marketplace/Apps.Service/BusinessLogic/AppsSettings.cs index 5ef1812d18..796595886a 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppsSettings.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppsSettings.cs @@ -225,6 +225,15 @@ public class AppsSettings [Required] [DistinctValues("x => x.DocumentTypeId")] public IEnumerable UploadActiveAppDocumentTypeIds { get; set; } = null!; + + [Required(AllowEmptyStrings = true)] + public string DecentralIdentityManagementAuthUrl { get; set; } = null!; + + [Required(AllowEmptyStrings = true)] + public string IssuerDid { get; set; } = null!; + + [Required(AllowEmptyStrings = true)] + public string BpnDidResolverUrl { get; set; } = null!; } /// diff --git a/src/marketplace/Apps.Service/Controllers/AppsController.cs b/src/marketplace/Apps.Service/Controllers/AppsController.cs index 65950bb393..386846c375 100644 --- a/src/marketplace/Apps.Service/Controllers/AppsController.cs +++ b/src/marketplace/Apps.Service/Controllers/AppsController.cs @@ -230,7 +230,7 @@ public IAsyncEnumerable GetAppAgreement([FromRoute] Guid appId) = /// If sub claim is empty/invalid or user does not exist, or any other parameters are invalid. /// Internal Server Error. [HttpPut] - [Route("/subscription/{subscriptionId}/activate")] + [Route("subscription/{subscriptionId}/activate")] [Authorize(Roles = "activate_subscription")] [Authorize(Policy = PolicyTypes.ValidIdentity)] [Authorize(Policy = PolicyTypes.ValidCompany)] diff --git a/src/marketplace/Offers.Library/Models/WalletConfigData.cs b/src/marketplace/Offers.Library/Models/WalletConfigData.cs new file mode 100644 index 0000000000..a30fd5c62f --- /dev/null +++ b/src/marketplace/Offers.Library/Models/WalletConfigData.cs @@ -0,0 +1,26 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; + +public record WalletConfigData( + string IssuerDid, + string BpnDidResolverUrl, + string DecentralIdentityManagementAuthUrl +); diff --git a/src/marketplace/Offers.Library/Service/IOfferService.cs b/src/marketplace/Offers.Library/Service/IOfferService.cs index 4500324be6..df7e12aabe 100644 --- a/src/marketplace/Offers.Library/Service/IOfferService.cs +++ b/src/marketplace/Offers.Library/Service/IOfferService.cs @@ -248,8 +248,9 @@ Task CreateOrUpdateOfferSubscriptionAgreementConsentAsync(Guid subscriptionId, /// Id of the subscription /// Offer type /// The roles of the users that will be listed as contact + /// The information for the external service data /// Returns the details of the subscription - Task GetAppSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable contactUserRoles); + Task GetAppSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable contactUserRoles, WalletConfigData walletData); /// /// Unsubscribe the Offer subscription by subscriptionId diff --git a/src/marketplace/Offers.Library/Service/OfferService.cs b/src/marketplace/Offers.Library/Service/OfferService.cs index cb2671b85a..b3beae7b5b 100644 --- a/src/marketplace/Offers.Library/Service/OfferService.cs +++ b/src/marketplace/Offers.Library/Service/OfferService.cs @@ -821,11 +821,30 @@ public Task GetSubscriptionDetailsForProviderAsy GetOfferSubscriptionDetailsInternal(offerId, subscriptionId, offerTypeId, contactUserRoles, OfferCompanyRole.Provider, _portalRepositories.GetInstance().GetSubscriptionDetailsForProviderAsync); /// - public async Task GetAppSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable contactUserRoles) + public async Task GetAppSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable contactUserRoles, WalletConfigData walletData) { var data = await GetOfferSubscriptionDetailsInternal(offerId, subscriptionId, offerTypeId, contactUserRoles, OfferCompanyRole.Provider, _portalRepositories.GetInstance().GetAppSubscriptionDetailsForProviderAsync) .ConfigureAwait(ConfigureAwaitOptions.None); - return new AppProviderSubscriptionDetailData(data.Id, data.OfferSubscriptionStatus, data.Name, data.Customer, data.Bpn, data.Contact, data.TechnicalUserData, data.TenantUrl, data.AppInstanceId, data.ProcessSteps.GetProcessStepTypeId(data.Id)); + + return new AppProviderSubscriptionDetailData( + data.Id, + data.OfferSubscriptionStatus, + data.Name, + data.Customer, + data.Bpn, + data.Contact, + data.TechnicalUserData, + data.ConnectorData, + data.TenantUrl, + data.AppInstanceId, + data.ProcessSteps.GetProcessStepTypeId(data.Id), + new SubscriptionExternalServiceData( + walletData.IssuerDid, + data.ExternalServiceData?.ParticipantId, + data.ExternalServiceData == null || data.ExternalServiceData.TrustedIssuer.EndsWith(":holder-iatp") ? data.ExternalServiceData?.TrustedIssuer : $"{data.ExternalServiceData.TrustedIssuer}:holder-iatp", + walletData.BpnDidResolverUrl, + walletData.DecentralIdentityManagementAuthUrl, + data.ExternalServiceData?.DecentralIdentityManagementServiceUrl)); } /// diff --git a/src/marketplace/Offers.Library/Service/OfferSetupService.cs b/src/marketplace/Offers.Library/Service/OfferSetupService.cs index b87ae2b0b8..6892af40e4 100644 --- a/src/marketplace/Offers.Library/Service/OfferSetupService.cs +++ b/src/marketplace/Offers.Library/Service/OfferSetupService.cs @@ -678,7 +678,7 @@ public async Task TriggerActivateSubscription(Guid offerSubscriptionId) if (string.IsNullOrWhiteSpace(offerDetails.RequesterEmail)) { return new ValueTuple?, ProcessStepStatusId, bool, string?>( - offerDetails.InstanceData.IsSingleInstance ? null : new[] { ProcessStepTypeId.TRIGGER_PROVIDER_CALLBACK }, + offerDetails.InstanceData.IsSingleInstance || !offerDetails.HasCallbackUrl ? null : [ProcessStepTypeId.TRIGGER_PROVIDER_CALLBACK], ProcessStepStatusId.DONE, true, null); @@ -687,7 +687,7 @@ public async Task TriggerActivateSubscription(Guid offerSubscriptionId) SendMail(basePortalAddress, $"{offerDetails.RequesterFirstname} {offerDetails.RequesterLastname}", offerDetails.RequesterEmail, offerDetails.OfferName, offerDetails.OfferTypeId); return new ValueTuple?, ProcessStepStatusId, bool, string?>( - offerDetails.InstanceData.IsSingleInstance ? null : new[] { ProcessStepTypeId.TRIGGER_PROVIDER_CALLBACK }, + offerDetails.InstanceData.IsSingleInstance || !offerDetails.HasCallbackUrl ? null : [ProcessStepTypeId.TRIGGER_PROVIDER_CALLBACK], ProcessStepStatusId.DONE, true, null); @@ -712,7 +712,7 @@ private async Task EnableClientAndServiceAccount(Guid offerSubscriptionId, Subsc try { - foreach (var serviceAccountClientId in offerDetails.ServiceAccountClientIds) + foreach (var serviceAccountClientId in offerDetails.InternalServiceAccountClientIds) { await _provisioningManager.EnableClient(serviceAccountClientId).ConfigureAwait(ConfigureAwaitOptions.None); } diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/OfferSubscriptionDetailData.cs b/src/portalbackend/PortalBackend.DBAccess/Models/OfferSubscriptionDetailData.cs index 7b72845a77..f7b8ca48d4 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/OfferSubscriptionDetailData.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/OfferSubscriptionDetailData.cs @@ -69,9 +69,20 @@ public record AppProviderSubscriptionDetailData( string? Bpn, IEnumerable Contact, IEnumerable TechnicalUserData, + IEnumerable ConnectorData, string? TenantUrl, string AppInstanceId, - ProcessStepTypeId? ProcessStepTypeId + ProcessStepTypeId? ProcessStepTypeId, + SubscriptionExternalServiceData ExternalService +); + +public record SubscriptionExternalServiceData( + [property: JsonPropertyName("trusted_issuer")] string TrustedIssuer, + [property: JsonPropertyName("participant_id")] string? ParticipantId, + [property: JsonPropertyName("iatp_id")] string? IatpId, + [property: JsonPropertyName("did_resolver")] string DidResolver, + [property: JsonPropertyName("decentralIdentityManagementAuthUrl")] string DecentralIdentityManagementAuthUrl, + [property: JsonPropertyName("decentralIdentityManagementServiceUrl")] string? DecentralIdentityManagementServiceUrl ); /// @@ -126,5 +137,13 @@ public record AppProviderSubscriptionDetail( IEnumerable TechnicalUserData, string? TenantUrl, string AppInstanceId, - IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId)> ProcessSteps + IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId)> ProcessSteps, + IEnumerable ConnectorData, + ExternalServiceData? ExternalServiceData +); + +public record ExternalServiceData( + [property: JsonPropertyName("trusted_issuer")] string TrustedIssuer, + [property: JsonPropertyName("participant_id")] string? ParticipantId, + [property: JsonPropertyName("decentralIdentityManagementServiceUrl")] string DecentralIdentityManagementServiceUrl ); diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/TriggerProviderInformation.cs b/src/portalbackend/PortalBackend.DBAccess/Models/TriggerProviderInformation.cs index 555bebbb41..01b6e07092 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/TriggerProviderInformation.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/TriggerProviderInformation.cs @@ -49,5 +49,6 @@ public record SubscriptionActivationData( Guid? SalesManagerId, Guid? ProviderCompanyId, string? ClientClientId, - IEnumerable ServiceAccountClientIds + IEnumerable InternalServiceAccountClientIds, + bool HasCallbackUrl ); diff --git a/src/portalbackend/PortalBackend.DBAccess/PortalBackend.DBAccess.csproj b/src/portalbackend/PortalBackend.DBAccess/PortalBackend.DBAccess.csproj index 5811168475..f7812e68e9 100644 --- a/src/portalbackend/PortalBackend.DBAccess/PortalBackend.DBAccess.csproj +++ b/src/portalbackend/PortalBackend.DBAccess/PortalBackend.DBAccess.csproj @@ -33,7 +33,7 @@ - + diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs index 80b2e19b8c..c15224fb1f 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs @@ -367,16 +367,15 @@ public void CreateWalletData(Guid companyId, string did, JsonDocument didDocumen .Select(x => new ValueTuple(true, x.DidDocument)) .SingleOrDefaultAsync(); - public Task<(bool Exists, Guid CompanyId, IEnumerable SubmittedCompanyApplicationId)> GetCompanyIdByBpn(string bpn) => + public IAsyncEnumerable<(Guid CompanyId, IEnumerable SubmittedApplicationIds)> GetCompanySubmittedApplicationIdsByBpn(string bpn) => context.Companies .Where(x => x.BusinessPartnerNumber == bpn) - .Select(x => new ValueTuple>( - true, + .Select(x => new ValueTuple>( x.Id, x.CompanyApplications .Where(ca => ca.ApplicationStatusId == CompanyApplicationStatusId.SUBMITTED) .Select(ca => ca.Id))) - .SingleOrDefaultAsync(); + .ToAsyncEnumerable(); public Task<(string? Bpn, string? Did, string? WalletUrl)> GetDimServiceUrls(Guid companyId) => context.Companies.Where(x => x.Id == companyId) diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs index d77170ded7..e8d44c0a9e 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs @@ -175,7 +175,7 @@ public interface ICompanyRepository Task CheckBpnExists(string bpn); void CreateWalletData(Guid companyId, string did, JsonDocument didDocument, string clientId, byte[] clientSecret, byte[]? initializationVector, int encryptionMode, string authenticationServiceUrl); Task<(bool Exists, JsonDocument DidDocument)> GetDidDocumentById(string bpn); - Task<(bool Exists, Guid CompanyId, IEnumerable SubmittedCompanyApplicationId)> GetCompanyIdByBpn(string bpn); + IAsyncEnumerable<(Guid CompanyId, IEnumerable SubmittedApplicationIds)> GetCompanySubmittedApplicationIdsByBpn(string bpn); Task<(string? Bpn, string? Did, string? WalletUrl)> GetDimServiceUrls(Guid companyId); Task<(string? Holder, string? BusinessPartnerNumber, WalletInformation? WalletInformation)> GetWalletData(Guid identityId); void RemoveProviderCompanyDetails(Guid providerCompanyDetailId); diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs index f13e63de6d..5cbc47b6c8 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs @@ -155,7 +155,7 @@ public interface IOfferSubscriptionsRepository Task GetProcessStepData(Guid offerSubscriptionId, IEnumerable processStepTypeIds); Task GetClientCreationData(Guid offerSubscriptionId); Task GetTechnicalUserCreationData(Guid offerSubscriptionId); - Task<(IEnumerable<(Guid TechnicalUserId, string? TechnicalClientId)> ServiceAccounts, string? ClientId, string? CallbackUrl, OfferSubscriptionStatusId Status)> GetTriggerProviderCallbackInformation(Guid offerSubscriptionId); + Task<(IEnumerable<(Guid TechnicalUserId, string? TechnicalClientId, CompanyServiceAccountKindId CompanyServiceAccountKindId)> ServiceAccounts, string? ClientId, string? CallbackUrl, OfferSubscriptionStatusId Status)> GetTriggerProviderCallbackInformation(Guid offerSubscriptionId); OfferSubscriptionProcessData CreateOfferSubscriptionProcessData(Guid offerSubscriptionId, string offerUrl); void RemoveOfferSubscriptionProcessData(Guid offerSubscriptionProcessDataId); IAsyncEnumerable GetProcessStepsForSubscription(Guid offerSubscriptionId); diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs index 9eae7e9e8a..1257bf97a7 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs @@ -244,7 +244,9 @@ public OfferSubscription AttachAndModifyOfferSubscription(Guid offerSubscription .Select(ps => new ValueTuple( ps.ProcessStepTypeId, ps.ProcessStepStatusId)) - .Distinct()) + .Distinct(), + x.Subscription.ConnectorAssignedOfferSubscriptions.Select(c => new SubscriptionAssignedConnectorData(c.ConnectorId, c.Connector!.Name, c.Connector.ConnectorUrl)), + x.Company.CompanyWalletData == null ? null : new ExternalServiceData(x.Company.CompanyWalletData!.Did, x.Company.BusinessPartnerNumber, x.Company.CompanyWalletData.AuthenticationServiceUrl)) : null)) .SingleOrDefaultAsync(); @@ -396,7 +398,8 @@ public Task GetOfferSubscriptionDataForProcessIdAsync(Guid processId) => x.Offer.OfferTypeId == OfferTypeId.APP && (x.Offer.AppInstanceSetup == null || !x.Offer.AppInstanceSetup!.IsSingleInstance) ? x.AppSubscriptionDetail!.AppInstance!.IamClient!.ClientClientId : null, - x.CompanyServiceAccounts.Where(sa => sa.ClientClientId != null).Select(sa => sa.ClientClientId!) + x.CompanyServiceAccounts.Where(sa => sa.CompanyServiceAccountKindId == CompanyServiceAccountKindId.INTERNAL && sa.ClientClientId != null).Select(sa => sa.ClientClientId!), + x.Offer.ProviderCompany!.ProviderCompanyDetail!.AutoSetupCallbackUrl != null )) .SingleOrDefaultAsync(); @@ -451,11 +454,11 @@ public Task GetOfferSubscriptionDataForProcessIdAsync(Guid processId) => .SingleOrDefaultAsync(); /// - public Task<(IEnumerable<(Guid TechnicalUserId, string? TechnicalClientId)> ServiceAccounts, string? ClientId, string? CallbackUrl, OfferSubscriptionStatusId Status)> GetTriggerProviderCallbackInformation(Guid offerSubscriptionId) => + public Task<(IEnumerable<(Guid TechnicalUserId, string? TechnicalClientId, CompanyServiceAccountKindId CompanyServiceAccountKindId)> ServiceAccounts, string? ClientId, string? CallbackUrl, OfferSubscriptionStatusId Status)> GetTriggerProviderCallbackInformation(Guid offerSubscriptionId) => _context.OfferSubscriptions .Where(x => x.Id == offerSubscriptionId) - .Select(x => new ValueTuple, string?, string?, OfferSubscriptionStatusId>( - x.CompanyServiceAccounts.Select(sa => new ValueTuple(sa.Id, sa.ClientClientId)), + .Select(x => new ValueTuple, string?, string?, OfferSubscriptionStatusId>( + x.CompanyServiceAccounts.Select(sa => new ValueTuple(sa.Id, sa.ClientClientId, sa.CompanyServiceAccountKindId)), x.AppSubscriptionDetail!.AppInstance!.IamClient!.ClientClientId, x.Offer!.ProviderCompany!.ProviderCompanyDetail!.AutoSetupCallbackUrl, x.OfferSubscriptionStatusId diff --git a/src/portalbackend/PortalBackend.Migrations/PortalBackend.Migrations.csproj b/src/portalbackend/PortalBackend.Migrations/PortalBackend.Migrations.csproj index 4031c48f0a..7be952d106 100644 --- a/src/portalbackend/PortalBackend.Migrations/PortalBackend.Migrations.csproj +++ b/src/portalbackend/PortalBackend.Migrations/PortalBackend.Migrations.csproj @@ -32,13 +32,14 @@ true - + all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/portalbackend/PortalBackend.PortalEntities/PortalBackend.PortalEntities.csproj b/src/portalbackend/PortalBackend.PortalEntities/PortalBackend.PortalEntities.csproj index 9ad7e358d9..6222467935 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/PortalBackend.PortalEntities.csproj +++ b/src/portalbackend/PortalBackend.PortalEntities/PortalBackend.PortalEntities.csproj @@ -28,7 +28,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/processes/Processes.ProcessIdentity/Processes.ProcessIdentity.csproj b/src/processes/Processes.ProcessIdentity/Processes.ProcessIdentity.csproj index 7d6eb8ab75..7150bf55e9 100644 --- a/src/processes/Processes.ProcessIdentity/Processes.ProcessIdentity.csproj +++ b/src/processes/Processes.ProcessIdentity/Processes.ProcessIdentity.csproj @@ -25,9 +25,8 @@ Org.Eclipse.TractusX.Portal.Backend.Processes.ProcessIdentity - - - + + diff --git a/src/processes/Processes.Worker/Processes.Worker.csproj b/src/processes/Processes.Worker/Processes.Worker.csproj index 4025f56740..e30770fdd7 100644 --- a/src/processes/Processes.Worker/Processes.Worker.csproj +++ b/src/processes/Processes.Worker/Processes.Worker.csproj @@ -33,13 +33,14 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/processes/Processes.Worker/appsettings.json b/src/processes/Processes.Worker/appsettings.json index 300eda8cc3..241f2e7630 100644 --- a/src/processes/Processes.Worker/appsettings.json +++ b/src/processes/Processes.Worker/appsettings.json @@ -209,6 +209,7 @@ "enabled": true, "emailVerified": true }, + "ClientPrefix": "app", "ServiceAccountClientPrefix": "sa", "ServiceAccountClient": { "clientId": "", diff --git a/src/provisioning/Provisioning.DBAccess/Provisioning.DBAccess.csproj b/src/provisioning/Provisioning.DBAccess/Provisioning.DBAccess.csproj index 6c0aa90b68..4e048ac18c 100644 --- a/src/provisioning/Provisioning.DBAccess/Provisioning.DBAccess.csproj +++ b/src/provisioning/Provisioning.DBAccess/Provisioning.DBAccess.csproj @@ -27,11 +27,11 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/src/provisioning/Provisioning.Migrations/Provisioning.Migrations.csproj b/src/provisioning/Provisioning.Migrations/Provisioning.Migrations.csproj index 42c6d295f0..50c3692935 100644 --- a/src/provisioning/Provisioning.Migrations/Provisioning.Migrations.csproj +++ b/src/provisioning/Provisioning.Migrations/Provisioning.Migrations.csproj @@ -35,7 +35,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -43,6 +43,7 @@ + diff --git a/src/provisioning/Provisioning.ProvisioningEntities/Provisioning.ProvisioningEntities.csproj b/src/provisioning/Provisioning.ProvisioningEntities/Provisioning.ProvisioningEntities.csproj index 7d76a747cb..a664e6b990 100644 --- a/src/provisioning/Provisioning.ProvisioningEntities/Provisioning.ProvisioningEntities.csproj +++ b/src/provisioning/Provisioning.ProvisioningEntities/Provisioning.ProvisioningEntities.csproj @@ -28,7 +28,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/registration/ApplicationActivation.Library/ApplicationActivation.Library.csproj b/src/registration/ApplicationActivation.Library/ApplicationActivation.Library.csproj index 39cb41308d..9f1cfd1e74 100644 --- a/src/registration/ApplicationActivation.Library/ApplicationActivation.Library.csproj +++ b/src/registration/ApplicationActivation.Library/ApplicationActivation.Library.csproj @@ -30,7 +30,7 @@ - + diff --git a/src/registration/Registration.Service/Registration.Service.csproj b/src/registration/Registration.Service/Registration.Service.csproj index f627efa928..40b3a4fdfa 100644 --- a/src/registration/Registration.Service/Registration.Service.csproj +++ b/src/registration/Registration.Service/Registration.Service.csproj @@ -34,7 +34,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/web/Web.PublicInfos/Web.PublicInfos.csproj b/src/web/Web.PublicInfos/Web.PublicInfos.csproj index ac19d5a229..5f48e8b4ff 100644 --- a/src/web/Web.PublicInfos/Web.PublicInfos.csproj +++ b/src/web/Web.PublicInfos/Web.PublicInfos.csproj @@ -27,6 +27,7 @@ + diff --git a/tests/endtoend/EndToEnd.Tests.csproj b/tests/endtoend/EndToEnd.Tests.csproj index 5f511458e3..9a3a4ee3de 100644 --- a/tests/endtoend/EndToEnd.Tests.csproj +++ b/tests/endtoend/EndToEnd.Tests.csproj @@ -33,7 +33,7 @@ - + diff --git a/tests/externalsystems/Dim.Library.Tests/DimBusinessLogicTests.cs b/tests/externalsystems/Dim.Library.Tests/DimBusinessLogicTests.cs index 42bb772b01..797e7abf79 100644 --- a/tests/externalsystems/Dim.Library.Tests/DimBusinessLogicTests.cs +++ b/tests/externalsystems/Dim.Library.Tests/DimBusinessLogicTests.cs @@ -259,8 +259,8 @@ public async Task ProcessDimResponse_NoCompanyForBpn_ThrowsNotFoundException() { // Arrange var data = _fixture.Create(); - A.CallTo(() => _companyRepository.GetCompanyIdByBpn(BPN)) - .Returns(new ValueTuple>(false, default, Enumerable.Empty())); + A.CallTo(() => _companyRepository.GetCompanySubmittedApplicationIdsByBpn(BPN)) + .Returns(Enumerable.Empty>>().ToAsyncEnumerable()); async Task Act() => await _logic.ProcessDimResponse(BPN, data, CancellationToken.None); // Act @@ -277,8 +277,8 @@ public async Task ProcessDimResponse_WithMultipleSubmittedApplications_ThrowsCon { // Arrange var data = _fixture.Create(); - A.CallTo(() => _companyRepository.GetCompanyIdByBpn(BPN)) - .Returns(new ValueTuple>(true, default, _fixture.CreateMany(2))); + A.CallTo(() => _companyRepository.GetCompanySubmittedApplicationIdsByBpn(BPN)) + .Returns(Enumerable.Repeat(new ValueTuple>(default, _fixture.CreateMany(2)), 1).ToAsyncEnumerable()); async Task Act() => await _logic.ProcessDimResponse(BPN, data, CancellationToken.None); // Act @@ -304,8 +304,8 @@ public async Task ProcessDimResponse_WithDidSchemaInvalid_CallsExpected() .With(x => x.Did, "did:web:test.com:BPNL0000000000XX") .Create(); var companyId = Guid.NewGuid(); - A.CallTo(() => _companyRepository.GetCompanyIdByBpn(BPN)) - .Returns(new ValueTuple>(true, companyId, Enumerable.Repeat(ApplicationId, 1))); + A.CallTo(() => _companyRepository.GetCompanySubmittedApplicationIdsByBpn(BPN)) + .Returns(Enumerable.Repeat(new ValueTuple>(companyId, Enumerable.Repeat(ApplicationId, 1)), 1).ToAsyncEnumerable()); A.CallTo(() => _checklistService.VerifyChecklistEntryAndProcessSteps(ApplicationId, ApplicationChecklistEntryTypeId.IDENTITY_WALLET, A>._, ProcessStepTypeId.AWAIT_DIM_RESPONSE, A?>._, A?>._)) .Returns(context); @@ -330,8 +330,8 @@ public async Task ProcessDimResponse_WithFailingSchemaValidation_CallsExpected() var didDocument = JsonDocument.Parse("{\n \"@context\": [\n \"abc\" ],\n \"id\": \"did:web:example.org:did:BPNL0000000000XX\",\n \"verificationMethod\": [\n {\n \"id\": [\"did:web:example.com:did:BPNL0000000000XX#key-0\"],\n \"publicKeyJwk\": {\n \"kty\": \"JsonWebKey2020\",\n \"crv\": \"Ed25519\",\n \"x\": \"3534354354353\"\n }\n }\n ],\n \"services\": [\n {\n \"id\": [\"did:web:example.com:did:BPNL0000000000XX#key-0\"],\n \"serviceEndpoint\": \"test.org:123\"\n }\n ]\n}"); var data = _fixture.Build().With(x => x.DidDocument, didDocument).With(x => x.Did, "did:web:example.org:did:BPNL0000000000XX").Create(); var companyId = Guid.NewGuid(); - A.CallTo(() => _companyRepository.GetCompanyIdByBpn(BPN)) - .Returns(new ValueTuple>(true, companyId, Enumerable.Repeat(ApplicationId, 1))); + A.CallTo(() => _companyRepository.GetCompanySubmittedApplicationIdsByBpn(BPN)) + .Returns(Enumerable.Repeat(new ValueTuple>(companyId, Enumerable.Repeat(ApplicationId, 1)), 1).ToAsyncEnumerable()); A.CallTo(() => _checklistService.VerifyChecklistEntryAndProcessSteps(ApplicationId, ApplicationChecklistEntryTypeId.IDENTITY_WALLET, A>._, ProcessStepTypeId.AWAIT_DIM_RESPONSE, A?>._, A?>._)) .Returns(context); @@ -390,8 +390,8 @@ public async Task ProcessDimResponse_WithValid_CallsExpected() .With(x => x.Did, "did:web:example.org:did:BPNL0000000000XX") .Create(); var companyId = Guid.NewGuid(); - A.CallTo(() => _companyRepository.GetCompanyIdByBpn(BPN)) - .Returns(new ValueTuple>(true, companyId, Enumerable.Repeat(ApplicationId, 1))); + A.CallTo(() => _companyRepository.GetCompanySubmittedApplicationIdsByBpn(BPN)) + .Returns(Enumerable.Repeat(new ValueTuple>(companyId, Enumerable.Repeat(ApplicationId, 1)), 1).ToAsyncEnumerable()); A.CallTo(() => _checklistService.VerifyChecklistEntryAndProcessSteps(ApplicationId, ApplicationChecklistEntryTypeId.IDENTITY_WALLET, A>._, ProcessStepTypeId.AWAIT_DIM_RESPONSE, A?>._, A?>._)) .Returns(context); byte[]? encrypted = null; diff --git a/tests/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogicTests.cs b/tests/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogicTests.cs index 4ee6116a0e..b188f2db40 100644 --- a/tests/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogicTests.cs +++ b/tests/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogicTests.cs @@ -143,7 +143,7 @@ public async Task TriggerProviderCallback_InvalidSubscriptionId_Throws() // Arrange var fakeId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.GetTriggerProviderCallbackInformation(fakeId)) - .Returns<(IEnumerable<(Guid, string?)>, string?, string?, OfferSubscriptionStatusId)>(default); + .Returns<(IEnumerable<(Guid, string?, CompanyServiceAccountKindId)>, string?, string?, OfferSubscriptionStatusId)>(default); async Task Act() => await _sut.TriggerProviderCallback(fakeId, CancellationToken.None); // Act @@ -159,7 +159,7 @@ public async Task TriggerProviderCallback_WithPendingSubscription_Throws() // Arrange var fakeId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.GetTriggerProviderCallbackInformation(fakeId)) - .Returns((Enumerable.Empty<(Guid, string?)>(), string.Empty, null, OfferSubscriptionStatusId.PENDING)); + .Returns((Enumerable.Empty<(Guid, string?, CompanyServiceAccountKindId)>(), string.Empty, "callback", OfferSubscriptionStatusId.PENDING)); async Task Act() => await _sut.TriggerProviderCallback(fakeId, CancellationToken.None); // Act @@ -175,7 +175,7 @@ public async Task TriggerProviderCallback_WithClientIdNotSet_Throws() // Arrange var fakeId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.GetTriggerProviderCallbackInformation(fakeId)) - .Returns((Enumerable.Empty<(Guid, string?)>(), null, null, OfferSubscriptionStatusId.ACTIVE)); + .Returns((Enumerable.Empty<(Guid, string?, CompanyServiceAccountKindId)>(), null, "callback", OfferSubscriptionStatusId.ACTIVE)); async Task Act() => await _sut.TriggerProviderCallback(fakeId, CancellationToken.None); // Act @@ -186,19 +186,19 @@ public async Task TriggerProviderCallback_WithClientIdNotSet_Throws() } [Fact] - public async Task TriggerProviderCallback_WithCallbackUrlNotSet_Throws() + public async Task TriggerProviderCallback_WithCallbackUrlNotSet_Skips() { // Arrange var fakeId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.GetTriggerProviderCallbackInformation(fakeId)) - .Returns((Enumerable.Empty<(Guid, string?)>(), "cl1", null, OfferSubscriptionStatusId.ACTIVE)); - async Task Act() => await _sut.TriggerProviderCallback(fakeId, CancellationToken.None); + .Returns((Enumerable.Empty<(Guid, string?, CompanyServiceAccountKindId)>(), "cl1", null, OfferSubscriptionStatusId.ACTIVE)); // Act - var ex = await Assert.ThrowsAsync(Act); + var result = await _sut.TriggerProviderCallback(fakeId, CancellationToken.None); // Assert - ex.Message.Should().Be("Callback Url should be set here"); + result.nextStepTypeIds.Should().BeNull(); + result.stepStatusId.Should().Be(ProcessStepStatusId.SKIPPED); } [Fact] @@ -207,7 +207,7 @@ public async Task TriggerProviderCallback_WithNoServiceAccountSet_CallsExpected( // Arrange var fakeId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.GetTriggerProviderCallbackInformation(fakeId)) - .Returns((Enumerable.Empty<(Guid, string?)>(), "cl1", "https://callback.com", OfferSubscriptionStatusId.ACTIVE)); + .Returns((Enumerable.Empty<(Guid, string?, CompanyServiceAccountKindId)>(), "cl1", "https://callback.com", OfferSubscriptionStatusId.ACTIVE)); // Act var result = await _sut.TriggerProviderCallback(fakeId, CancellationToken.None); @@ -226,10 +226,10 @@ public async Task TriggerProviderCallback_WithMultipleServiceAccountSet_Throws() { // Arrange var fakeId = Guid.NewGuid(); - var serviceAccounts = new (Guid, string?)[] + var serviceAccounts = new (Guid, string?, CompanyServiceAccountKindId)[] { - new(Guid.NewGuid(), "sa1"), - new(Guid.NewGuid(), "sa2") + new(Guid.NewGuid(), "sa1", CompanyServiceAccountKindId.INTERNAL), + new(Guid.NewGuid(), "sa2", CompanyServiceAccountKindId.INTERNAL) }; A.CallTo(() => _offerSubscriptionRepository.GetTriggerProviderCallbackInformation(fakeId)) .Returns((serviceAccounts, "cl1", "https://callback.com", OfferSubscriptionStatusId.ACTIVE)); @@ -243,15 +243,15 @@ public async Task TriggerProviderCallback_WithMultipleServiceAccountSet_Throws() } [Fact] - public async Task TriggerProviderCallback_WithValidData_ReturnsExpected() + public async Task TriggerProviderCallback_WithValidData_InternalSA_ReturnsExpected() { // Arrange var technicalUserId = Guid.NewGuid(); var technicalUserClientId = "sa1"; var technicalUserInternalClientId = Guid.NewGuid().ToString(); - var serviceAccounts = new (Guid, string?)[] + var serviceAccounts = new (Guid, string?, CompanyServiceAccountKindId)[] { - new(technicalUserId, technicalUserClientId) + new(technicalUserId, technicalUserClientId, CompanyServiceAccountKindId.INTERNAL) }; A.CallTo(() => _offerSubscriptionRepository.GetTriggerProviderCallbackInformation(_subscriptionId)) .Returns((serviceAccounts, "cl1", "https://callback.com", OfferSubscriptionStatusId.ACTIVE)); @@ -271,6 +271,34 @@ public async Task TriggerProviderCallback_WithValidData_ReturnsExpected() .MustHaveHappenedOnceExactly(); } + [Fact] + public async Task TriggerProviderCallback_WithValidData_ExternalSA_ReturnsExpected() + { + // Arrange + var technicalUserId = Guid.NewGuid(); + var technicalUserClientId = "sa1"; + var serviceAccounts = new (Guid, string?, CompanyServiceAccountKindId)[] + { + new(technicalUserId, technicalUserClientId, CompanyServiceAccountKindId.EXTERNAL) + }; + A.CallTo(() => _offerSubscriptionRepository.GetTriggerProviderCallbackInformation(_subscriptionId)) + .Returns((serviceAccounts, "cl1", "https://callback.com", OfferSubscriptionStatusId.ACTIVE)); + + // Act + var result = await _sut.TriggerProviderCallback(_subscriptionId, CancellationToken.None); + + // Assert + result.nextStepTypeIds.Should().BeNull(); + result.stepStatusId.Should().Be(ProcessStepStatusId.DONE); + result.modified.Should().BeTrue(); + A.CallTo(() => _provisioningManager.GetIdOfCentralClientAsync(A._)) + .MustNotHaveHappened(); + A.CallTo(() => _provisioningManager.GetCentralClientAuthDataAsync(A._)) + .MustNotHaveHappened(); + A.CallTo(() => _offerProviderService.TriggerOfferProviderCallback(A.That.Matches(x => x.TechnicalUserInfo!.TechnicalUserSecret == null), A._, A._)) + .MustHaveHappenedOnceExactly(); + } + #endregion #region Setup diff --git a/tests/framework/Framework.Tests.Shared/Framework.Tests.Shared.csproj b/tests/framework/Framework.Tests.Shared/Framework.Tests.Shared.csproj index a3c194a20e..f574fb0d86 100644 --- a/tests/framework/Framework.Tests.Shared/Framework.Tests.Shared.csproj +++ b/tests/framework/Framework.Tests.Shared/Framework.Tests.Shared.csproj @@ -33,7 +33,7 @@ - + diff --git a/tests/framework/Framework.Web.Tests/Framework.Web.Tests.csproj b/tests/framework/Framework.Web.Tests/Framework.Web.Tests.csproj index 2efa6201b3..c55c2ef216 100644 --- a/tests/framework/Framework.Web.Tests/Framework.Web.Tests.csproj +++ b/tests/framework/Framework.Web.Tests/Framework.Web.Tests.csproj @@ -30,7 +30,7 @@ - + diff --git a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs index 4d4da1588f..333346ecc4 100644 --- a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs +++ b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs @@ -503,7 +503,7 @@ public async Task GetSubscriptionDetailForProvider_ReturnsExpected() new UserRoleConfig("ClientTest", new[] {"Test"}) } }; - A.CallTo(() => _offerService.GetAppSubscriptionDetailsForProviderAsync(A._, A._, A._, A>._)) + A.CallTo(() => _offerService.GetAppSubscriptionDetailsForProviderAsync(A._, A._, A._, A>._, A._)) .Returns(data); var sut = new AppsBusinessLogic(null!, null!, _offerService, null!, Options.Create(settings), _identityService); @@ -512,7 +512,7 @@ public async Task GetSubscriptionDetailForProvider_ReturnsExpected() // Assert result.Should().Be(data); - A.CallTo(() => _offerService.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, A>._)) + A.CallTo(() => _offerService.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, A>._, A._)) .MustHaveHappenedOnceExactly(); } diff --git a/tests/marketplace/Apps.Service.Tests/appsettings.IntegrationTests.json b/tests/marketplace/Apps.Service.Tests/appsettings.IntegrationTests.json index 1f00b30b42..1617190390 100644 --- a/tests/marketplace/Apps.Service.Tests/appsettings.IntegrationTests.json +++ b/tests/marketplace/Apps.Service.Tests/appsettings.IntegrationTests.json @@ -234,7 +234,10 @@ } ], "OfferSubscriptionAddress": "https://test.de", - "OfferDetailAddress": "https://detail.de" + "OfferDetailAddress": "https://detail.de", + "DecentralIdentityManagementAuthUrl": "https://test.org/auth", + "IssuerDid": "did:web:example.org:test123", + "BpnDidResolverUrl": "https://test.org/bpn-did" }, "Provisioning": { "CentralRealm": "CX-Central", diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs index 7caecd9920..afbdfbea70 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs @@ -2216,11 +2216,12 @@ public async Task GetAppSubscriptionDetailForProvider_WithNotMatchingUserRoles_T var offerId = Guid.NewGuid(); var subscriptionId = Guid.NewGuid(); var companyAdminRoles = _fixture.CreateMany().ToImmutableArray(); + var walletData = _fixture.Create(); SetupGetSubscriptionDetailForProvider(); // Act - async Task Act() => await _sut.GetAppSubscriptionDetailsForProviderAsync(offerId, subscriptionId, OfferTypeId.APP, companyAdminRoles); + async Task Act() => await _sut.GetAppSubscriptionDetailsForProviderAsync(offerId, subscriptionId, OfferTypeId.APP, companyAdminRoles, walletData); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -2241,13 +2242,14 @@ public async Task GetAppSubscriptionDetailForProvider_WithNotExistingOffer_Throw { new UserRoleConfig("ClientTest", new[] {"Test"}) }; + var walletData = _fixture.Create(); SetupGetSubscriptionDetailForProvider(); A.CallTo(() => _offerSubscriptionsRepository.GetAppSubscriptionDetailsForProviderAsync(A._, A._, A._, A._, A>._)) .Returns<(bool, bool, AppProviderSubscriptionDetail?)>(default); // Act - async Task Act() => await _sut.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, companyAdminRoles); + async Task Act() => await _sut.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, companyAdminRoles, walletData); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -2268,13 +2270,14 @@ public async Task GetAppSubscriptionDetailForProvider_WithUserNotInProvidingComp { new UserRoleConfig("ClientTest", new[] {"Test"}) }; + var walletData = _fixture.Create(); SetupGetSubscriptionDetailForProvider(); A.CallTo(() => _offerSubscriptionsRepository.GetAppSubscriptionDetailsForProviderAsync(A._, A._, A._, A._, A>._)) .Returns((true, false, _fixture.Create())); // Act - async Task Act() => await _sut.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, companyAdminRoles); + async Task Act() => await _sut.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, companyAdminRoles, walletData); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -2295,6 +2298,7 @@ public async Task GetAppSubscriptionDetailForProvider_WithValidData_ReturnsExpec { new UserRoleConfig("ClientTest", new[] {"Test"}) }; + var walletData = _fixture.Create(); SetupGetSubscriptionDetailForProvider(); var data = _fixture.Create(); @@ -2303,7 +2307,7 @@ public async Task GetAppSubscriptionDetailForProvider_WithValidData_ReturnsExpec .Returns((true, true, data)); // Act - var result = await _sut.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, companyAdminRoles); + var result = await _sut.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, companyAdminRoles, walletData); // Assert result.Id.Should().Be(data.Id); diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs index d55165e87e..55ad160255 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs @@ -1285,7 +1285,7 @@ public async Task ActivateSingleInstanceSubscription_WithValidData_ReturnsExpect A.CallTo(() => _notificationService.CreateNotificationsWithExistenceCheck(A>._, null, A>._, A._, A._, A._, A._)) .Returns(new[] { Guid.NewGuid() }.AsFakeIAsyncEnumerable(out var createNotificationsEnumerator)); A.CallTo(() => _offerSubscriptionsRepository.GetSubscriptionActivationDataByIdAsync(offerSubscription.Id)) - .Returns(new SubscriptionActivationData(_validOfferId, OfferSubscriptionStatusId.PENDING, OfferTypeId.APP, "Test App", "Stark Industries", _companyId, requesterEmail, "Tony", "Stark", Guid.NewGuid(), new(true, null), [Guid.NewGuid()], offerSubscriptionProcessDataId, Guid.NewGuid(), _companyId, null, Enumerable.Empty())); + .Returns(new SubscriptionActivationData(_validOfferId, OfferSubscriptionStatusId.PENDING, OfferTypeId.APP, "Test App", "Stark Industries", _companyId, requesterEmail, "Tony", "Stark", Guid.NewGuid(), new(true, null), [Guid.NewGuid()], offerSubscriptionProcessDataId, Guid.NewGuid(), _companyId, null, Enumerable.Empty(), true)); A.CallTo(() => _offerSubscriptionProcessService.VerifySubscriptionAndProcessSteps(offerSubscription.Id, ProcessStepTypeId.ACTIVATE_SUBSCRIPTION, null, true)) .Returns(new ManualProcessStepData(ProcessStepTypeId.ACTIVATE_SUBSCRIPTION, _fixture.Create(), [processStep], _portalRepositories)); @@ -1332,9 +1332,11 @@ public async Task ActivateSingleInstanceSubscription_WithValidData_ReturnsExpect } [Theory] - [InlineData(null)] - [InlineData("test@email.com")] - public async Task ActivateMultipleInstancesSubscription_WithValidData_ReturnsExpected(string? requesterEmail) + [InlineData(null, true)] + [InlineData("test@email.com", true)] + [InlineData(null, false)] + [InlineData("test@email.com", false)] + public async Task ActivateMultipleInstancesSubscription_WithValidData_ReturnsExpected(string? requesterEmail, bool hasCallbackUrl) { // Arrange var offerSubscription = new OfferSubscription(Guid.NewGuid(), _validOfferId, CompanyUserCompanyId, OfferSubscriptionStatusId.PENDING, _companyUserId, default); @@ -1347,7 +1349,7 @@ public async Task ActivateMultipleInstancesSubscription_WithValidData_ReturnsExp A.CallTo(() => _notificationService.CreateNotificationsWithExistenceCheck(A>._, null, A>._, A._, A._, A._, A._)) .Returns(new[] { Guid.NewGuid() }.AsFakeIAsyncEnumerable(out var createNotificationsEnumerator)); A.CallTo(() => _offerSubscriptionsRepository.GetSubscriptionActivationDataByIdAsync(offerSubscription.Id)) - .Returns(new SubscriptionActivationData(_validOfferId, OfferSubscriptionStatusId.PENDING, OfferTypeId.APP, "Test App", "Stark Industries", _companyId, requesterEmail, "Tony", "Stark", Guid.NewGuid(), new(false, null), [Guid.NewGuid()], offerSubscriptionProcessDataId, Guid.NewGuid(), _companyId, clientClientId, serviceAccountClientIds)); + .Returns(new SubscriptionActivationData(_validOfferId, OfferSubscriptionStatusId.PENDING, OfferTypeId.APP, "Test App", "Stark Industries", _companyId, requesterEmail, "Tony", "Stark", Guid.NewGuid(), new(false, null), [Guid.NewGuid()], offerSubscriptionProcessDataId, Guid.NewGuid(), _companyId, clientClientId, serviceAccountClientIds, hasCallbackUrl)); A.CallTo(() => _offerSubscriptionProcessService.VerifySubscriptionAndProcessSteps(offerSubscription.Id, ProcessStepTypeId.ACTIVATE_SUBSCRIPTION, null, true)) .Returns(new ManualProcessStepData(ProcessStepTypeId.ACTIVATE_SUBSCRIPTION, _fixture.Create(), [processStep], _portalRepositories)); @@ -1368,7 +1370,14 @@ public async Task ActivateMultipleInstancesSubscription_WithValidData_ReturnsExp var notificationTypeId = NotificationTypeId.APP_SUBSCRIPTION_ACTIVATION; offerSubscription.OfferSubscriptionStatusId.Should().Be(OfferSubscriptionStatusId.ACTIVE); - result.nextStepTypeIds.Should().ContainInOrder([ProcessStepTypeId.TRIGGER_PROVIDER_CALLBACK]); + if (hasCallbackUrl) + { + result.nextStepTypeIds.Should().ContainInOrder([ProcessStepTypeId.TRIGGER_PROVIDER_CALLBACK]); + } + else + { + result.nextStepTypeIds.Should().BeNull(); + } result.stepStatusId.Should().Be(ProcessStepStatusId.DONE); result.modified.Should().BeTrue(); result.processMessage.Should().BeNull(); diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs index 3040623cd3..c603bb6d05 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs @@ -490,6 +490,7 @@ public async Task GetSubscriptionActivationDataByIdAsync_WithValidData_ReturnsEx result!.OfferName.Should().Be("Trace-X"); result.InstanceData.Should().Be((true, "https://test.com")); result.Status.Should().Be(OfferSubscriptionStatusId.ACTIVE); + result.InternalServiceAccountClientIds.Should().ContainSingle().Which.Should().Be("sa-os-internal"); } [Fact] diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionViewTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionViewTests.cs index 3ea700269f..a21fb09929 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionViewTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionViewTests.cs @@ -49,7 +49,7 @@ public async Task OfferSubscriptionView_GetAll_ReturnsExpected() // Act var result = await sut.OfferSubscriptionView.ToListAsync(); - result.Should().HaveCount(14); + result.Should().HaveCount(15); } [Fact] diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/PortalBackend.DBAccess.Tests.csproj b/tests/portalbackend/PortalBackend.DBAccess.Tests/PortalBackend.DBAccess.Tests.csproj index 7a32e90cdf..9f486828da 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/PortalBackend.DBAccess.Tests.csproj +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/PortalBackend.DBAccess.Tests.csproj @@ -31,7 +31,7 @@ - + diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/company_service_accounts.test.json b/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/company_service_accounts.test.json index 62623cb7f0..4b719c50a2 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/company_service_accounts.test.json +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/company_service_accounts.test.json @@ -68,5 +68,23 @@ "company_service_account_kind_id": 1, "offer_subscription_id": null, "client_client_id": "sa-x-0" + }, + { + "id": "a946f314-f53e-4c72-9124-40b72bcc59aa", + "name": "offersubscription-sa-0", + "description": "internal test user for offersubscription", + "company_service_account_type_id": 2, + "company_service_account_kind_id": 1, + "offer_subscription_id": "ed4de48d-fd4b-4384-a72f-ecae3c6cc5ba", + "client_client_id": "sa-os-internal" + }, + { + "id": "4ce1b774-3d00-4e07-9a53-ae1f64193392", + "name": "offersubscription-sa-0", + "description": "internal test user for offersubscription", + "company_service_account_type_id": 2, + "company_service_account_kind_id": 2, + "offer_subscription_id": "ed4de48d-fd4b-4384-a72f-ecae3c6cc5ba", + "client_client_id": "sa-os-external" } ] diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/identities.test.json b/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/identities.test.json index 91042a1e3a..ed4b43ebce 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/identities.test.json +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/identities.test.json @@ -167,5 +167,23 @@ "user_entity_id": "3d8142f1-860b-48aa-8c2b-1ccb18699f66", "identity_type_id": 2, "last_editor_id":"8b42e6de-7b59-4217-a63c-198e83d93777" + }, + { + "id": "a946f314-f53e-4c72-9124-40b72bcc59aa", + "date_created": "2024-07-22 18:01:33.439000 +00:00", + "company_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", + "user_status_id": 1, + "user_entity_id": null, + "identity_type_id": 2, + "last_editor_id":"8b42e6de-7b59-4217-a63c-198e83d93777" + }, + { + "id": "4ce1b774-3d00-4e07-9a53-ae1f64193392", + "date_created": "2024-07-22 18:01:33.439000 +00:00", + "company_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", + "user_status_id": 1, + "user_entity_id": null, + "identity_type_id": 2, + "last_editor_id":"8b42e6de-7b59-4217-a63c-198e83d93777" } ] diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/ServiceAccountRespotitoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/ServiceAccountRespotitoryTests.cs index 30b792dde6..537cb5d882 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/ServiceAccountRespotitoryTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/ServiceAccountRespotitoryTests.cs @@ -291,13 +291,15 @@ public async Task GetOwnCompanyServiceAccountsUntracked_WithOwnerTrue_ReturnsExp // Assert result.Should().NotBeNull(); - result!.Count.Should().Be(15); + result!.Count.Should().Be(17); result.Data.Should().HaveCount(10) .And.AllSatisfy(x => x.Should().Match(y => y.CompanyServiceAccountTypeId == CompanyServiceAccountTypeId.OWN && y.UserStatusId == UserStatusId.ACTIVE)) .And.BeInAscendingOrder(x => x.Name) .And.Satisfy( + x => x.ServiceAccountId == new Guid("4ce1b774-3d00-4e07-9a53-ae1f64193392"), + x => x.ServiceAccountId == new Guid("a946f314-f53e-4c72-9124-40b72bcc59aa"), x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201029"), x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201026"), x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201027"), @@ -305,9 +307,7 @@ public async Task GetOwnCompanyServiceAccountsUntracked_WithOwnerTrue_ReturnsExp x => x.ServiceAccountId == new Guid("f3498fe6-e0e5-413b-a725-39bf5c7c1959"), x => x.ServiceAccountId == new Guid("ab7f01ea-cbb9-4d58-9efa-ea992395f997"), x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201031"), - x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201032"), - x => x.ServiceAccountId == new Guid("33480038-9acf-40e2-9127-c9c7a9cbed99"), - x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201023")); + x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201032")); } [Fact] diff --git a/tests/portalbackend/PortalBackend.Migrations.Tests/PortalBackend.Migrations.Tests.csproj b/tests/portalbackend/PortalBackend.Migrations.Tests/PortalBackend.Migrations.Tests.csproj index 1df3841653..123215442e 100644 --- a/tests/portalbackend/PortalBackend.Migrations.Tests/PortalBackend.Migrations.Tests.csproj +++ b/tests/portalbackend/PortalBackend.Migrations.Tests/PortalBackend.Migrations.Tests.csproj @@ -32,7 +32,7 @@ - + diff --git a/tests/provisioning/Provisioning.DBAccess.Tests/Provisioning.DBAccess.Tests.csproj b/tests/provisioning/Provisioning.DBAccess.Tests/Provisioning.DBAccess.Tests.csproj index 0882828c1e..64c61060c4 100644 --- a/tests/provisioning/Provisioning.DBAccess.Tests/Provisioning.DBAccess.Tests.csproj +++ b/tests/provisioning/Provisioning.DBAccess.Tests/Provisioning.DBAccess.Tests.csproj @@ -31,7 +31,7 @@ - +