diff --git a/docs/api/administration-service.yaml b/docs/api/administration-service.yaml index dd0e0bcf1c..825f60efeb 100644 --- a/docs/api/administration-service.yaml +++ b/docs/api/administration-service.yaml @@ -4314,7 +4314,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ServiceAccountCreationInfo' + $ref: '#/components/schemas/TechnicalUserCreationInfo' responses: '200': description: The service account was created. @@ -7688,21 +7688,6 @@ components: type: string nullable: true additionalProperties: false - ServiceAccountCreationInfo: - type: object - properties: - name: - type: string - description: - type: string - authenticationType: - $ref: '#/components/schemas/IamClientAuthMethod' - roleIds: - type: array - items: - type: string - format: uuid - additionalProperties: false ServiceAccountDetails: type: object properties: @@ -7747,6 +7732,21 @@ components: authenticationType: $ref: '#/components/schemas/IamClientAuthMethod' additionalProperties: false + TechnicalUserCreationInfo: + type: object + properties: + name: + type: string + description: + type: string + authenticationType: + $ref: '#/components/schemas/IamClientAuthMethod' + roleIds: + type: array + items: + type: string + format: uuid + additionalProperties: false TechnicalUserData: type: object properties: diff --git a/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ITechnicalUserBusinessLogic.cs similarity index 95% rename from src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs rename to src/administration/Administration.Service/BusinessLogic/ITechnicalUserBusinessLogic.cs index eb3030413b..1e702ff876 100644 --- a/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/ITechnicalUserBusinessLogic.cs @@ -26,9 +26,9 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; -public interface IServiceAccountBusinessLogic +public interface ITechnicalUserBusinessLogic { - Task> CreateOwnCompanyServiceAccountAsync(ServiceAccountCreationInfo serviceAccountCreationInfos); + Task> CreateOwnCompanyServiceAccountAsync(TechnicalUserCreationInfo technicalUserCreationInfos); Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId); Task GetOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId); Task UpdateOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId, ServiceAccountEditableDetails serviceAccountDetails); diff --git a/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/TechnicalUserBusinessLogic.cs similarity index 95% rename from src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs rename to src/administration/Administration.Service/BusinessLogic/TechnicalUserBusinessLogic.cs index 2e04568eec..4158fb283f 100644 --- a/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/TechnicalUserBusinessLogic.cs @@ -38,30 +38,30 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; -public class ServiceAccountBusinessLogic( +public class TechnicalUserBusinessLogic( IProvisioningManager provisioningManager, IPortalRepositories portalRepositories, IOptions options, - IServiceAccountCreation serviceAccountCreation, + ITechnicalUserCreation technicalUserCreation, IIdentityService identityService, IServiceAccountManagement serviceAccountManagement) - : IServiceAccountBusinessLogic + : ITechnicalUserBusinessLogic { private readonly IIdentityData _identityData = identityService.IdentityData; private readonly ServiceAccountSettings _settings = options.Value; private const string CompanyId = "companyId"; - public async Task> CreateOwnCompanyServiceAccountAsync(ServiceAccountCreationInfo serviceAccountCreationInfos) + public async Task> CreateOwnCompanyServiceAccountAsync(TechnicalUserCreationInfo technicalUserCreationInfos) { - if (serviceAccountCreationInfos.IamClientAuthMethod != IamClientAuthMethod.SECRET) + if (technicalUserCreationInfos.IamClientAuthMethod != IamClientAuthMethod.SECRET) { - throw ControllerArgumentException.Create(AdministrationServiceAccountErrors.SERVICE_AUTH_SECRET_ARGUMENT, parameters: [new("authenticationType", serviceAccountCreationInfos.IamClientAuthMethod.ToString())]);//TODO implement other authenticationTypes + throw ControllerArgumentException.Create(AdministrationServiceAccountErrors.SERVICE_AUTH_SECRET_ARGUMENT, parameters: [new("authenticationType", technicalUserCreationInfos.IamClientAuthMethod.ToString())]);//TODO implement other authenticationTypes } - if (string.IsNullOrWhiteSpace(serviceAccountCreationInfos.Name)) + if (string.IsNullOrWhiteSpace(technicalUserCreationInfos.Name)) { - throw ControllerArgumentException.Create(AdministrationServiceAccountErrors.SERVICE_NAME_EMPTY_ARGUMENT, parameters: [new("name", serviceAccountCreationInfos.Name)]); + throw ControllerArgumentException.Create(AdministrationServiceAccountErrors.SERVICE_NAME_EMPTY_ARGUMENT, parameters: [new("name", technicalUserCreationInfos.Name)]); } var companyId = _identityData.CompanyId; @@ -76,11 +76,11 @@ public async Task> CreateOwnCompanyServiceAcc throw ConflictException.Create(AdministrationServiceAccountErrors.SERVICE_BPN_NOT_SET_CONFLICT, [new(CompanyId, companyId.ToString())]); } - serviceAccountCreationInfos.UserRoleIds.Except(result.TechnicalUserRoleIds) + technicalUserCreationInfos.UserRoleIds.Except(result.TechnicalUserRoleIds) .IfAny(unassignable => throw ControllerArgumentException.Create(AdministrationServiceAccountErrors.SERVICE_ROLES_NOT_ASSIGN_ARGUMENT, parameters: [new("unassignable", string.Join(",", unassignable)), new("userRoleIds", string.Join(",", result.TechnicalUserRoleIds))])); const TechnicalUserTypeId TechnicalUserTypeId = TechnicalUserTypeId.OWN; - var (_, _, serviceAccounts) = await serviceAccountCreation.CreateServiceAccountAsync(serviceAccountCreationInfos, companyId, [result.Bpn], TechnicalUserTypeId, false, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null)).ConfigureAwait(ConfigureAwaitOptions.None); + var (_, _, serviceAccounts) = await technicalUserCreation.CreateTechnicalUsersAsync(technicalUserCreationInfos, companyId, [result.Bpn], TechnicalUserTypeId, false, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null)).ConfigureAwait(ConfigureAwaitOptions.None); await portalRepositories.SaveAsync().ConfigureAwait(ConfigureAwaitOptions.None); return serviceAccounts.Select(sa => new ServiceAccountDetails( diff --git a/src/administration/Administration.Service/Controllers/ServiceAccountController.cs b/src/administration/Administration.Service/Controllers/ServiceAccountController.cs index 56f6131cb6..859ebcac6e 100644 --- a/src/administration/Administration.Service/Controllers/ServiceAccountController.cs +++ b/src/administration/Administration.Service/Controllers/ServiceAccountController.cs @@ -36,12 +36,12 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers [EnvironmentRoute("MVC_ROUTING_BASEPATH", "serviceaccount")] [Produces("application/json")] [Consumes("application/json")] -public class ServiceAccountController(IServiceAccountBusinessLogic logic) : ControllerBase +public class ServiceAccountController(ITechnicalUserBusinessLogic logic) : ControllerBase { /// /// Creates a new technical user / service account with selected role under the same org as the requester /// - /// + /// /// /// Example: POST: api/administration/serviceaccount/owncompany/serviceaccounts /// The service account was created. @@ -54,8 +54,8 @@ public class ServiceAccountController(IServiceAccountBusinessLogic logic) : Cont [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] - public Task> ExecuteCompanyUserCreation([FromBody] ServiceAccountCreationInfo serviceAccountCreationInfo) => - logic.CreateOwnCompanyServiceAccountAsync(serviceAccountCreationInfo); + public Task> ExecuteCompanyUserCreation([FromBody] TechnicalUserCreationInfo technicalUserCreationInfo) => + logic.CreateOwnCompanyServiceAccountAsync(technicalUserCreationInfo); /// /// Deletes the service account with the given id diff --git a/src/administration/Administration.Service/Program.cs b/src/administration/Administration.Service/Program.cs index f9a1a40b8f..b1d3f805fc 100644 --- a/src/administration/Administration.Service/Program.cs +++ b/src/administration/Administration.Service/Program.cs @@ -63,7 +63,7 @@ await WebAppHelper builder.Services.AddTransient() .ConfigureRegistrationSettings(builder.Configuration.GetSection("Registration")); - builder.Services.AddTransient() + builder.Services.AddTransient() .ConfigureServiceAccountSettings(builder.Configuration.GetSection("ServiceAccount")); builder.Services.AddTransient() diff --git a/src/marketplace/Offers.Library/Service/ITechnicalUserProfileService.cs b/src/marketplace/Offers.Library/Service/ITechnicalUserProfileService.cs index 70fc4c6ac6..9e0ebcc9a7 100644 --- a/src/marketplace/Offers.Library/Service/ITechnicalUserProfileService.cs +++ b/src/marketplace/Offers.Library/Service/ITechnicalUserProfileService.cs @@ -30,12 +30,12 @@ public interface ITechnicalUserProfileService /// /// Id of the offer /// - Task> GetTechnicalUserProfilesForOffer(Guid offerId, OfferTypeId offerTypeId); + Task> GetTechnicalUserProfilesForOffer(Guid offerId, OfferTypeId offerTypeId); /// /// Gets the technical user profiles for the specific offer subscription /// /// Id of the offer /// - Task> GetTechnicalUserProfilesForOfferSubscription(Guid subscriptionId); + Task> GetTechnicalUserProfilesForOfferSubscription(Guid subscriptionId); } diff --git a/src/marketplace/Offers.Library/Service/OfferSetupService.cs b/src/marketplace/Offers.Library/Service/OfferSetupService.cs index 0c7ed37a48..508d1b230a 100644 --- a/src/marketplace/Offers.Library/Service/OfferSetupService.cs +++ b/src/marketplace/Offers.Library/Service/OfferSetupService.cs @@ -45,7 +45,7 @@ public class OfferSetupService : IOfferSetupService { private readonly IPortalRepositories _portalRepositories; private readonly IProvisioningManager _provisioningManager; - private readonly IServiceAccountCreation _serviceAccountCreation; + private readonly ITechnicalUserCreation _technicalUserCreation; private readonly INotificationService _notificationService; private readonly IOfferSubscriptionProcessService _offerSubscriptionProcessService; private readonly IMailingProcessCreation _mailingProcessCreation; @@ -59,7 +59,7 @@ public class OfferSetupService : IOfferSetupService /// /// Factory to access the repositories /// Access to the provisioning manager - /// Access to the service account creation + /// Access to the service account creation /// Creates notifications for the user /// Access to offer subscription process service /// Access to the technical user profile service @@ -70,7 +70,7 @@ public class OfferSetupService : IOfferSetupService public OfferSetupService( IPortalRepositories portalRepositories, IProvisioningManager provisioningManager, - IServiceAccountCreation serviceAccountCreation, + ITechnicalUserCreation technicalUserCreation, INotificationService notificationService, IOfferSubscriptionProcessService offerSubscriptionProcessService, ITechnicalUserProfileService technicalUserProfileService, @@ -81,7 +81,7 @@ public OfferSetupService( { _portalRepositories = portalRepositories; _provisioningManager = provisioningManager; - _serviceAccountCreation = serviceAccountCreation; + _technicalUserCreation = technicalUserCreation; _notificationService = notificationService; _offerSubscriptionProcessService = offerSubscriptionProcessService; _technicalUserProfileService = technicalUserProfileService; @@ -139,12 +139,12 @@ private async Task AutoSetupOfferMultiInstance(Offer var technicalUserClientId = clientInfoData?.ClientId ?? $"{offerDetails.OfferName}-{offerDetails.CompanyName}"; var createTechnicalUserData = new CreateTechnicalUserData(offerDetails.CompanyId, offerDetails.OfferName, offerDetails.Bpn, technicalUserClientId, offerTypeId == OfferTypeId.APP, true); - var (_, processId, technicalUsers) = await CreateTechnicalUserForSubscription(data.RequestId, createTechnicalUserData, null).ConfigureAwait(ConfigureAwaitOptions.None); + var technicalUsers = await CreateTechnicalUserForSubscription(data.RequestId, createTechnicalUserData, null).ConfigureAwait(ConfigureAwaitOptions.None); offerSubscriptionsRepository.AttachAndModifyOfferSubscription(data.RequestId, subscription => { subscription.OfferSubscriptionStatusId = OfferSubscriptionStatusId.ACTIVE; - subscription.ProcessId = processId; + subscription.ProcessId = technicalUsers.ProcessId; }); await CreateNotifications(itAdminRoles, offerTypeId, offerDetails, _identityData.IdentityId).ConfigureAwait(ConfigureAwaitOptions.None); @@ -157,7 +157,7 @@ private async Task AutoSetupOfferMultiInstance(Offer await _portalRepositories.SaveAsync().ConfigureAwait(ConfigureAwaitOptions.None); return new OfferAutoSetupResponseData( - technicalUsers.Select(x => new TechnicalUserInfoData(x.ServiceAccountId, x.UserRoleData.Select(ur => ur.UserRoleText), x.ServiceAccountData?.AuthData.Secret, x.ClientId)), + technicalUsers.ServiceAccounts.Select(x => new TechnicalUserInfoData(x.ServiceAccountId, x.UserRoleData.Select(ur => ur.UserRoleText), x.ServiceAccountData?.AuthData.Secret, x.ClientId)), clientInfoData); } @@ -165,32 +165,33 @@ private async Task AutoSetupOfferMultiInstance(Offer { var technicalUserInfoCreations = await _technicalUserProfileService.GetTechnicalUserProfilesForOfferSubscription(subscriptionId).ConfigureAwait(ConfigureAwaitOptions.None); - ServiceAccountCreationInfo? serviceAccountCreationInfo; - try - { - serviceAccountCreationInfo = technicalUserInfoCreations.SingleOrDefault(); - } - catch (InvalidOperationException) + if (!technicalUserInfoCreations.Any()) { - throw new UnexpectedConditionException($"There should only be one or none technical user profile configured for {subscriptionId}"); + return (false, null, []); } - if (serviceAccountCreationInfo == null) + var serviceAccounts = new List(); + var hasExternalServiceAccount = false; + var processIdToUse = processId; + foreach (var serviceAccountCreationInfo in technicalUserInfoCreations) { - return (false, null, []); + var serviceAccountResult = await _technicalUserCreation + .CreateTechnicalUsersAsync( + serviceAccountCreationInfo, + data.CompanyId, + data.Bpn == null ? Enumerable.Empty() : Enumerable.Repeat(data.Bpn, 1), + TechnicalUserTypeId.MANAGED, + data.EnhanceTechnicalUserName, + data.Enabled, + new ServiceAccountCreationProcessData(ProcessTypeId.OFFER_SUBSCRIPTION, processIdToUse), + sa => { sa.OfferSubscriptionId = subscriptionId; }) + .ConfigureAwait(ConfigureAwaitOptions.None); + processIdToUse = serviceAccountResult.ProcessId; + serviceAccounts.AddRange(serviceAccountResult.TechnicalUsers); + hasExternalServiceAccount = hasExternalServiceAccount || serviceAccountResult.HasExternalTechnicalUser; } - return await _serviceAccountCreation - .CreateServiceAccountAsync( - serviceAccountCreationInfo, - data.CompanyId, - data.Bpn == null ? Enumerable.Empty() : Enumerable.Repeat(data.Bpn, 1), - TechnicalUserTypeId.MANAGED, - data.EnhanceTechnicalUserName, - data.Enabled, - new ServiceAccountCreationProcessData(ProcessTypeId.OFFER_SUBSCRIPTION, processId), - sa => { sa.OfferSubscriptionId = subscriptionId; }) - .ConfigureAwait(ConfigureAwaitOptions.None); + return (hasExternalServiceAccount, processIdToUse, serviceAccounts); } /// @@ -275,8 +276,8 @@ private async IAsyncEnumerable> CreateTechnic var creationData = await _technicalUserProfileService.GetTechnicalUserProfilesForOffer(offerId, offerTypeId).ConfigureAwait(ConfigureAwaitOptions.None); foreach (var creationInfo in creationData) { - var (_, _, result) = await _serviceAccountCreation - .CreateServiceAccountAsync( + var (_, _, result) = await _technicalUserCreation + .CreateTechnicalUsersAsync( creationInfo, data.CompanyId, data.Bpn == null ? Enumerable.Empty() : [data.Bpn], @@ -543,12 +544,12 @@ public async Task CreateSingleInstanceSubscriptionDetail(Guid offerSubscriptionI var technicalUserClientId = data.ClientId ?? $"{data.OfferName}-{data.CompanyName}"; var createTechnicalUserData = new CreateTechnicalUserData(data.CompanyId, data.OfferName, data.Bpn, technicalUserClientId, true, false); - var (hasExternalServiceAccount, _, serviceAccounts) = await CreateTechnicalUserForSubscription(offerSubscriptionId, createTechnicalUserData, processId).ConfigureAwait(ConfigureAwaitOptions.None); - var technicalClientIds = serviceAccounts.Select(x => x.ClientId); + var technicalUsers = await CreateTechnicalUserForSubscription(offerSubscriptionId, createTechnicalUserData, processId).ConfigureAwait(ConfigureAwaitOptions.None); + var technicalClientIds = technicalUsers.ServiceAccounts.Select(sa => sa.ClientId); var content = JsonSerializer.Serialize(new { - technicalClientIds, + technicalClientIds }); await _notificationService.CreateNotifications( @@ -561,7 +562,7 @@ await _notificationService.CreateNotifications( return new ValueTuple?, ProcessStepStatusId, bool, string?>( [ - hasExternalServiceAccount + technicalUsers.HasExternalServiceAccount ? ProcessStepTypeId.OFFERSUBSCRIPTION_CREATE_DIM_TECHNICAL_USER : ProcessStepTypeId.MANUAL_TRIGGER_ACTIVATE_SUBSCRIPTION ], diff --git a/src/marketplace/Offers.Library/Service/TechnicalUserProfileService.cs b/src/marketplace/Offers.Library/Service/TechnicalUserProfileService.cs index 2a354d2ff4..19e0c6471d 100644 --- a/src/marketplace/Offers.Library/Service/TechnicalUserProfileService.cs +++ b/src/marketplace/Offers.Library/Service/TechnicalUserProfileService.cs @@ -42,7 +42,7 @@ public TechnicalUserProfileService(IPortalRepositories portalRepositories) } /// - public async Task> GetTechnicalUserProfilesForOffer(Guid offerId, OfferTypeId offerTypeId) + public async Task> GetTechnicalUserProfilesForOffer(Guid offerId, OfferTypeId offerTypeId) { var data = await _portalRepositories.GetInstance() .GetServiceAccountProfileData(offerId, offerTypeId) @@ -54,11 +54,11 @@ public async Task> GetTechnicalUserProfi return CheckTechnicalUserData(data) ? data.ServiceAccountProfiles.Select(x => GetServiceAccountData(data.OfferName!, x)) - : Enumerable.Empty(); + : Enumerable.Empty(); } /// - public async Task> GetTechnicalUserProfilesForOfferSubscription(Guid subscriptionId) + public async Task> GetTechnicalUserProfilesForOfferSubscription(Guid subscriptionId) { var data = await _portalRepositories.GetInstance() .GetServiceAccountProfileDataForSubscription(subscriptionId) @@ -70,7 +70,7 @@ public async Task> GetTechnicalUserProfi return CheckTechnicalUserData(data) ? data.ServiceAccountProfiles.Select(x => GetServiceAccountData(data.OfferName!, x)) - : Enumerable.Empty(); + : Enumerable.Empty(); } private static bool CheckTechnicalUserData((bool IsSingleInstance, IEnumerable> ServiceAccountProfiles, string? OfferName) data) @@ -83,7 +83,7 @@ private static bool CheckTechnicalUserData((bool IsSingleInstance, IEnumerable serviceAccountUserRoles) => + private static TechnicalUserCreationInfo GetServiceAccountData(string offerName, IEnumerable serviceAccountUserRoles) => new( offerName, $"Technical User for app {offerName} - {string.Join(",", serviceAccountUserRoles.Select(x => x.UserRoleText))}", diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/OfferCompanySubscriptionStatusData.cs b/src/portalbackend/PortalBackend.DBAccess/Models/OfferCompanySubscriptionStatusData.cs index d871326388..94b9dd397b 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/OfferCompanySubscriptionStatusData.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/OfferCompanySubscriptionStatusData.cs @@ -25,37 +25,12 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; /// /// View model containing an offer id and connected company subscription statuses. /// -public class OfferCompanySubscriptionStatusData -{ - /// - /// Constructor. - /// - public OfferCompanySubscriptionStatusData() - { - CompanySubscriptionStatuses = new HashSet(); - } - - /// - /// Id of the offer. - /// - public Guid OfferId { get; set; } - - /// - /// Name of the service. - /// - public string? ServiceName { get; set; } - - /// - /// Subscription statuses of subscribing companies. - /// - public IEnumerable CompanySubscriptionStatuses { get; set; } - - /// - /// Id of the lead Image - /// - /// - public Guid Image { get; set; } -} +public record OfferCompanySubscriptionStatusData( + Guid OfferId, + string? ServiceName, + IEnumerable CompanySubscriptionStatuses, + Guid Image +); /// /// View model containing the ID of a company and its app subscription status in a specific context. diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs index 04edf67fec..0880e5bac7 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs @@ -58,11 +58,10 @@ public OfferSubscription CreateOfferSubscription(Guid offerId, Guid companyId, O SubscriptionStatusSorting.OfferIdDesc => (IEnumerable o) => o.OrderByDescending(offer => offer.Id), _ => null }, - g => new OfferCompanySubscriptionStatusData - { - OfferId = g.Id, - ServiceName = g.Name, - CompanySubscriptionStatuses = g.OfferSubscriptions + g => new OfferCompanySubscriptionStatusData( + g.Id, + g.Name, + g.OfferSubscriptions .Where(os => statusIds.Contains(os.OfferSubscriptionStatusId) && (companyName == null || EF.Functions.ILike(os.Company!.Name, $"%{companyName.EscapeForILike()}%"))) @@ -82,11 +81,11 @@ public OfferSubscription CreateOfferSubscription(Guid offerId, Guid companyId, O ps.ProcessStepTypeId, ps.ProcessStepStatusId)) .Distinct())), - Image = g.Documents + g.Documents .Where(document => document.DocumentTypeId == DocumentTypeId.APP_LEADIMAGE && document.DocumentStatusId == DocumentStatusId.LOCKED) .Select(document => document.Id) .FirstOrDefault() - }) + )) .SingleOrDefaultAsync(); /// diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscription.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscription.cs index 78ac2ea176..f8640d4c2d 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscription.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscription.cs @@ -49,7 +49,6 @@ public OfferSubscription() /// Company id. /// app subscription status. /// Id of the requester - /// Id of the editor /// DateCreated of an Subscription public OfferSubscription(Guid id, Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId, DateTimeOffset dateCreated) : this() diff --git a/src/provisioning/Provisioning.Library/Extensions/ServiceAccountCreationExtensions.cs b/src/provisioning/Provisioning.Library/Extensions/ServiceAccountCreationExtensions.cs index b48b97d606..6388d1060d 100644 --- a/src/provisioning/Provisioning.Library/Extensions/ServiceAccountCreationExtensions.cs +++ b/src/provisioning/Provisioning.Library/Extensions/ServiceAccountCreationExtensions.cs @@ -35,7 +35,7 @@ public static IServiceCollection AddServiceAccountCreation(this IServiceCollecti .EnvironmentalValidation(section); services - .AddTransient(); + .AddTransient(); return services; } diff --git a/src/provisioning/Provisioning.Library/Models/ServiceAccountCreationInfo.cs b/src/provisioning/Provisioning.Library/Models/TechnicalUserCreationInfo.cs similarity index 97% rename from src/provisioning/Provisioning.Library/Models/ServiceAccountCreationInfo.cs rename to src/provisioning/Provisioning.Library/Models/TechnicalUserCreationInfo.cs index 9d4b5c759d..130e1e0368 100644 --- a/src/provisioning/Provisioning.Library/Models/ServiceAccountCreationInfo.cs +++ b/src/provisioning/Provisioning.Library/Models/TechnicalUserCreationInfo.cs @@ -30,7 +30,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; /// Description for the service account table /// Method of the authentication /// ids for the user roles -public record ServiceAccountCreationInfo( +public record TechnicalUserCreationInfo( [property: JsonPropertyName("name")] string Name, [property: JsonPropertyName("description")] string Description, [property: JsonPropertyName("authenticationType")] IamClientAuthMethod IamClientAuthMethod, diff --git a/src/provisioning/Provisioning.Library/Service/IServiceAccountCreation.cs b/src/provisioning/Provisioning.Library/Service/ITechnicalUserCreation.cs similarity index 87% rename from src/provisioning/Provisioning.Library/Service/IServiceAccountCreation.cs rename to src/provisioning/Provisioning.Library/Service/ITechnicalUserCreation.cs index b76fcef51d..aaabfcdd41 100644 --- a/src/provisioning/Provisioning.Library/Service/IServiceAccountCreation.cs +++ b/src/provisioning/Provisioning.Library/Service/ITechnicalUserCreation.cs @@ -23,7 +23,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Service; -public interface IServiceAccountCreation +public interface ITechnicalUserCreation { /// /// Creates the technical user account and stores the client in the service account table @@ -31,14 +31,14 @@ public interface IServiceAccountCreation /// Creation Data /// Id of the company the technical user is created for /// Optional list of bpns to set for the user - /// The type of the created service account + /// The type of the created service account /// If true the technicalUserName will get enhanced by the id of the clientID. /// if true the technical user will be enabled, otherwise false /// The process that should be created if a role for a provider type was selected /// /// Returns information about the created technical user - Task<(bool HasExternalServiceAccount, Guid? processId, IEnumerable ServiceAccounts)> CreateServiceAccountAsync( - ServiceAccountCreationInfo creationData, + Task<(bool HasExternalTechnicalUser, Guid? ProcessId, IEnumerable TechnicalUsers)> CreateTechnicalUsersAsync( + TechnicalUserCreationInfo creationData, Guid companyId, IEnumerable bpns, TechnicalUserTypeId technicalUserTypeId, diff --git a/src/provisioning/Provisioning.Library/Service/ServiceAccountCreation.cs b/src/provisioning/Provisioning.Library/Service/TechnicalUserCreation.cs similarity index 96% rename from src/provisioning/Provisioning.Library/Service/ServiceAccountCreation.cs rename to src/provisioning/Provisioning.Library/Service/TechnicalUserCreation.cs index 020d04d94a..4ded6b7b0b 100644 --- a/src/provisioning/Provisioning.Library/Service/ServiceAccountCreation.cs +++ b/src/provisioning/Provisioning.Library/Service/TechnicalUserCreation.cs @@ -36,16 +36,16 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Service; /// -public class ServiceAccountCreation( +public class TechnicalUserCreation( IProvisioningManager provisioningManager, IPortalRepositories portalRepositories, IProvisioningDBAccess provisioningDbAccess, - IOptions options) : IServiceAccountCreation + IOptions options) : ITechnicalUserCreation { private readonly ServiceAccountCreationSettings _settings = options.Value; /// - async Task<(bool HasExternalServiceAccount, Guid? processId, IEnumerable ServiceAccounts)> IServiceAccountCreation.CreateServiceAccountAsync(ServiceAccountCreationInfo creationData, + async Task<(bool HasExternalTechnicalUser, Guid? ProcessId, IEnumerable TechnicalUsers)> ITechnicalUserCreation.CreateTechnicalUsersAsync(TechnicalUserCreationInfo creationData, Guid companyId, IEnumerable bpns, TechnicalUserTypeId technicalUserTypeId, diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/TechnicalUserBusinessLogicTests.cs similarity index 87% rename from tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs rename to tests/administration/Administration.Service.Tests/BusinessLogic/TechnicalUserBusinessLogicTests.cs index ced7bb46ca..e6a0ecf92a 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/TechnicalUserBusinessLogicTests.cs @@ -39,7 +39,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.BusinessLogic; -public class ServiceAccountBusinessLogicTests +public class TechnicalUserBusinessLogicTests { private const string ValidBpn = "BPNL00000003CRHK"; private const string ClientId = "Cl1-CX-Registration"; @@ -54,7 +54,7 @@ public class ServiceAccountBusinessLogicTests private static readonly Guid ExternalServiceAccount = Guid.NewGuid(); private readonly IIdentityData _identity; private readonly IEnumerable _userRoleIds = Enumerable.Repeat(Guid.NewGuid(), 1); - private readonly IServiceAccountCreation _serviceAccountCreation; + private readonly ITechnicalUserCreation _technicalUserCreation; private readonly ICompanyRepository _companyRepository; private readonly IUserRepository _userRepository; private readonly IUserRolesRepository _userRolesRepository; @@ -68,13 +68,13 @@ public class ServiceAccountBusinessLogicTests private readonly IOptions _options; private readonly IIdentityService _identityService; - public ServiceAccountBusinessLogicTests() + public TechnicalUserBusinessLogicTests() { _fixture = new Fixture().Customize(new AutoFakeItEasyCustomization { ConfigureMembers = true }); _fixture.ConfigureFixture(); _provisioningManager = A.Fake(); - _serviceAccountCreation = A.Fake(); + _technicalUserCreation = A.Fake(); _serviceAccountManagement = A.Fake(); _companyRepository = A.Fake(); @@ -113,8 +113,8 @@ public async Task CreateOwnCompanyServiceAccountAsync_WithValidInput_ReturnsCrea { // Arrange SetupCreateOwnCompanyServiceAccount(); - var serviceAccountCreationInfos = new ServiceAccountCreationInfo("TheName", "Just a short description", IamClientAuthMethod.SECRET, Enumerable.Repeat(UserRoleId1, 1)); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, _serviceAccountCreation, _identityService, _serviceAccountManagement); + var serviceAccountCreationInfos = new TechnicalUserCreationInfo("TheName", "Just a short description", IamClientAuthMethod.SECRET, Enumerable.Repeat(UserRoleId1, 1)); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, _technicalUserCreation, _identityService, _serviceAccountManagement); // Act var result = await sut.CreateOwnCompanyServiceAccountAsync(serviceAccountCreationInfos); @@ -131,8 +131,8 @@ public async Task CreateOwnCompanyServiceAccountAsync_WithInvalidUser_NotFoundEx var identity = _fixture.Create(); A.CallTo(() => _identityService.IdentityData).Returns(identity); SetupCreateOwnCompanyServiceAccount(); - var serviceAccountCreationInfos = new ServiceAccountCreationInfo("TheName", "Just a short description", IamClientAuthMethod.SECRET, Enumerable.Repeat(UserRoleId1, 1)); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, _serviceAccountCreation, _identityService, _serviceAccountManagement); + var serviceAccountCreationInfos = new TechnicalUserCreationInfo("TheName", "Just a short description", IamClientAuthMethod.SECRET, Enumerable.Repeat(UserRoleId1, 1)); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, _technicalUserCreation, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.CreateOwnCompanyServiceAccountAsync(serviceAccountCreationInfos); @@ -147,8 +147,8 @@ public async Task CreateOwnCompanyServiceAccountAsync_WithEmptyName_ThrowsContro { // Arrange SetupCreateOwnCompanyServiceAccount(); - var serviceAccountCreationInfos = new ServiceAccountCreationInfo(string.Empty, "Just a short description", IamClientAuthMethod.SECRET, Enumerable.Repeat(UserRoleId1, 1)); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, _serviceAccountCreation, _identityService, _serviceAccountManagement); + var serviceAccountCreationInfos = new TechnicalUserCreationInfo(string.Empty, "Just a short description", IamClientAuthMethod.SECRET, Enumerable.Repeat(UserRoleId1, 1)); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, _technicalUserCreation, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.CreateOwnCompanyServiceAccountAsync(serviceAccountCreationInfos); @@ -166,8 +166,8 @@ public async Task CreateOwnCompanyServiceAccountAsync_WithInvalidIamClientAuthMe { // Arrange SetupCreateOwnCompanyServiceAccount(); - var serviceAccountCreationInfos = new ServiceAccountCreationInfo("TheName", "Just a short description", IamClientAuthMethod.JWT, Enumerable.Repeat(UserRoleId1, 1)); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, _serviceAccountCreation, _identityService, _serviceAccountManagement); + var serviceAccountCreationInfos = new TechnicalUserCreationInfo("TheName", "Just a short description", IamClientAuthMethod.JWT, Enumerable.Repeat(UserRoleId1, 1)); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, _technicalUserCreation, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.CreateOwnCompanyServiceAccountAsync(serviceAccountCreationInfos); @@ -186,8 +186,8 @@ public async Task CreateOwnCompanyServiceAccountAsync_WithInvalidUserRoleId_Thro // Arrange var wrongUserRoleId = Guid.NewGuid(); SetupCreateOwnCompanyServiceAccount(); - var serviceAccountCreationInfos = new ServiceAccountCreationInfo("TheName", "Just a short description", IamClientAuthMethod.SECRET, [UserRoleId1, wrongUserRoleId]); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, _serviceAccountCreation, _identityService, _serviceAccountManagement); + var serviceAccountCreationInfos = new TechnicalUserCreationInfo("TheName", "Just a short description", IamClientAuthMethod.SECRET, [UserRoleId1, wrongUserRoleId]); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, _technicalUserCreation, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.CreateOwnCompanyServiceAccountAsync(serviceAccountCreationInfos); @@ -210,7 +210,7 @@ public async Task GetOwnCompanyServiceAccountDetailsAsync_WithValidInput_GetsAll { // Arrange SetupGetOwnCompanyServiceAccountDetails(); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act var result = await sut.GetOwnCompanyServiceAccountDetailsAsync(ValidServiceAccountId); @@ -230,7 +230,7 @@ public async Task GetOwnCompanyServiceAccountDetailsAsync_WithValidInputAndDimCo { // Arrange SetupGetOwnCompanyServiceAccountDetails(); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act var result = await sut.GetOwnCompanyServiceAccountDetailsAsync(ValidServiceAccountWithDimDataId); @@ -252,7 +252,7 @@ public async Task GetOwnCompanyServiceAccountDetailsAsync_WithInvalidCompany_Not SetupGetOwnCompanyServiceAccountDetails(); var invalidCompanyId = Guid.NewGuid(); A.CallTo(() => _identity.CompanyId).Returns(invalidCompanyId); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.GetOwnCompanyServiceAccountDetailsAsync(ValidServiceAccountId); @@ -268,7 +268,7 @@ public async Task GetOwnCompanyServiceAccountDetailsAsync_WithInvalidServiceAcco // Arrange SetupGetOwnCompanyServiceAccountDetails(); var invalidServiceAccountId = Guid.NewGuid(); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.GetOwnCompanyServiceAccountDetailsAsync(invalidServiceAccountId); @@ -287,7 +287,7 @@ public async Task ResetOwnCompanyServiceAccountSecretAsync_WithValidInput_GetsAl { // Arrange SetupResetOwnCompanyServiceAccountSecret(); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act var result = await sut.ResetOwnCompanyServiceAccountSecretAsync(ValidServiceAccountId); @@ -304,7 +304,7 @@ public async Task ResetOwnCompanyServiceAccountSecretAsync_WithInvalidUser_NotFo SetupResetOwnCompanyServiceAccountSecret(); var invalidUser = _fixture.Create(); A.CallTo(() => _identityService.IdentityData).Returns(invalidUser); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.ResetOwnCompanyServiceAccountSecretAsync(ValidServiceAccountId); @@ -320,7 +320,7 @@ public async Task ResetOwnCompanyServiceAccountSecretAsync_WithInvalidServiceAcc // Arrange SetupResetOwnCompanyServiceAccountSecret(); var invalidServiceAccountId = Guid.NewGuid(); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.ResetOwnCompanyServiceAccountSecretAsync(invalidServiceAccountId); @@ -340,7 +340,7 @@ public async Task UpdateOwnCompanyServiceAccountDetailsAsync_WithValidData_Retur // Arrange SetupUpdateOwnCompanyServiceAccountDetails(); var data = new ServiceAccountEditableDetails(ValidServiceAccountId, "new name", "changed description", IamClientAuthMethod.SECRET); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); TechnicalUser? initial = null; TechnicalUser? modified = null; @@ -375,7 +375,7 @@ public async Task UpdateOwnCompanyServiceAccountDetailsAsync_WithInvalidAuthMeth // Arrange SetupUpdateOwnCompanyServiceAccountDetails(); var data = new ServiceAccountEditableDetails(ValidServiceAccountId, "new name", "changed description", IamClientAuthMethod.JWT); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.UpdateOwnCompanyServiceAccountDetailsAsync(ValidServiceAccountId, data); @@ -393,7 +393,7 @@ public async Task UpdateOwnCompanyServiceAccountDetailsAsync_WithDifferentServic // Arrange SetupUpdateOwnCompanyServiceAccountDetails(); var data = new ServiceAccountEditableDetails(ValidServiceAccountId, "new name", "changed description", IamClientAuthMethod.SECRET); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.UpdateOwnCompanyServiceAccountDetailsAsync(Guid.NewGuid(), data); @@ -415,7 +415,7 @@ public async Task UpdateOwnCompanyServiceAccountDetailsAsync_WithNotExistingServ A.CallTo(() => _technicalUserRepository.GetTechnicalUserWithRoleDataClientIdAsync(invalidServiceAccountId, ValidCompanyId)) .Returns(null); var data = new ServiceAccountEditableDetails(invalidServiceAccountId, "new name", "changed description", IamClientAuthMethod.SECRET); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.UpdateOwnCompanyServiceAccountDetailsAsync(invalidServiceAccountId, data); @@ -436,7 +436,7 @@ public async Task UpdateOwnCompanyServiceAccountDetailsAsync_WithInactiveService A.CallTo(() => _technicalUserRepository.GetTechnicalUserWithRoleDataClientIdAsync(InactiveServiceAccount, ValidCompanyId)) .Returns(inactive); var data = new ServiceAccountEditableDetails(InactiveServiceAccount, "new name", "changed description", IamClientAuthMethod.SECRET); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.UpdateOwnCompanyServiceAccountDetailsAsync(InactiveServiceAccount, data); @@ -460,7 +460,7 @@ public async Task UpdateOwnCompanyServiceAccountDetailsAsync_WithExternalService A.CallTo(() => _technicalUserRepository.GetTechnicalUserWithRoleDataClientIdAsync(ExternalServiceAccount, ValidCompanyId)) .Returns(external); var data = new ServiceAccountEditableDetails(ExternalServiceAccount, "new name", "changed description", IamClientAuthMethod.SECRET); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act var result = await sut.UpdateOwnCompanyServiceAccountDetailsAsync(ExternalServiceAccount, data); @@ -505,7 +505,7 @@ public async Task GetOwnCompanyServiceAccountsDataAsync_GetsExpectedData(IEnumer .Returns((int skip, int take) => Task.FromResult?>(new(data.Count(), data.Skip(skip).Take(take)))); A.CallTo(() => _portalRepositories.GetInstance()).Returns(_technicalUserRepository); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act var result = await sut.GetOwnCompanyServiceAccountsDataAsync(1, 10, null, null, isUserInactive, userStatusIds); @@ -536,7 +536,7 @@ public async Task DeleteOwnCompanyServiceAccountAsync_WithNotExistingServiceAcco var serviceAccountId = Guid.NewGuid(); SetupDeleteOwnCompanyServiceAccount(); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.DeleteOwnCompanyServiceAccountAsync(serviceAccountId); @@ -556,7 +556,7 @@ public async Task DeleteOwnCompanyServiceAccountAsync_WithExistingOfferSubscript A.CallTo(() => _technicalUserRepository.GetOwnTechnicalUserWithIamUserRolesAsync(A.That.Not.Matches(x => x == ValidServiceAccountId), A._, A>._)) .Returns(null); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.DeleteOwnCompanyServiceAccountAsync(ValidServiceAccountId); @@ -576,7 +576,7 @@ public async Task DeleteOwnCompanyServiceAccountAsync_WithInvalidConnectorStatus A.CallTo(() => _technicalUserRepository.GetOwnTechnicalUserWithIamUserRolesAsync(A.That.Not.Matches(x => x == ValidServiceAccountId), A._, A>._)) .Returns(null); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.DeleteOwnCompanyServiceAccountAsync(ValidServiceAccountId); @@ -597,7 +597,7 @@ public async Task DeleteOwnCompanyServiceAccountAsync_WithServiceAccountNotActiv A.CallTo(() => _technicalUserRepository.GetOwnTechnicalUserWithIamUserRolesAsync(ValidServiceAccountId, ValidCompanyId, A>._)) .Returns(new OwnTechnicalUserData(_userRoleIds, ValidServiceAccountId, userStatusId, true, Guid.NewGuid(), null, null, ConnectorStatusId.ACTIVE, OfferSubscriptionStatusId.PENDING, false, false, null)); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.DeleteOwnCompanyServiceAccountAsync(ValidServiceAccountId); @@ -614,7 +614,7 @@ public async Task DeleteOwnCompanyServiceAccountAsync_WithUserNotOwnerOrProvider A.CallTo(() => _technicalUserRepository.GetOwnTechnicalUserWithIamUserRolesAsync(ValidServiceAccountId, ValidCompanyId, A>._)) .Returns(new OwnTechnicalUserData(_userRoleIds, ValidServiceAccountId, UserStatusId.ACTIVE, false, Guid.NewGuid(), null, null, ConnectorStatusId.ACTIVE, OfferSubscriptionStatusId.PENDING, false, false, null)); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act async Task Act() => await sut.DeleteOwnCompanyServiceAccountAsync(ValidServiceAccountId); @@ -637,7 +637,7 @@ public async Task DeleteOwnCompanyServiceAccountAsync_WithoutClient_CallsExpecte .Create(); var processId = Guid.NewGuid(); SetupDeleteOwnCompanyServiceAccount(connector, identity, processId); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act await sut.DeleteOwnCompanyServiceAccountAsync(ValidServiceAccountId); @@ -663,7 +663,7 @@ public async Task GetServiceAccountRolesAsync_GetsExpectedData() A.CallTo(() => _portalRepositories.GetInstance()).Returns(_userRolesRepository); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, null!, _identityService, _serviceAccountManagement); // Act var result = await sut.GetServiceAccountRolesAsync(null).ToListAsync(); @@ -695,7 +695,7 @@ public async Task HandleServiceAccountCreationCallback_WithValidOfferSubscriptio A.CallTo(() => _processStepRepository.GetProcessDataForServiceAccountCallback(A._, A>._)) .Returns((ProcessTypeId.OFFER_SUBSCRIPTION, context, Guid.NewGuid(), Guid.NewGuid())); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, _serviceAccountCreation, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, _technicalUserCreation, _identityService, _serviceAccountManagement); // Act await sut.HandleServiceAccountCreationCallback(process.Id, _fixture.Create()); @@ -717,7 +717,7 @@ public async Task HandleServiceAccountCreationCallback_WithNotExistingProcess_Th A.CallTo(() => _processStepRepository.GetProcessDataForServiceAccountCallback(A._, A>._)) .Returns<(ProcessTypeId, VerifyProcessData, Guid?, Guid?)>(default); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, _serviceAccountCreation, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, _technicalUserCreation, _identityService, _serviceAccountManagement); async Task Act() => await sut.HandleServiceAccountCreationCallback(process.Id, _fixture.Create()); @@ -740,7 +740,7 @@ public async Task HandleServiceAccountCreationCallback_WithOfferSubscriptionIdNo A.CallTo(() => _processStepRepository.GetProcessDataForServiceAccountCallback(A._, A>._)) .Returns((ProcessTypeId.OFFER_SUBSCRIPTION, context, null, null)); - var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, _serviceAccountCreation, _identityService, _serviceAccountManagement); + var sut = new TechnicalUserBusinessLogic(_provisioningManager, _portalRepositories, _options, _technicalUserCreation, _identityService, _serviceAccountManagement); async Task Act() => await sut.HandleServiceAccountCreationCallback(process.Id, _fixture.Create()); @@ -764,7 +764,7 @@ private void SetupCreateOwnCompanyServiceAccount() A.CallTo(() => _companyRepository.GetBpnAndTechnicalUserRoleIds(A.That.Not.Matches(x => x == ValidCompanyId), ClientId)) .Returns<(string?, IEnumerable)>(default); - A.CallTo(() => _serviceAccountCreation.CreateServiceAccountAsync(A._, A.That.Matches(x => x == ValidCompanyId), A>._, TechnicalUserTypeId.OWN, A._, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), null)) + A.CallTo(() => _technicalUserCreation.CreateTechnicalUsersAsync(A._, A.That.Matches(x => x == ValidCompanyId), A>._, TechnicalUserTypeId.OWN, A._, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), null)) .Returns((false, null, [new CreatedServiceAccountData(Guid.NewGuid(), "test", "description", UserStatusId.ACTIVE, ClientId, new(ClientId, Guid.NewGuid().ToString(), new ClientAuthData(IamClientAuthMethod.SECRET)), Enumerable.Empty())])); A.CallTo(() => _portalRepositories.GetInstance()).Returns(_companyRepository); diff --git a/tests/administration/Administration.Service.Tests/Controllers/ServiceAccountControllerTests.cs b/tests/administration/Administration.Service.Tests/Controllers/ServiceAccountControllerTests.cs index f338c0c486..670a81e71c 100644 --- a/tests/administration/Administration.Service.Tests/Controllers/ServiceAccountControllerTests.cs +++ b/tests/administration/Administration.Service.Tests/Controllers/ServiceAccountControllerTests.cs @@ -34,7 +34,7 @@ public class ServiceAccountControllerTests { private readonly IIdentityData _identity; private readonly IFixture _fixture; - private readonly IServiceAccountBusinessLogic _logic; + private readonly ITechnicalUserBusinessLogic _logic; private readonly ServiceAccountController _controller; public ServiceAccountControllerTests() @@ -48,7 +48,7 @@ public ServiceAccountControllerTests() A.CallTo(() => _identity.IdentityId).Returns(Guid.NewGuid()); A.CallTo(() => _identity.IdentityTypeId).Returns(IdentityTypeId.COMPANY_USER); A.CallTo(() => _identity.CompanyId).Returns(Guid.NewGuid()); - _logic = A.Fake(); + _logic = A.Fake(); _controller = new ServiceAccountController(_logic); _controller.AddControllerContextWithClaim(_identity); } @@ -61,8 +61,8 @@ public async Task ExecuteCompanyUserCreation_CallsExpected() var responseData = _fixture.Build() .With(x => x.TechnicalUserId, serviceAccountId) .CreateMany(1); - var data = _fixture.Create(); - A.CallTo(() => _logic.CreateOwnCompanyServiceAccountAsync(A._)) + var data = _fixture.Create(); + A.CallTo(() => _logic.CreateOwnCompanyServiceAccountAsync(A._)) .Returns(responseData); // Act diff --git a/tests/endtoend/ServiceAccountCUDScenarios/AdministrationEndpointHelper.cs b/tests/endtoend/ServiceAccountCUDScenarios/AdministrationEndpointHelper.cs index 6a4ae16d9d..1cbcb7d977 100644 --- a/tests/endtoend/ServiceAccountCUDScenarios/AdministrationEndpointHelper.cs +++ b/tests/endtoend/ServiceAccountCUDScenarios/AdministrationEndpointHelper.cs @@ -103,7 +103,7 @@ public static async Task> CreateNewServiceAcc userRoleIds.AddRange(from t in allServiceAccountsRoles where t.UserRoleText.Contains(p) select t.UserRoleId); } - var serviceAccountCreationInfo = new ServiceAccountCreationInfo(techUserName, Description, IamClientAuthMethod.SECRET, userRoleIds); + var serviceAccountCreationInfo = new TechnicalUserCreationInfo(techUserName, Description, IamClientAuthMethod.SECRET, userRoleIds); var endpoint = $"{EndPoint}/serviceaccount/owncompany/serviceaccounts"; var response = Given() .DisableSslCertificateValidation() diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs index 6beb983321..5865df3c32 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs @@ -74,7 +74,7 @@ public class OfferSetupServiceTests private readonly IMailingProcessCreation _mailingProcessCreation; private readonly IPortalRepositories _portalRepositories; private readonly IProvisioningManager _provisioningManager; - private readonly IServiceAccountCreation _serviceAccountCreation; + private readonly ITechnicalUserCreation _technicalUserCreation; private readonly INotificationService _notificationService; private readonly OfferSetupService _sut; private readonly ITechnicalUserProfileService _technicalUserProfileService; @@ -97,7 +97,7 @@ public OfferSetupServiceTests() _userRolesRepository = A.Fake(); _provisioningManager = A.Fake(); _notificationRepository = A.Fake(); - _serviceAccountCreation = A.Fake(); + _technicalUserCreation = A.Fake(); _notificationService = A.Fake(); _technicalUserProfileService = A.Fake(); _offerSubscriptionProcessService = A.Fake(); @@ -117,7 +117,7 @@ public OfferSetupServiceTests() A.CallTo(() => _portalRepositories.GetInstance()).Returns(_offerRepository); A.CallTo(() => _portalRepositories.GetInstance()).Returns(_userRolesRepository); - _sut = new OfferSetupService(_portalRepositories, _provisioningManager, _serviceAccountCreation, _notificationService, _offerSubscriptionProcessService, _technicalUserProfileService, _identityService, _mailingProcessCreation, _dimService, A.Fake>()); + _sut = new OfferSetupService(_portalRepositories, _provisioningManager, _technicalUserCreation, _notificationService, _offerSubscriptionProcessService, _technicalUserProfileService, _identityService, _mailingProcessCreation, _dimService, A.Fake>()); } #region AutoSetupServiceAsync @@ -253,7 +253,7 @@ public async Task AutoSetup_WithValidData_ReturnsExpectedNotificationAndSecret(O } [Fact] - public async Task AutoSetup_WithMultipleTechnicalUsers_ThrowsException() + public async Task AutoSetup_WithMultipleTechnicalUsers_CreatesMultipleUsers() { // Arrange SetupAutoSetup(OfferTypeId.APP); @@ -264,8 +264,8 @@ public async Task AutoSetup_WithMultipleTechnicalUsers_ThrowsException() A.CallTo(() => _technicalUserProfileService.GetTechnicalUserProfilesForOfferSubscription(A._)) .Returns( [ - new(Guid.NewGuid().ToString(), "test", IamClientAuthMethod.SECRET, Enumerable.Empty()), - new(Guid.NewGuid().ToString(), "test1", IamClientAuthMethod.SECRET, Enumerable.Empty()) + new("sa1", "test", IamClientAuthMethod.SECRET, Enumerable.Empty()), + new("sa2", "test1", IamClientAuthMethod.SECRET, Enumerable.Empty()) ]); A.CallTo(() => _appInstanceRepository.CreateAppInstance(A._, A._)) @@ -283,11 +283,12 @@ public async Task AutoSetup_WithMultipleTechnicalUsers_ThrowsException() var data = new OfferAutoSetupData(_pendingSubscriptionId, "https://new-url.com/"); // Act - async Task Act() => await _sut.AutoSetupOfferAsync(data, companyAdminRoles, OfferTypeId.APP, "https://base-address.com", serviceManagerAdminRoles); + var result = await _sut.AutoSetupOfferAsync(data, companyAdminRoles, OfferTypeId.APP, "https://base-address.com", serviceManagerAdminRoles); // Assert - var ex = await Assert.ThrowsAsync(Act); - ex.Message.Should().Be($"There should only be one or none technical user profile configured for {data.RequestId}"); + result.TechnicalUserInfo.Should().HaveCount(2).And.Satisfy( + x => x.TechnicalClientId == "cl1", + x => x.TechnicalClientId == "cl2"); } [Theory] @@ -424,7 +425,7 @@ public async Task ActivateSingleInstanceAppAsync_WithValidData_ReturnsExpected() var appInstance = new AppInstance(appInstanceId, _validOfferId, default); SetupCreateSingleInstance(appInstance); A.CallTo(() => _technicalUserProfileService.GetTechnicalUserProfilesForOffer(_validOfferId, A._)) - .Returns(new ServiceAccountCreationInfo[] { new(Guid.NewGuid().ToString(), "test", IamClientAuthMethod.SECRET, Enumerable.Empty()) }.AsFakeIEnumerable(out var enumerator)); + .Returns(new TechnicalUserCreationInfo[] { new(Guid.NewGuid().ToString(), "test", IamClientAuthMethod.SECRET, Enumerable.Empty()) }.AsFakeIEnumerable(out var enumerator)); // Act var result = await _sut.ActivateSingleInstanceAppAsync(_validOfferId); @@ -1101,8 +1102,8 @@ public async Task CreateTechnicalUser_WithTechnicalUserNeeded_ReturnsExpected(st .Returns(userRoleData.ToAsyncEnumerable()); A.CallTo(() => _technicalUserProfileService.GetTechnicalUserProfilesForOfferSubscription(A._)) .Returns([new(Guid.NewGuid().ToString(), "test", IamClientAuthMethod.SECRET, roleIds)]); - A.CallTo(() => _serviceAccountCreation.CreateServiceAccountAsync(A._, A._, A>.That.IsSameSequenceAs(new[] { Bpn }), TechnicalUserTypeId.MANAGED, A._, A._, A._, A>._)) - .Invokes((ServiceAccountCreationInfo _, + A.CallTo(() => _technicalUserCreation.CreateTechnicalUsersAsync(A._, A._, A>.That.IsSameSequenceAs(new[] { Bpn }), TechnicalUserTypeId.MANAGED, A._, A._, A._, A>._)) + .Invokes((TechnicalUserCreationInfo _, Guid _, IEnumerable _, TechnicalUserTypeId _, @@ -1460,28 +1461,35 @@ private IAsyncEnumerator SetupServices(TechnicalUser? technicalUser = null A.CallTo(() => _provisioningManager.SetupClientAsync(A._, A._, A?>._, A._)) .Returns("cl1"); - A.CallTo(() => _serviceAccountCreation.CreateServiceAccountAsync(A._, A._, A>.That.Matches(x => x.Any(y => y == "CAXSDUMMYCATENAZZ")), TechnicalUserTypeId.MANAGED, A._, A._, A._, A?>._)) - .Invokes((ServiceAccountCreationInfo _, Guid _, IEnumerable _, TechnicalUserTypeId _, bool _, bool _, ServiceAccountCreationProcessData? _, Action? setOptionalParameter) => + var count = 1; + A.CallTo(() => _technicalUserCreation.CreateTechnicalUsersAsync(A._, A._, A>.That.Matches(x => x.Any(y => y == "CAXSDUMMYCATENAZZ")), TechnicalUserTypeId.MANAGED, A._, A._, A._, A?>._)) + .Invokes((TechnicalUserCreationInfo _, Guid _, IEnumerable _, TechnicalUserTypeId _, bool _, bool _, ServiceAccountCreationProcessData? _, Action? setOptionalParameter) => { if (technicalUser != null) { setOptionalParameter?.Invoke(technicalUser); } }) - .Returns(new ValueTuple>(false, null, [ - new CreatedServiceAccountData( - _technicalUserId, - "sa2", - "description", - UserStatusId.ACTIVE, - "cl1", - new ServiceAccountData(Guid.NewGuid().ToString(), "cl1", - new ClientAuthData(IamClientAuthMethod.SECRET) { Secret = "katze!1234" }), - new UserRoleData[] - { - new(Guid.NewGuid(), "client1", "role1"), new(Guid.NewGuid(), "client1", "role2"), - }) - ])); + .ReturnsLazily(() => + { + var result = new ValueTuple>(false, null, [ + new CreatedServiceAccountData( + _technicalUserId, + $"sa-{count + 1}", + "description", + UserStatusId.ACTIVE, + $"cl{count}", + new ServiceAccountData(Guid.NewGuid().ToString(), $"cl{count}", + new ClientAuthData(IamClientAuthMethod.SECRET) { Secret = "katze!1234" }), + new UserRoleData[] + { + new(Guid.NewGuid(), $"client{count}", "role1"), + new(Guid.NewGuid(), $"client{count}", "role2"), + }) + ]); + count++; + return result; + }); A.CallTo(() => _notificationService.CreateNotifications(A>._, A._, A>._, A._, A._)) @@ -1556,6 +1564,7 @@ private IAsyncEnumerator SetupAutoSetup(OfferTypeId offerTypeId, OfferSubs return createNotificationsEnumerator; } + private void SetupCreateSingleInstance(AppInstance? appInstance = null) { SetupServices(); diff --git a/tests/provisioning/Provisioning.Library.Tests/Extensions/ServiceAccountCreationTests.cs b/tests/provisioning/Provisioning.Library.Tests/Extensions/TechnicalUserCreationTests.cs similarity index 95% rename from tests/provisioning/Provisioning.Library.Tests/Extensions/ServiceAccountCreationTests.cs rename to tests/provisioning/Provisioning.Library.Tests/Extensions/TechnicalUserCreationTests.cs index 3d34870068..304b9f215c 100644 --- a/tests/provisioning/Provisioning.Library.Tests/Extensions/ServiceAccountCreationTests.cs +++ b/tests/provisioning/Provisioning.Library.Tests/Extensions/TechnicalUserCreationTests.cs @@ -34,7 +34,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Tests.Extensions; -public class ServiceAccountCreationTests +public class TechnicalUserCreationTests { private const string Bpn = "CAXSDUMMYCATENAZZ"; private readonly string _iamUserId = Guid.NewGuid().ToString(); @@ -57,9 +57,9 @@ public class ServiceAccountCreationTests private readonly IProvisioningManager _provisioningManager; private readonly IPortalRepositories _portalRepositories; private readonly IProvisioningDBAccess _provisioningDbAccess; - private readonly IServiceAccountCreation _sut; + private readonly ITechnicalUserCreation _sut; - public ServiceAccountCreationTests() + public TechnicalUserCreationTests() { var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization { ConfigureMembers = true }); fixture.Behaviors.OfType().ToList() @@ -90,7 +90,7 @@ public ServiceAccountCreationTests() A.CallTo(() => _portalRepositories.GetInstance()).Returns(_userRolesRepository); A.CallTo(() => _portalRepositories.GetInstance()).Returns(_processStepRepository); - _sut = new ServiceAccountCreation(_provisioningManager, _portalRepositories, _provisioningDbAccess, Options.Create(settings)); + _sut = new TechnicalUserCreation(_provisioningManager, _portalRepositories, _provisioningDbAccess, Options.Create(settings)); } private void ServiceAccountCreationAction(TechnicalUser _) { } @@ -99,11 +99,11 @@ private void ServiceAccountCreationAction(TechnicalUser _) { } public async Task CreateServiceAccountAsync_WithInvalidRole_ThrowsNotFoundException() { // Arrange - var creationData = new ServiceAccountCreationInfo("testName", "abc", IamClientAuthMethod.SECRET, [_invalidUserRoleId]); + var creationData = new TechnicalUserCreationInfo("testName", "abc", IamClientAuthMethod.SECRET, [_invalidUserRoleId]); Setup(); // Act - async Task Act() => await _sut.CreateServiceAccountAsync(creationData, _companyId, Enumerable.Empty(), TechnicalUserTypeId.OWN, false, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), ServiceAccountCreationAction); + async Task Act() => await _sut.CreateTechnicalUsersAsync(creationData, _companyId, Enumerable.Empty(), TechnicalUserTypeId.OWN, false, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), ServiceAccountCreationAction); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -132,7 +132,7 @@ public async Task CreateServiceAccountAsync_WithValidData_ReturnsExpected(bool e // Arrange var serviceAccounts = new List(); var identities = new List(); - var creationData = new ServiceAccountCreationInfo("testName", "abc", IamClientAuthMethod.SECRET, [_validUserRoleId]); + var creationData = new TechnicalUserCreationInfo("testName", "abc", IamClientAuthMethod.SECRET, [_validUserRoleId]); var bpns = new[] { Bpn @@ -140,11 +140,11 @@ public async Task CreateServiceAccountAsync_WithValidData_ReturnsExpected(bool e Setup(serviceAccounts, identities); // Act - var result = await _sut.CreateServiceAccountAsync(creationData, _companyId, bpns, TechnicalUserTypeId.OWN, enhance, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), ServiceAccountCreationAction); + var result = await _sut.CreateTechnicalUsersAsync(creationData, _companyId, bpns, TechnicalUserTypeId.OWN, enhance, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), ServiceAccountCreationAction); // Assert - result.ServiceAccounts.Should().ContainSingle() + result.TechnicalUsers.Should().ContainSingle() .Which.Should().Match(x => x.ClientId == "sa1" && x.Description == "abc" && @@ -210,7 +210,7 @@ public async Task CreateServiceAccountAsync_WithValidDimData_ReturnsExpected() // Arrange var serviceAccounts = new List(); var identities = new List(); - var creationData = new ServiceAccountCreationInfo("testName", "abc", IamClientAuthMethod.SECRET, [_dimUserRoleId]); + var creationData = new TechnicalUserCreationInfo("testName", "abc", IamClientAuthMethod.SECRET, [_dimUserRoleId]); var bpns = new[] { Bpn @@ -218,10 +218,10 @@ public async Task CreateServiceAccountAsync_WithValidDimData_ReturnsExpected() Setup(serviceAccounts, identities); // Act - var result = await _sut.CreateServiceAccountAsync(creationData, _companyId, bpns, TechnicalUserTypeId.OWN, false, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), ServiceAccountCreationAction); + var result = await _sut.CreateTechnicalUsersAsync(creationData, _companyId, bpns, TechnicalUserTypeId.OWN, false, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), ServiceAccountCreationAction); // Assert - result.ServiceAccounts.Should().ContainSingle() + result.TechnicalUsers.Should().ContainSingle() .Which.Should().Match(x => x.ClientId == null && x.Description == "abc" && @@ -278,7 +278,7 @@ public async Task CreateServiceAccountAsync_WithValidDataPlus_ReturnsExpected() // Arrange var serviceAccounts = new List(); var identities = new List(); - var creationData = new ServiceAccountCreationInfo("testName", "abc", IamClientAuthMethod.SECRET, [_validUserRoleId, _dimUserRoleId]); + var creationData = new TechnicalUserCreationInfo("testName", "abc", IamClientAuthMethod.SECRET, [_validUserRoleId, _dimUserRoleId]); var bpns = new[] { Bpn @@ -286,10 +286,10 @@ public async Task CreateServiceAccountAsync_WithValidDataPlus_ReturnsExpected() Setup(serviceAccounts, identities); // Act - var result = await _sut.CreateServiceAccountAsync(creationData, _companyId, bpns, TechnicalUserTypeId.OWN, false, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), ServiceAccountCreationAction); + var result = await _sut.CreateTechnicalUsersAsync(creationData, _companyId, bpns, TechnicalUserTypeId.OWN, false, true, new ServiceAccountCreationProcessData(ProcessTypeId.DIM_TECHNICAL_USER, null), ServiceAccountCreationAction); // Assert - result.ServiceAccounts.Should().HaveCount(2) + result.TechnicalUsers.Should().HaveCount(2) .And.Satisfy( x => x.ClientId == "sa1" && x.Description == "abc" &&