diff --git a/Framework.ProcessIdentity/DependencyInjection/ProcessIdentitySettings.cs b/Framework.ProcessIdentity/DependencyInjection/ProcessIdentitySettings.cs deleted file mode 100644 index cb46650d39..0000000000 --- a/Framework.ProcessIdentity/DependencyInjection/ProcessIdentitySettings.cs +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 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 - ********************************************************************************/ - -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using System.ComponentModel.DataAnnotations; - -namespace Org.Eclipse.TractusX.Portal.Backend.Framework.ProcessIdentity.DependencyInjection; - -public class ProcessIdentitySettings -{ - [Required(AllowEmptyStrings = false)] - public string UserEntityId { get; set; } = null!; - - [Required] - public Guid ProcessUserId { get; set; } = default; - - [Required] - public IdentityTypeId IdentityTypeId { get; set; } = default; - - [Required] - public Guid ProcessUserCompanyId { get; set; } = default; -} diff --git a/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs index 749c69c803..4e1d8ad0db 100644 --- a/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs @@ -34,7 +34,6 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using PortalBackend.PortalEntities.Identity; using System.Globalization; using System.Text.Json; diff --git a/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs index 337d021326..5cd9ee8183 100644 --- a/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs @@ -313,7 +313,7 @@ await _sdFactoryBusinessLogic public async Task DeleteConnectorAsync(Guid connectorId, Guid companyId, CancellationToken cancellationToken) { var connectorsRepository = _portalRepositories.GetInstance(); - var (isValidConnectorId, dapsClientId, selfDescriptionDocumentId, + var (isValidConnectorId, isProvidingOrHostCompany, dapsClientId, selfDescriptionDocumentId, documentStatus, connectorStatus, dapsRegistrationSuccess) = await connectorsRepository.GetConnectorDeleteDataAsync(connectorId, companyId).ConfigureAwait(false); if (!isValidConnectorId) @@ -321,6 +321,11 @@ public async Task DeleteConnectorAsync(Guid connectorId, Guid companyId, Cancell throw new NotFoundException($"Connector {connectorId} does not exist"); } + if (!isProvidingOrHostCompany) + { + throw new ForbiddenException($"company {companyId} is neither provider nor host-company of connector {connectorId}"); + } + switch ((dapsRegistrationSuccess ?? false, connectorStatus)) { case (true, ConnectorStatusId.ACTIVE) when selfDescriptionDocumentId == null: diff --git a/src/administration/Administration.Service/BusinessLogic/IInvitationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IInvitationBusinessLogic.cs index c4feb93a12..09cc651f22 100644 --- a/src/administration/Administration.Service/BusinessLogic/IInvitationBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/IInvitationBusinessLogic.cs @@ -24,6 +24,6 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLog { public interface IInvitationBusinessLogic { - Task ExecuteInvitation(CompanyInvitationData invitationData, Guid userId); + Task ExecuteInvitation(CompanyInvitationData invitationData); } } diff --git a/src/administration/Administration.Service/BusinessLogic/IRegistrationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IRegistrationBusinessLogic.cs index d10bd84358..4ba796f563 100644 --- a/src/administration/Administration.Service/BusinessLogic/IRegistrationBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/IRegistrationBusinessLogic.cs @@ -45,8 +45,7 @@ public interface IRegistrationBusinessLogic /// /// Id of the application /// Reason of decline - /// - Task DeclineRegistrationVerification(Guid applicationId, string comment, Guid userId); + Task DeclineRegistrationVerification(Guid applicationId, string comment); /// /// Processes the clearinghouse response diff --git a/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs index 2acb144442..692a41d4fe 100644 --- a/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/IServiceAccountBusinessLogic.cs @@ -28,7 +28,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLog public interface IServiceAccountBusinessLogic { Task CreateOwnCompanyServiceAccountAsync(ServiceAccountCreationInfo serviceAccountCreationInfos, Guid companyId); - Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId, (Guid UserId, Guid CompanyId) identity); + Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId, Guid companyId); Task GetOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId, Guid companyId); Task UpdateOwnCompanyServiceAccountDetailsAsync(Guid serviceAccountId, ServiceAccountEditableDetails serviceAccountDetails, Guid companyId); Task ExecuteResetOwnCompanyServiceAccountSecretAsync(Guid serviceAccountId, Guid companyId); diff --git a/src/administration/Administration.Service/BusinessLogic/ISubscriptionConfigurationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ISubscriptionConfigurationBusinessLogic.cs index 1162a48dab..c2ee708094 100644 --- a/src/administration/Administration.Service/BusinessLogic/ISubscriptionConfigurationBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/ISubscriptionConfigurationBusinessLogic.cs @@ -66,6 +66,6 @@ public interface ISubscriptionConfigurationBusinessLogic /// Sets service provider company details /// /// Detail data for the service provider - /// Id of the users and the users company - Task SetProviderCompanyDetailsAsync(ProviderDetailData data, (Guid UserId, Guid CompanyId) identity); + /// Id of the users company + Task SetProviderCompanyDetailsAsync(ProviderDetailData data, Guid companyId); } diff --git a/src/administration/Administration.Service/BusinessLogic/InvitationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/InvitationBusinessLogic.cs index 401d5d4720..af699f7a74 100644 --- a/src/administration/Administration.Service/BusinessLogic/InvitationBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/InvitationBusinessLogic.cs @@ -62,7 +62,7 @@ public InvitationBusinessLogic( _settings = settings.Value; } - public Task ExecuteInvitation(CompanyInvitationData invitationData, Guid userId) + public Task ExecuteInvitation(CompanyInvitationData invitationData) { if (string.IsNullOrWhiteSpace(invitationData.email)) { @@ -72,10 +72,10 @@ public Task ExecuteInvitation(CompanyInvitationData invitationData, Guid userId) { throw new ControllerArgumentException("organisationName must not be empty", "organisationName"); } - return ExecuteInvitationInternalAsync(invitationData, userId); + return ExecuteInvitationInternalAsync(invitationData); } - private async Task ExecuteInvitationInternalAsync(CompanyInvitationData invitationData, Guid userId) + private async Task ExecuteInvitationInternalAsync(CompanyInvitationData invitationData) { var idpName = await _provisioningManager.GetNextCentralIdentityProviderNameAsync().ConfigureAwait(false); await _provisioningManager.SetupSharedIdpAsync(idpName, invitationData.organisationName, _settings.InitialLoginTheme).ConfigureAwait(false); @@ -96,7 +96,6 @@ private async Task ExecuteInvitationInternalAsync(CompanyInvitationData invitati company.Id, company.Name, null, - userId, idpName, true ); @@ -120,7 +119,7 @@ private async Task ExecuteInvitationInternalAsync(CompanyInvitationData invitati "" )}.ToAsyncEnumerable(); - var (companyUserId, _, password, error) = await _userProvisioningService.CreateOwnCompanyIdpUsersAsync(companyNameIdpAliasData, userCreationInfoIdps, userId).SingleAsync().ConfigureAwait(false); + var (companyUserId, _, password, error) = await _userProvisioningService.CreateOwnCompanyIdpUsersAsync(companyNameIdpAliasData, userCreationInfoIdps).SingleAsync().ConfigureAwait(false); if (error != null) { diff --git a/src/administration/Administration.Service/BusinessLogic/RegistrationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/RegistrationBusinessLogic.cs index 2580e294a8..1713868413 100644 --- a/src/administration/Administration.Service/BusinessLogic/RegistrationBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/RegistrationBusinessLogic.cs @@ -403,7 +403,7 @@ public async Task ApproveRegistrationVerification(Guid applicationId) await _portalRepositories.SaveAsync().ConfigureAwait(false); } - public async Task DeclineRegistrationVerification(Guid applicationId, string comment, Guid userId) + public async Task DeclineRegistrationVerification(Guid applicationId, string comment) { var result = await _portalRepositories.GetInstance().GetCompanyIdNameForSubmittedApplication(applicationId).ConfigureAwait(false); if (result == default) diff --git a/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs index d62504dca5..eeeeb0467d 100644 --- a/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/ServiceAccountBusinessLogic.cs @@ -94,13 +94,13 @@ public async Task CreateOwnCompanyServiceAccountAsync(Ser serviceAccountData.AuthData.Secret); } - public async Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId, (Guid UserId, Guid CompanyId) identity) + public async Task DeleteOwnCompanyServiceAccountAsync(Guid serviceAccountId, Guid companyId) { var serviceAccountRepository = _portalRepositories.GetInstance(); - var result = await serviceAccountRepository.GetOwnCompanyServiceAccountWithIamServiceAccountRolesAsync(serviceAccountId, identity.CompanyId).ConfigureAwait(false); + var result = await serviceAccountRepository.GetOwnCompanyServiceAccountWithIamServiceAccountRolesAsync(serviceAccountId, companyId).ConfigureAwait(false); if (result == default) { - throw new ConflictException($"serviceAccount {serviceAccountId} not found for company {identity.CompanyId}"); + throw new ConflictException($"serviceAccount {serviceAccountId} not found for company {companyId}"); } if (result.statusId == ConnectorStatusId.ACTIVE || result.statusId == ConnectorStatusId.PENDING) { diff --git a/src/administration/Administration.Service/BusinessLogic/SubscriptionConfigurationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/SubscriptionConfigurationBusinessLogic.cs index 44a23f3671..049e25c8cd 100644 --- a/src/administration/Administration.Service/BusinessLogic/SubscriptionConfigurationBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/SubscriptionConfigurationBusinessLogic.cs @@ -59,7 +59,7 @@ public async Task GetProviderCompanyDetailsAsync(Guid } /// - public Task SetProviderCompanyDetailsAsync(ProviderDetailData data, (Guid UserId, Guid CompanyId) identity) + public Task SetProviderCompanyDetailsAsync(ProviderDetailData data, Guid companyId) { data.Url.EnsureValidHttpsUrl(() => nameof(data.Url)); data.CallbackUrl?.EnsureValidHttpsUrl(() => nameof(data.CallbackUrl)); @@ -70,29 +70,29 @@ public Task SetProviderCompanyDetailsAsync(ProviderDetailData data, (Guid UserId "the maximum allowed length is 100 characters", nameof(data.Url)); } - return SetOfferProviderCompanyDetailsInternalAsync(data, identity); + return SetOfferProviderCompanyDetailsInternalAsync(data, companyId); } - private async Task SetOfferProviderCompanyDetailsInternalAsync(ProviderDetailData data, (Guid UserId, Guid CompanyId) identity) + private async Task SetOfferProviderCompanyDetailsInternalAsync(ProviderDetailData data, Guid companyId) { var companyRepository = _portalRepositories.GetInstance(); var providerDetailData = await companyRepository - .GetProviderCompanyDetailsExistsForUser(identity.CompanyId) + .GetProviderCompanyDetailsExistsForUser(companyId) .ConfigureAwait(false); if (providerDetailData == default) { var result = await companyRepository - .IsValidCompanyRoleOwner(identity.CompanyId, new[] { CompanyRoleId.APP_PROVIDER, CompanyRoleId.SERVICE_PROVIDER }) + .IsValidCompanyRoleOwner(companyId, new[] { CompanyRoleId.APP_PROVIDER, CompanyRoleId.SERVICE_PROVIDER }) .ConfigureAwait(false); if (!result.IsValidCompanyId) { - throw new ConflictException($"Company {identity.CompanyId} not found"); + throw new ConflictException($"Company {companyId} not found"); } if (!result.IsCompanyRoleOwner) { - throw new ForbiddenException($"Company {identity.CompanyId} is not an app- or service-provider"); + throw new ForbiddenException($"Company {companyId} is not an app- or service-provider"); } - companyRepository.CreateProviderCompanyDetail(identity.CompanyId, data.Url, providerDetails => + companyRepository.CreateProviderCompanyDetail(companyId, data.Url, providerDetails => { if (data.CallbackUrl != null) { diff --git a/src/administration/Administration.Service/BusinessLogic/UserBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/UserBusinessLogic.cs index 881a5cd702..fb05c2bb6e 100644 --- a/src/administration/Administration.Service/BusinessLogic/UserBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/UserBusinessLogic.cs @@ -115,7 +115,7 @@ private async IAsyncEnumerable CreateOwnCompanyUsersInternalAsync(IEnume var companyDisplayName = await _userProvisioningService.GetIdentityProviderDisplayName(companyNameIdpAliasData.IdpAlias).ConfigureAwait(false); - await foreach (var (_, userName, password, error) in _userProvisioningService.CreateOwnCompanyIdpUsersAsync(companyNameIdpAliasData, userCreationInfoIdps, identity.UserId).ConfigureAwait(false)) + await foreach (var (_, userName, password, error) in _userProvisioningService.CreateOwnCompanyIdpUsersAsync(companyNameIdpAliasData, userCreationInfoIdps).ConfigureAwait(false)) { var email = emailData[userName]; @@ -177,8 +177,7 @@ public async Task CreateOwnCompanyIdpUserAsync(Guid identityProviderId, Us roleDatas, userCreationInfo.UserName, userCreationInfo.UserId - ), 1).ToAsyncEnumerable(), - identity.UserId) + ), 1).ToAsyncEnumerable()) .FirstAsync() .ConfigureAwait(false); diff --git a/src/administration/Administration.Service/BusinessLogic/UserUploadBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/UserUploadBusinessLogic.cs index fb4f422780..f882ae2df5 100644 --- a/src/administration/Administration.Service/BusinessLogic/UserUploadBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/UserUploadBusinessLogic.cs @@ -90,13 +90,11 @@ await GetUserRoleDatas(parsed.Roles, validRoleData, identity.CompanyId).Configur .CreateOwnCompanyIdpUsersAsync( companyNameIdpAliasData, lines, - identity.UserId, cancellationToken) : CreateOwnCompanyIdpUsersWithEmailAsync( nameCreatedBy, companyNameIdpAliasData, lines, - identity.UserId, cancellationToken)) .Select(x => (x.CompanyUserId != Guid.Empty, x.Error)), cancellationToken).ConfigureAwait(false); @@ -104,7 +102,7 @@ await GetUserRoleDatas(parsed.Roles, validRoleData, identity.CompanyId).Configur return new UserCreationStats(numCreated, errors.Count(), numLines, errors.Select(x => $"line: {x.Line}, message: {x.Error.Message}")); } - private async IAsyncEnumerable<(Guid CompanyUserId, string UserName, string? Password, Exception? Error)> CreateOwnCompanyIdpUsersWithEmailAsync(string nameCreatedBy, CompanyNameIdpAliasData companyNameIdpAliasData, IAsyncEnumerable userCreationInfos, Guid userId, [EnumeratorCancellation] CancellationToken cancellationToken) + private async IAsyncEnumerable<(Guid CompanyUserId, string UserName, string? Password, Exception? Error)> CreateOwnCompanyIdpUsersWithEmailAsync(string nameCreatedBy, CompanyNameIdpAliasData companyNameIdpAliasData, IAsyncEnumerable userCreationInfos, [EnumeratorCancellation] CancellationToken cancellationToken) { if (companyNameIdpAliasData.IsSharedIdp) { @@ -123,7 +121,6 @@ await GetUserRoleDatas(parsed.Roles, validRoleData, identity.CompanyId).Configur userCreationInfo = info; return info; }), - userId, cancellationToken) .WithCancellation(cancellationToken) .ConfigureAwait(false)) @@ -221,7 +218,6 @@ await GetUserRoleDatas(parsed.Roles, validRoleData, identity.CompanyId).Configur .CreateOwnCompanyIdpUsersAsync( companyNameIdpAliasData, lines, - identity.UserId, cancellationToken) .Select(x => (x.CompanyUserId != Guid.Empty, x.Error)), cancellationToken).ConfigureAwait(false); diff --git a/src/administration/Administration.Service/Controllers/InvitationController.cs b/src/administration/Administration.Service/Controllers/InvitationController.cs index a1edb4f16d..75d0cfdc36 100644 --- a/src/administration/Administration.Service/Controllers/InvitationController.cs +++ b/src/administration/Administration.Service/Controllers/InvitationController.cs @@ -70,5 +70,5 @@ public InvitationController(IInvitationBusinessLogic logic) [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status502BadGateway)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] public Task ExecuteInvitation([FromBody] CompanyInvitationData invitationData) => - this.WithUserId(userId => _logic.ExecuteInvitation(invitationData, userId)); + _logic.ExecuteInvitation(invitationData); } diff --git a/src/administration/Administration.Service/Controllers/RegistrationController.cs b/src/administration/Administration.Service/Controllers/RegistrationController.cs index f13d950cb0..614809088b 100644 --- a/src/administration/Administration.Service/Controllers/RegistrationController.cs +++ b/src/administration/Administration.Service/Controllers/RegistrationController.cs @@ -166,7 +166,7 @@ public async Task ApproveApplication([FromRoute] Guid applicati [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] public async Task DeclineApplication([FromRoute] Guid applicationId, [FromBody] RegistrationDeclineData data) { - await this.WithUserId(userId => _logic.DeclineRegistrationVerification(applicationId, data.Comment, userId)).ConfigureAwait(false); + await _logic.DeclineRegistrationVerification(applicationId, data.Comment).ConfigureAwait(false); return NoContent(); } diff --git a/src/administration/Administration.Service/Controllers/ServiceAccountController.cs b/src/administration/Administration.Service/Controllers/ServiceAccountController.cs index 3b8676ddaf..a5d7e8de19 100644 --- a/src/administration/Administration.Service/Controllers/ServiceAccountController.cs +++ b/src/administration/Administration.Service/Controllers/ServiceAccountController.cs @@ -86,7 +86,7 @@ public async Task ExecuteCompanyUserCreation([FromBody] Se [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] public Task DeleteServiceAccount([FromRoute] Guid serviceAccountId) => - this.WithUserIdAndCompanyId(identity => _logic.DeleteOwnCompanyServiceAccountAsync(serviceAccountId, identity)); + this.WithCompanyId(companyId => _logic.DeleteOwnCompanyServiceAccountAsync(serviceAccountId, companyId)); /// /// Gets the service account details for the given id diff --git a/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs b/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs index d923f7eaf4..ed5fc4b456 100644 --- a/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs +++ b/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs @@ -88,7 +88,7 @@ public Task GetServiceProviderCompanyDetail() => [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] public async Task SetProviderCompanyDetail([FromBody] ProviderDetailData data) { - await this.WithUserIdAndCompanyId(identity => _businessLogic.SetProviderCompanyDetailsAsync(data, identity)).ConfigureAwait(false); + await this.WithCompanyId(companyId => _businessLogic.SetProviderCompanyDetailsAsync(data, companyId)).ConfigureAwait(false); return NoContent(); } diff --git a/src/framework/Framework.ProcessIdentity/DependencyInjection/ProcessIdentityServiceCollectionExtensions.cs b/src/framework/Framework.ProcessIdentity/DependencyInjection/ProcessIdentityServiceCollectionExtensions.cs index 85d1e6c3c1..1e524aad0e 100644 --- a/src/framework/Framework.ProcessIdentity/DependencyInjection/ProcessIdentityServiceCollectionExtensions.cs +++ b/src/framework/Framework.ProcessIdentity/DependencyInjection/ProcessIdentityServiceCollectionExtensions.cs @@ -20,8 +20,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identity; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; namespace Org.Eclipse.TractusX.Portal.Backend.Framework.ProcessIdentity.DependencyInjection; diff --git a/src/framework/Framework.ProcessIdentity/DependencyInjection/ProcessIdentitySettings.cs b/src/framework/Framework.ProcessIdentity/DependencyInjection/ProcessIdentitySettings.cs index cb46650d39..44c3701e29 100644 --- a/src/framework/Framework.ProcessIdentity/DependencyInjection/ProcessIdentitySettings.cs +++ b/src/framework/Framework.ProcessIdentity/DependencyInjection/ProcessIdentitySettings.cs @@ -29,11 +29,11 @@ public class ProcessIdentitySettings public string UserEntityId { get; set; } = null!; [Required] - public Guid ProcessUserId { get; set; } = default; + public Guid ProcessUserId { get; set; } = Guid.Empty; [Required] public IdentityTypeId IdentityTypeId { get; set; } = default; [Required] - public Guid ProcessUserCompanyId { get; set; } = default; + public Guid ProcessUserCompanyId { get; set; } = Guid.Empty; } diff --git a/src/framework/Framework.ProcessIdentity/ProcessIdentityService.cs b/src/framework/Framework.ProcessIdentity/ProcessIdentityService.cs index 95f7574b4b..c88571f949 100644 --- a/src/framework/Framework.ProcessIdentity/ProcessIdentityService.cs +++ b/src/framework/Framework.ProcessIdentity/ProcessIdentityService.cs @@ -20,8 +20,7 @@ using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Framework.ProcessIdentity.DependencyInjection; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identity; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; namespace Org.Eclipse.TractusX.Portal.Backend.Framework.ProcessIdentity; diff --git a/src/framework/Framework.Web/IdentityService.cs b/src/framework/Framework.Web/IdentityService.cs index 8649b2f5d6..821a15f567 100644 --- a/src/framework/Framework.Web/IdentityService.cs +++ b/src/framework/Framework.Web/IdentityService.cs @@ -21,8 +21,7 @@ using Microsoft.AspNetCore.Http; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identity; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; namespace Org.Eclipse.TractusX.Portal.Backend.Framework.Web; diff --git a/src/framework/Framework.Web/StartupServiceExtensions.cs b/src/framework/Framework.Web/StartupServiceExtensions.cs index a2bde5fbed..3a72ac80d8 100644 --- a/src/framework/Framework.Web/StartupServiceExtensions.cs +++ b/src/framework/Framework.Web/StartupServiceExtensions.cs @@ -26,13 +26,11 @@ using Org.Eclipse.TractusX.Portal.Backend.Framework.Authorization; using Org.Eclipse.TractusX.Portal.Backend.Framework.Cors; using Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider.DependencyInjection; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Swagger; using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identity; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using System.IdentityModel.Tokens.Jwt; using System.Text.Json.Serialization; diff --git a/src/keycloak/Keycloak.Authentication/ControllerExtensions.cs b/src/keycloak/Keycloak.Authentication/ControllerExtensions.cs index 1d539afa8b..34294cf968 100644 --- a/src/keycloak/Keycloak.Authentication/ControllerExtensions.cs +++ b/src/keycloak/Keycloak.Authentication/ControllerExtensions.cs @@ -22,7 +22,7 @@ using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using System.Security.Claims; namespace Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication; diff --git a/src/maintenance/Maintenance.App/Program.cs b/src/maintenance/Maintenance.App/Program.cs index f6d4216d7c..ab98591959 100644 --- a/src/maintenance/Maintenance.App/Program.cs +++ b/src/maintenance/Maintenance.App/Program.cs @@ -24,7 +24,6 @@ using Org.Eclipse.TractusX.Portal.Backend.Framework.ProcessIdentity.DependencyInjection; using Org.Eclipse.TractusX.Portal.Backend.Maintenance.App; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; -using PortalBackend.PortalEntities.Identity; using Serilog; LoggingExtensions.EnsureInitialized(); diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppChangeBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppChangeBusinessLogic.cs index f576b2ac7f..3c492d56d9 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppChangeBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppChangeBusinessLogic.cs @@ -204,16 +204,16 @@ public Task DeactivateOfferByAppIdAsync(Guid appId, Guid companyId) => _offerService.DeactivateOfferIdAsync(appId, companyId, OfferTypeId.APP); /// - public Task UpdateTenantUrlAsync(Guid offerId, Guid subscriptionId, UpdateTenantData data, (Guid UserId, Guid CompanyId) identity) + public Task UpdateTenantUrlAsync(Guid offerId, Guid subscriptionId, UpdateTenantData data, Guid companyId) { data.Url.EnsureValidHttpUrl(() => nameof(data.Url)); - return UpdateTenantUrlAsyncInternal(offerId, subscriptionId, data.Url, identity); + return UpdateTenantUrlAsyncInternal(offerId, subscriptionId, data.Url, companyId); } - private async Task UpdateTenantUrlAsyncInternal(Guid offerId, Guid subscriptionId, string url, (Guid UserId, Guid CompanyId) identity) + private async Task UpdateTenantUrlAsyncInternal(Guid offerId, Guid subscriptionId, string url, Guid companyId) { var offerSubscriptionsRepository = _portalRepositories.GetInstance(); - var result = await offerSubscriptionsRepository.GetUpdateUrlDataAsync(offerId, subscriptionId, identity.CompanyId).ConfigureAwait(false); + var result = await offerSubscriptionsRepository.GetUpdateUrlDataAsync(offerId, subscriptionId, companyId).ConfigureAwait(false); if (result == null) { throw new NotFoundException($"Offer {offerId} or subscription {subscriptionId} do not exists"); @@ -227,7 +227,7 @@ private async Task UpdateTenantUrlAsyncInternal(Guid offerId, Guid subscriptionI if (!isUserOfCompany) { - throw new ForbiddenException($"Company {identity.CompanyId} is not the app's providing company"); + throw new ForbiddenException($"Company {companyId} is not the app's providing company"); } if (offerSubscriptionStatusId != OfferSubscriptionStatusId.ACTIVE) diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs index 58700e21c4..19066207ac 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs @@ -287,12 +287,12 @@ private async Task CreateAppAsync(AppRequestModel appRequestModel, Guid co } /// - public async Task UpdateAppReleaseAsync(Guid appId, AppRequestModel appRequestModel, (Guid UserId, Guid CompanyId) identity) + public async Task UpdateAppReleaseAsync(Guid appId, AppRequestModel appRequestModel, Guid companyId) { var appData = await _portalRepositories.GetInstance() .GetAppUpdateData( appId, - identity.CompanyId, + companyId, appRequestModel.SupportedLanguageCodes) .ConfigureAwait(false); if (appData is null) @@ -307,12 +307,12 @@ public async Task UpdateAppReleaseAsync(Guid appId, AppRequestModel appRequestMo if (!appData.IsUserOfProvider) { - throw new ForbiddenException($"Company {identity.CompanyId} is not the app provider."); + throw new ForbiddenException($"Company {companyId} is not the app provider."); } if (appRequestModel.SalesManagerId.HasValue) { - await _offerService.ValidateSalesManager(appRequestModel.SalesManagerId.Value, identity.CompanyId, _settings.SalesManagerRoles).ConfigureAwait(false); + await _offerService.ValidateSalesManager(appRequestModel.SalesManagerId.Value, companyId, _settings.SalesManagerRoles).ConfigureAwait(false); } var newSupportedLanguages = appRequestModel.SupportedLanguageCodes.Except(appData.Languages.Where(x => x.IsMatch).Select(x => x.Shortname)); diff --git a/src/marketplace/Apps.Service/BusinessLogic/IAppChangeBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/IAppChangeBusinessLogic.cs index b2a92658c9..9a3cf710db 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/IAppChangeBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/IAppChangeBusinessLogic.cs @@ -74,6 +74,6 @@ public interface IAppChangeBusinessLogic /// Id of the offer /// If of the subscription /// the data to update the url - /// - Task UpdateTenantUrlAsync(Guid offerId, Guid subscriptionId, UpdateTenantData data, (Guid UserId, Guid CompanyId) identity); + /// + Task UpdateTenantUrlAsync(Guid offerId, Guid subscriptionId, UpdateTenantData data, Guid companyId); } diff --git a/src/marketplace/Apps.Service/BusinessLogic/IAppReleaseBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/IAppReleaseBusinessLogic.cs index 07c9618b1c..1864efd453 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/IAppReleaseBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/IAppReleaseBusinessLogic.cs @@ -121,9 +121,9 @@ public interface IAppReleaseBusinessLogic /// /// /// - /// + /// /// Guid of the created app. - Task UpdateAppReleaseAsync(Guid appId, AppRequestModel appRequestModel, (Guid UserId, Guid CompanyId) identity); + Task UpdateAppReleaseAsync(Guid appId, AppRequestModel appRequestModel, Guid companyId); /// /// Retrieves all in review status apps in the marketplace. diff --git a/src/marketplace/Apps.Service/Controllers/AppChangeController.cs b/src/marketplace/Apps.Service/Controllers/AppChangeController.cs index 27e2bcbd14..cc72f0d7b6 100644 --- a/src/marketplace/Apps.Service/Controllers/AppChangeController.cs +++ b/src/marketplace/Apps.Service/Controllers/AppChangeController.cs @@ -183,7 +183,7 @@ public async Task DeactivateApp([FromRoute] Guid appId) [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] public async Task UpdateTenantUrl([FromRoute] Guid appId, [FromRoute] Guid subscriptionId, [FromBody] UpdateTenantData data) { - await this.WithUserIdAndCompanyId(identity => _businessLogic.UpdateTenantUrlAsync(appId, subscriptionId, data, identity)).ConfigureAwait(false); + await this.WithCompanyId(companyId => _businessLogic.UpdateTenantUrlAsync(appId, subscriptionId, data, companyId)).ConfigureAwait(false); return NoContent(); } } diff --git a/src/marketplace/Apps.Service/Controllers/AppReleaseProcessController.cs b/src/marketplace/Apps.Service/Controllers/AppReleaseProcessController.cs index c9ca586bd7..e17b5140de 100644 --- a/src/marketplace/Apps.Service/Controllers/AppReleaseProcessController.cs +++ b/src/marketplace/Apps.Service/Controllers/AppReleaseProcessController.cs @@ -285,7 +285,7 @@ public async Task ExecuteAppCreation([FromBody] AppRequest [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] public async Task UpdateAppRelease([FromRoute] Guid appId, [FromBody] AppRequestModel appRequestModel) { - await this.WithUserIdAndCompanyId(identity => _appReleaseBusinessLogic.UpdateAppReleaseAsync(appId, appRequestModel, identity).ConfigureAwait(false)); + await this.WithCompanyId(companyId => _appReleaseBusinessLogic.UpdateAppReleaseAsync(appId, appRequestModel, companyId).ConfigureAwait(false)); return NoContent(); } diff --git a/src/marketplace/Offers.Library/Service/IOfferService.cs b/src/marketplace/Offers.Library/Service/IOfferService.cs index 22f6a56f65..02ffc3fef2 100644 --- a/src/marketplace/Offers.Library/Service/IOfferService.cs +++ b/src/marketplace/Offers.Library/Service/IOfferService.cs @@ -18,13 +18,12 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Service; diff --git a/src/marketplace/Offers.Library/Service/OfferService.cs b/src/marketplace/Offers.Library/Service/OfferService.cs index b0feb0cb2c..320e031730 100644 --- a/src/marketplace/Offers.Library/Service/OfferService.cs +++ b/src/marketplace/Offers.Library/Service/OfferService.cs @@ -19,7 +19,6 @@ ********************************************************************************/ using Org.Eclipse.TractusX.Portal.Backend.Framework.Async; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; @@ -32,7 +31,7 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using System.Text.Json; namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Service; diff --git a/src/marketplace/Offers.Library/Service/OfferSubscriptionService.cs b/src/marketplace/Offers.Library/Service/OfferSubscriptionService.cs index 5264582067..7ecf9e37c3 100644 --- a/src/marketplace/Offers.Library/Service/OfferSubscriptionService.cs +++ b/src/marketplace/Offers.Library/Service/OfferSubscriptionService.cs @@ -58,7 +58,7 @@ public async Task AddOfferSubscriptionAsync(Guid offerId, IEnumerable(); var offerSubscription = offerTypeId == OfferTypeId.APP ? await HandleAppSubscriptionAsync(offerId, offerSubscriptionsRepository, companyInformation, identity.UserId).ConfigureAwait(false) - : offerSubscriptionsRepository.CreateOfferSubscription(offerId, companyInformation.CompanyId, OfferSubscriptionStatusId.PENDING, identity.UserId, identity.UserId); + : offerSubscriptionsRepository.CreateOfferSubscription(offerId, companyInformation.CompanyId, OfferSubscriptionStatusId.PENDING, identity.UserId); CreateProcessSteps(offerSubscription); CreateConsentsForSubscription(offerSubscription.Id, offerAgreementConsentData, companyInformation.CompanyId, identity.UserId); @@ -147,7 +147,7 @@ private static async Task HandleAppSubscriptionAsync( throw new ConflictException($"company {companyInformation.CompanyId} is already subscribed to {offerId}"); } - return offerSubscriptionsRepository.CreateOfferSubscription(offerId, companyInformation.CompanyId, OfferSubscriptionStatusId.PENDING, userId, userId); + return offerSubscriptionsRepository.CreateOfferSubscription(offerId, companyInformation.CompanyId, OfferSubscriptionStatusId.PENDING, userId); } private void CreateConsentsForSubscription(Guid offerSubscriptionId, IEnumerable offerAgreementConsentData, Guid companyId, Guid companyUserId) diff --git a/src/marketplace/Services.Service/BusinessLogic/IServiceReleaseBusinessLogic.cs b/src/marketplace/Services.Service/BusinessLogic/IServiceReleaseBusinessLogic.cs index ad0ea01898..60cb7bcdfb 100644 --- a/src/marketplace/Services.Service/BusinessLogic/IServiceReleaseBusinessLogic.cs +++ b/src/marketplace/Services.Service/BusinessLogic/IServiceReleaseBusinessLogic.cs @@ -98,8 +98,8 @@ public interface IServiceReleaseBusinessLogic /// /// Id of the service to update /// Data of the updated entry - /// Users identity - Task UpdateServiceAsync(Guid serviceId, ServiceUpdateRequestData data, (Guid UserId, Guid CompanyId) identity); + /// CompanyId of User + Task UpdateServiceAsync(Guid serviceId, ServiceUpdateRequestData data, Guid companyId); /// /// Update app status and create notification diff --git a/src/marketplace/Services.Service/BusinessLogic/ServiceReleaseBusinessLogic.cs b/src/marketplace/Services.Service/BusinessLogic/ServiceReleaseBusinessLogic.cs index 6a21dd5240..091ff0a0a7 100644 --- a/src/marketplace/Services.Service/BusinessLogic/ServiceReleaseBusinessLogic.cs +++ b/src/marketplace/Services.Service/BusinessLogic/ServiceReleaseBusinessLogic.cs @@ -163,11 +163,11 @@ public Task CreateServiceOfferingAsync(ServiceOfferingData data, (Guid Use _offerService.CreateServiceOfferingAsync(data, identity, OfferTypeId.SERVICE); /// - public async Task UpdateServiceAsync(Guid serviceId, ServiceUpdateRequestData data, (Guid UserId, Guid CompanyId) identity) + public async Task UpdateServiceAsync(Guid serviceId, ServiceUpdateRequestData data, Guid companyId) { var serviceData = await _portalRepositories .GetInstance() - .GetServiceUpdateData(serviceId, data.ServiceTypeIds, identity.CompanyId) + .GetServiceUpdateData(serviceId, data.ServiceTypeIds, companyId) .ConfigureAwait(false); if (serviceData is null) { @@ -181,12 +181,12 @@ public async Task UpdateServiceAsync(Guid serviceId, ServiceUpdateRequestData da if (!serviceData.IsUserOfProvider) { - throw new ForbiddenException($"Company {identity.CompanyId} is not the service provider."); + throw new ForbiddenException($"Company {companyId} is not the service provider."); } if (data.SalesManager.HasValue) { - await _offerService.ValidateSalesManager(data.SalesManager.Value, identity.CompanyId, _settings.SalesManagerRoles).ConfigureAwait(false); + await _offerService.ValidateSalesManager(data.SalesManager.Value, companyId, _settings.SalesManagerRoles).ConfigureAwait(false); } var offerRepository = _portalRepositories.GetInstance(); diff --git a/src/marketplace/Services.Service/Controllers/ServiceReleaseController.cs b/src/marketplace/Services.Service/Controllers/ServiceReleaseController.cs index 99509fefd8..917871e679 100644 --- a/src/marketplace/Services.Service/Controllers/ServiceReleaseController.cs +++ b/src/marketplace/Services.Service/Controllers/ServiceReleaseController.cs @@ -237,7 +237,7 @@ public async Task CreateServiceOffering([FromBody] Service [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] public async Task UpdateService([FromRoute] Guid serviceId, [FromBody] ServiceUpdateRequestData data) { - await this.WithUserIdAndCompanyId(identity => _serviceReleaseBusinessLogic.UpdateServiceAsync(serviceId, data, identity)); + await this.WithCompanyId(companyId => _serviceReleaseBusinessLogic.UpdateServiceAsync(serviceId, data, companyId)); return NoContent(); } diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs index 2fa9ff83dc..141eaf798b 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs @@ -137,11 +137,12 @@ public Connector AttachAndModifyConnector(Guid connectorId, Action? i .SingleOrDefaultAsync(); /// - public Task<(bool IsValidConnectorId, string? DapsClientId, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus, bool? DapsRegistrationSuccessful)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId) => + public Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, string? DapsClientId, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus, bool? DapsRegistrationSuccessful)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId) => _context.Connectors - .Where(x => x.Id == connectorId && (x.ProviderId == companyId || x.HostId == companyId)) - .Select(connector => new ValueTuple( + .Where(x => x.Id == connectorId) + .Select(connector => new ValueTuple( true, + connector.ProviderId == companyId || connector.HostId == companyId, connector.ClientDetails == null ? null : connector.ClientDetails!.ClientId, connector.SelfDescriptionDocumentId, connector.SelfDescriptionDocument!.DocumentStatusId, diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs index 4bb71c930c..43c38e20b1 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs @@ -87,7 +87,7 @@ public interface IConnectorsRepository /// Id of the connector /// Id of the company /// returns SelfDescriptionDocument Data/c> - Task<(bool IsValidConnectorId, string? DapsClientId, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus, bool? DapsRegistrationSuccessful)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId); + Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, string? DapsClientId, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus, bool? DapsRegistrationSuccessful)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId); /// /// Creates the connector details diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs index 05ef228a42..acfb09a867 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs @@ -38,7 +38,7 @@ public interface IOfferSubscriptionsRepository /// id of the app subscription status /// id of the user that requested the subscription of the app /// id of the creator - OfferSubscription CreateOfferSubscription(Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId, Guid creatorId); + OfferSubscription CreateOfferSubscription(Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId); /// /// Gets the provided offer subscription statuses for the user and given company diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/IUserRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/IUserRepository.cs index 937ee15928..855a3152b7 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/IUserRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/IUserRepository.cs @@ -18,12 +18,11 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; @@ -33,7 +32,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositorie public interface IUserRepository { IAsyncEnumerable GetApplicationsWithStatusUntrackedAsync(Guid companyId); - CompanyUser CreateCompanyUser(Guid identityId, string? firstName, string? lastName, string email, Guid lastEditorId); + CompanyUser CreateCompanyUser(Guid identityId, string? firstName, string? lastName, string email); Identity CreateIdentity(Guid companyId, UserStatusId userStatusId); void AttachAndModifyCompanyUser(Guid companyUserId, Action? initialize, Action setOptionalParameters); IQueryable GetOwnCompanyUserQuery(Guid companyId, Guid? companyUserId = null, string? userEntityId = null, string? firstName = null, string? lastName = null, string? email = null, IEnumerable? statusIds = null); diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs index a47e65b0e9..76b3d884ea 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs @@ -43,8 +43,8 @@ public OfferSubscriptionsRepository(PortalDbContext portalDbContext) } /// - public OfferSubscription CreateOfferSubscription(Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId, Guid creatorId) => - _context.OfferSubscriptions.Add(new OfferSubscription(Guid.NewGuid(), offerId, companyId, offerSubscriptionStatusId, requesterId, creatorId)).Entity; + public OfferSubscription CreateOfferSubscription(Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId) => + _context.OfferSubscriptions.Add(new OfferSubscription(Guid.NewGuid(), offerId, companyId, offerSubscriptionStatusId, requesterId)).Entity; /// public Func?>> GetOwnCompanyProvidedOfferSubscriptionStatusesUntrackedAsync(Guid userCompanyId, OfferTypeId offerTypeId, SubscriptionStatusSorting? sorting, IEnumerable statusIds, Guid? offerId) => @@ -169,7 +169,7 @@ public Task CheckPendingOrActiveSubscriptionExists(Guid offerId, Guid comp /// public OfferSubscription AttachAndModifyOfferSubscription(Guid offerSubscriptionId, Action setOptionalParameters) { - var offerSubscription = _context.Attach(new OfferSubscription(offerSubscriptionId, Guid.Empty, Guid.Empty, default, Guid.Empty, Guid.Empty)).Entity; + var offerSubscription = _context.Attach(new OfferSubscription(offerSubscriptionId, Guid.Empty, Guid.Empty, default, Guid.Empty)).Entity; setOptionalParameters.Invoke(offerSubscription); return offerSubscription; } diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/UserRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/UserRepository.cs index 7713c10c57..9fcb030f03 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/UserRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/UserRepository.cs @@ -25,7 +25,7 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; @@ -54,8 +54,8 @@ public IAsyncEnumerable GetApplicationsWithStatusU }) .AsAsyncEnumerable(); - public CompanyUser CreateCompanyUser(Guid identityId, string? firstName, string? lastName, string email, Guid lastEditorId) => - _dbContext.CompanyUsers.Add(new CompanyUser(identityId, lastEditorId) + public CompanyUser CreateCompanyUser(Guid identityId, string? firstName, string? lastName, string email) => + _dbContext.CompanyUsers.Add(new CompanyUser(identityId) { Firstname = firstName, Lastname = lastName, @@ -74,7 +74,7 @@ public Identity CreateIdentity(Guid companyId, UserStatusId userStatusId) => public void AttachAndModifyCompanyUser(Guid companyUserId, Action? initialize, Action setOptionalParameters) { - var companyUser = new CompanyUser(companyUserId, Guid.Empty); + var companyUser = new CompanyUser(companyUserId); initialize?.Invoke(companyUser); var updatedEntity = _dbContext.Attach(companyUser).Entity; setOptionalParameters.Invoke(updatedEntity); diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/20230718065537_AddLastEditorConstraints.Designer.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/20230718065537_AddLastEditorConstraints.Designer.cs index 4ac6226e5a..36fd1a1c0b 100644 --- a/src/portalbackend/PortalBackend.Migrations/Migrations/20230718065537_AddLastEditorConstraints.Designer.cs +++ b/src/portalbackend/PortalBackend.Migrations/Migrations/20230718065537_AddLastEditorConstraints.Designer.cs @@ -1,4 +1,4 @@ -/******************************************************************************** +/******************************************************************************** * Copyright (c) 2021, 2023 BMW Group AG * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation * @@ -19,12 +19,9 @@ ********************************************************************************/ // -using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; #nullable disable diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs index 7d30c2597e..b277c19b76 100644 --- a/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs +++ b/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs @@ -1,4 +1,4 @@ -/******************************************************************************** +/******************************************************************************** * Copyright (c) 2021, 2023 BMW Group AG * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation * @@ -19,11 +19,8 @@ ********************************************************************************/ // -using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; #nullable disable diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/AppSubscriptionDetail.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/AppSubscriptionDetail.cs index e7d0d58070..06f5b322d4 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/AppSubscriptionDetail.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/AppSubscriptionDetail.cs @@ -68,7 +68,9 @@ public AppSubscriptionDetail(Guid id, Guid offerSubscriptionId) public string? AppSubscriptionUrl { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } + + // navigational properties /// /// Subscribing app instance. @@ -79,5 +81,5 @@ public AppSubscriptionDetail(Guid id, Guid offerSubscriptionId) /// Subscription of an offer /// public virtual OfferSubscription? OfferSubscription { get; private set; } - public virtual Identity? LastEditor { get; set; } + public virtual Identity? LastEditor { get; private set; } } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyApplication.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyApplication.cs index 1bc0ee9c5a..5dc37c8055 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyApplication.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyApplication.cs @@ -53,7 +53,8 @@ public CompanyApplication(Guid id, Guid companyId, CompanyApplicationStatusId ap public Guid? ChecklistProcessId { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } + // Navigation properties public virtual CompanyApplicationStatus? ApplicationStatus { get; set; } public virtual Company? Company { get; set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyAssignedRole.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyAssignedRole.cs index 2e7b325061..fcae9baac2 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyAssignedRole.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyAssignedRole.cs @@ -39,9 +39,10 @@ public CompanyAssignedRole(Guid companyId, CompanyRoleId companyRoleId) public CompanyRoleId CompanyRoleId { get; private set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } // Navigation properties + public virtual Identity? LastEditor { get; private set; } public virtual Company? Company { get; private set; } public virtual CompanyRole? CompanyRole { get; private set; } } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanySsiDetail.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanySsiDetail.cs index 1ca99a25a9..98c393c9a5 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanySsiDetail.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanySsiDetail.cs @@ -52,9 +52,10 @@ public CompanySsiDetail(Guid id, Guid companyId, VerifiedCredentialTypeId verifi public Guid? VerifiedCredentialExternalTypeUseCaseDetailId { get; set; } public DateTimeOffset? DateLastChanged { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } // Navigation Properties + public virtual Identity? LastEditor { get; private set; } public virtual Company? Company { get; set; } public virtual VerifiedCredentialType? VerifiedCredentialType { get; set; } public virtual CompanySsiDetailStatus? CompanySsiDetailStatus { get; set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyUser.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyUser.cs index f9a67e235d..e07edc7a4f 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyUser.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyUser.cs @@ -28,10 +28,9 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entit [AuditEntityV1(typeof(AuditCompanyUser20230522))] public class CompanyUser : IBaseEntity, IAuditableV1 { - public CompanyUser(Guid id, Guid? lastEditorId) + public CompanyUser(Guid id) { Id = id; - LastEditorId = lastEditorId; Consents = new HashSet(); Documents = new HashSet(); @@ -62,7 +61,7 @@ public CompanyUser(Guid id, Guid? lastEditorId) public DateTimeOffset? DateLastChanged { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } public virtual Identity? Identity { get; set; } public virtual Identity? LastEditor { get; private set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyUserAssignedRole.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyUserAssignedRole.cs index a5d519df8f..1fbd4b0a8d 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyUserAssignedRole.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/CompanyUserAssignedRole.cs @@ -36,8 +36,10 @@ public IdentityAssignedRole(Guid identityId, Guid userRoleId) public Guid UserRoleId { get; private set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } + // Navigation properties + public virtual Identity? LastEditor { get; private set; } public virtual Identity? Identity { get; private set; } public virtual UserRole? UserRole { get; private set; } } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/Connector.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/Connector.cs index 03b2741b72..4d6a593ab6 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/Connector.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/Connector.cs @@ -71,7 +71,7 @@ public Connector(Guid id, string name, string locationId, string connectorUrl) public Guid? CompanyServiceAccountId { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } // Navigation properties public virtual ConnectorType? Type { get; set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/Consent.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/Consent.cs index 4899424751..4826141716 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/Consent.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/Consent.cs @@ -64,7 +64,7 @@ public Consent(Guid id, Guid agreementId, Guid companyId, Guid companyUserId, Co public Guid CompanyUserId { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } // Navigation properties public virtual Agreement? Agreement { get; private set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/Identity.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/Identity.cs index 7a0ef18b54..6f7f550620 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/Identity.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/Identity.cs @@ -37,7 +37,7 @@ public Identity(Guid id, DateTimeOffset dateCreated, Guid companyId, UserStatusI public DateTimeOffset? DateLastChanged { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } // Navigation properties public virtual CompanyUser? CompanyUser { get; set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/Offer.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/Offer.cs index 0a20a0da60..d2a47aa2df 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/Offer.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/Offer.cs @@ -93,7 +93,7 @@ public Offer(Guid id, string provider, DateTimeOffset dateCreated, OfferTypeId o public DateTimeOffset? DateLastChanged { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } // Navigation properties public virtual OfferType? OfferType { get; private set; } @@ -101,7 +101,7 @@ public Offer(Guid id, string provider, DateTimeOffset dateCreated, OfferTypeId o public virtual OfferStatus? OfferStatus { get; set; } public virtual LicenseType? LicenseType { get; set; } - public virtual Identity? LastEditor { get; set; } + public virtual Identity? LastEditor { get; private set; } public virtual AppInstanceSetup? AppInstanceSetup { get; set; } public virtual ICollection AgreementAssignedOffers { get; private set; } public virtual ICollection OfferDescriptions { get; private set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscription.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscription.cs index 390cdd93a7..d8b7443686 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscription.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscription.cs @@ -51,7 +51,7 @@ public OfferSubscription() /// app subscription status. /// Id of the requester /// Id of the editor - public OfferSubscription(Guid id, Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId, Guid lastEditorId) + public OfferSubscription(Guid id, Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId) : this() { Id = id; @@ -59,7 +59,6 @@ public OfferSubscription(Guid id, Guid offerId, Guid companyId, OfferSubscriptio CompanyId = companyId; OfferSubscriptionStatusId = offerSubscriptionStatusId; RequesterId = requesterId; - LastEditorId = lastEditorId; } /// @@ -98,7 +97,7 @@ public OfferSubscription(Guid id, Guid offerId, Guid companyId, OfferSubscriptio public Guid RequesterId { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } public Guid? ProcessId { get; set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/ProviderCompanyDetail.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/ProviderCompanyDetail.cs index c957e432f3..5598ec2708 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/ProviderCompanyDetail.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/ProviderCompanyDetail.cs @@ -54,7 +54,7 @@ public ProviderCompanyDetail(Guid id, Guid companyId, string autoSetupUrl, DateT public DateTimeOffset? DateLastChanged { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } // Navigation properties public virtual Company? Company { get; private set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/UserRole.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/UserRole.cs index e59813f790..7f2d6c8cb3 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/UserRole.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/UserRole.cs @@ -56,9 +56,10 @@ public UserRole(Guid id, string userRoleText, Guid offerId) : this() public Guid OfferId { get; set; } [AuditLastEditorV1] - public Guid? LastEditorId { get; set; } + public Guid? LastEditorId { get; private set; } // Navigation properties public virtual Offer? Offer { get; set; } + public virtual Identity? LastEditor { get; private set; } public virtual ICollection IdentityAssignedRoles { get; private set; } public virtual ICollection UserRoleCollections { get; private set; } public virtual ICollection UserRoleDescriptions { get; private set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Identity/IIdentityService.cs b/src/portalbackend/PortalBackend.PortalEntities/Identities/IIdentityService.cs similarity index 94% rename from src/portalbackend/PortalBackend.PortalEntities/Identity/IIdentityService.cs rename to src/portalbackend/PortalBackend.PortalEntities/Identities/IIdentityService.cs index 366d2e2121..e4b920d7cb 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Identity/IIdentityService.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Identities/IIdentityService.cs @@ -18,9 +18,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using PortalBackend.PortalEntities.Identity; - -namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identity; +namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; public interface IIdentityService { diff --git a/src/portalbackend/PortalBackend.PortalEntities/Identity/IdentityData.cs b/src/portalbackend/PortalBackend.PortalEntities/Identities/IdentityData.cs similarity index 92% rename from src/portalbackend/PortalBackend.PortalEntities/Identity/IdentityData.cs rename to src/portalbackend/PortalBackend.PortalEntities/Identities/IdentityData.cs index 3e4ec5329c..614faec123 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Identity/IdentityData.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Identities/IdentityData.cs @@ -20,6 +20,6 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -namespace PortalBackend.PortalEntities.Identity; +namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; public record IdentityData(string UserEntityId, Guid UserId, IdentityTypeId IdentityType, Guid CompanyId); diff --git a/src/portalbackend/PortalBackend.PortalEntities/PortalDbContext.cs b/src/portalbackend/PortalBackend.PortalEntities/PortalDbContext.cs index 091eb648ba..dc6f7ae4fb 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/PortalDbContext.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/PortalDbContext.cs @@ -23,9 +23,8 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Auditing; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Views; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; @@ -122,7 +121,7 @@ public PortalDbContext(DbContextOptions options, IIdentityServi public virtual DbSet DocumentStatus { get; set; } = default!; public virtual DbSet IamClients { get; set; } = default!; public virtual DbSet IamIdentityProviders { get; set; } = default!; - public virtual DbSet Identities { get; set; } = default!; + public virtual DbSet Identities { get; set; } = default!; public virtual DbSet IdentityAssignedRoles { get; set; } = default!; public virtual DbSet IdentityProviders { get; set; } = default!; public virtual DbSet IdentityProviderCategories { get; set; } = default!; @@ -686,7 +685,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .Select(e => new IdentityType(e)) ); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.HasIndex(e => e.UserEntityId) .IsUnique(); @@ -706,7 +705,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasForeignKey(e => e.IdentityTypeId) .OnDelete(DeleteBehavior.ClientSetNull); - entity.HasAuditV1Triggers(); + entity.HasAuditV1Triggers(); }); modelBuilder.Entity(entity => @@ -1373,18 +1372,16 @@ public override int SaveChanges() private void EnhanceChangedEntries() { - var changeSet = ChangeTracker.Entries() - .Where(c => c.State != EntityState.Unchanged); - foreach (var entry in changeSet.Where(x => x.Entity is IAuditableV1)) + foreach (var prop in ChangeTracker.Entries() + .Where(entry => entry.State != EntityState.Unchanged && entry.State != EntityState.Detached && entry.Entity is IAuditableV1) + .SelectMany(entry => + entry.Properties.IntersectBy( + entry.Entity.GetType().GetProperties() + .Where(x => Attribute.IsDefined(x, typeof(AuditLastEditorV1Attribute))) + .Select(x => x.Name), + property => property.Metadata.Name))) { - var names = entry.Entity.GetType() - .GetProperties().Where(x => Attribute.IsDefined(x, typeof(AuditLastEditorV1Attribute))) - .Select(x => x.Name); - var properties = entry.Properties.Where(x => names.Contains(x.Metadata.Name)); - foreach (var prop in properties) - { - prop.CurrentValue = _identityService.IdentityData.UserId; - } + prop.CurrentValue = _identityService.IdentityData.UserId; } } } diff --git a/src/provisioning/Provisioning.Library/Models/CompanyNameIdpAliasData.cs b/src/provisioning/Provisioning.Library/Models/CompanyNameIdpAliasData.cs index 6f7f8ab057..5849839980 100644 --- a/src/provisioning/Provisioning.Library/Models/CompanyNameIdpAliasData.cs +++ b/src/provisioning/Provisioning.Library/Models/CompanyNameIdpAliasData.cs @@ -1,3 +1,3 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; -public record CompanyNameIdpAliasData(Guid CompanyId, string CompanyName, string? BusinessPartnerNumber, Guid CompanyUserId, string IdpAlias, bool IsSharedIdp); +public record CompanyNameIdpAliasData(Guid CompanyId, string CompanyName, string? BusinessPartnerNumber, string IdpAlias, bool IsSharedIdp); diff --git a/src/provisioning/Provisioning.Library/Service/IUserProvisioningService.cs b/src/provisioning/Provisioning.Library/Service/IUserProvisioningService.cs index d9f18f5e5e..7920ec1c6f 100644 --- a/src/provisioning/Provisioning.Library/Service/IUserProvisioningService.cs +++ b/src/provisioning/Provisioning.Library/Service/IUserProvisioningService.cs @@ -26,7 +26,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Service; public interface IUserProvisioningService { - IAsyncEnumerable<(Guid CompanyUserId, string UserName, string? Password, Exception? Error)> CreateOwnCompanyIdpUsersAsync(CompanyNameIdpAliasData companyNameIdpAliasData, IAsyncEnumerable userCreationInfos, Guid userId, CancellationToken cancellationToken = default); + IAsyncEnumerable<(Guid CompanyUserId, string UserName, string? Password, Exception? Error)> CreateOwnCompanyIdpUsersAsync(CompanyNameIdpAliasData companyNameIdpAliasData, IAsyncEnumerable userCreationInfos, CancellationToken cancellationToken = default); Task<(CompanyNameIdpAliasData IdpAliasData, string NameCreatedBy)> GetCompanyNameIdpAliasData(Guid identityProviderId, Guid companyUserId); Task<(CompanyNameIdpAliasData IdpAliasData, string NameCreatedBy)> GetCompanyNameSharedIdpAliasData(Guid companyUserId, Guid? applicationId = null); Task GetIdentityProviderDisplayName(string idpAlias); diff --git a/src/provisioning/Provisioning.Library/Service/UserProvisioningService.cs b/src/provisioning/Provisioning.Library/Service/UserProvisioningService.cs index 773d24d4b4..612c1792a2 100644 --- a/src/provisioning/Provisioning.Library/Service/UserProvisioningService.cs +++ b/src/provisioning/Provisioning.Library/Service/UserProvisioningService.cs @@ -53,13 +53,12 @@ public UserProvisioningService(IProvisioningManager provisioningManager, IPortal public async IAsyncEnumerable<(Guid CompanyUserId, string UserName, string? Password, Exception? Error)> CreateOwnCompanyIdpUsersAsync( CompanyNameIdpAliasData companyNameIdpAliasData, IAsyncEnumerable userCreationInfos, - Guid userId, [EnumeratorCancellation] CancellationToken cancellationToken = default) { var userRepository = _portalRepositories.GetInstance(); var userRolesRepository = _portalRepositories.GetInstance(); - var (companyId, companyName, businessPartnerNumber, creatorId, alias, isSharedIdp) = companyNameIdpAliasData; + var (companyId, companyName, businessPartnerNumber, alias, isSharedIdp) = companyNameIdpAliasData; var passwordProvider = new OptionalPasswordProvider(isSharedIdp); @@ -72,7 +71,7 @@ public UserProvisioningService(IProvisioningManager provisioningManager, IPortal try { - var (identity, companyUserId) = await GetOrCreateCompanyUser(userRepository, alias, user, companyId, creatorId, businessPartnerNumber); + var (identity, companyUserId) = await GetOrCreateCompanyUser(userRepository, alias, user, companyId, businessPartnerNumber); cancellationToken.ThrowIfCancellationRequested(); @@ -128,7 +127,6 @@ public UserProvisioningService(IProvisioningManager provisioningManager, IPortal string alias, UserCreationRoleDataIdpInfo user, Guid companyId, - Guid creatorId, string? businessPartnerNumber) { var businessPartnerRepository = _portalRepositories.GetInstance(); @@ -141,7 +139,7 @@ public UserProvisioningService(IProvisioningManager provisioningManager, IPortal } identity = userRepository.CreateIdentity(companyId, UserStatusId.ACTIVE); - companyUserId = userRepository.CreateCompanyUser(identity.Id, user.FirstName, user.LastName, user.Email, creatorId).Id; + companyUserId = userRepository.CreateCompanyUser(identity.Id, user.FirstName, user.LastName, user.Email).Id; if (businessPartnerNumber != null) { businessPartnerRepository.CreateCompanyUserAssignedBusinessPartner(companyUserId, businessPartnerNumber); @@ -194,7 +192,7 @@ private Task CreateSharedIdpUserOrReturnUserId(UserCreationRoleDataIdpIn var createdByName = CreateNameString(companyUser.FirstName, companyUser.LastName, companyUser.Email, companyUser.CompanyUserId); - return (new CompanyNameIdpAliasData(company.CompanyId, company.CompanyName, company.BusinessPartnerNumber, companyUser.CompanyUserId, identityProvider.IdpAlias, identityProvider.IsSharedIdp), createdByName); + return (new CompanyNameIdpAliasData(company.CompanyId, company.CompanyName, company.BusinessPartnerNumber, identityProvider.IdpAlias, identityProvider.IsSharedIdp), createdByName); } public async Task<(CompanyNameIdpAliasData IdpAliasData, string NameCreatedBy)> GetCompanyNameSharedIdpAliasData(Guid companyUserId, Guid? applicationId = null) @@ -222,7 +220,7 @@ private Task CreateSharedIdpUserOrReturnUserId(UserCreationRoleDataIdpIn var createdByName = CreateNameString(companyUser.FirstName, companyUser.LastName, companyUser.Email, companyUser.CompanyUserId); - return (new CompanyNameIdpAliasData(company.CompanyId, company.CompanyName, company.BusinessPartnerNumber, companyUser.CompanyUserId, idpAliase.First(), true), createdByName); + return (new CompanyNameIdpAliasData(company.CompanyId, company.CompanyName, company.BusinessPartnerNumber, idpAliase.First(), true), createdByName); } private static string CreateNameString(string? firstName, string? lastName, string? email, Guid companyUserId) diff --git a/src/registration/Registration.Service/BusinessLogic/RegistrationBusinessLogic.cs b/src/registration/Registration.Service/BusinessLogic/RegistrationBusinessLogic.cs index e9ccf01367..cf29275daa 100644 --- a/src/registration/Registration.Service/BusinessLogic/RegistrationBusinessLogic.cs +++ b/src/registration/Registration.Service/BusinessLogic/RegistrationBusinessLogic.cs @@ -473,7 +473,7 @@ private async Task InviteNewUserInternalAsync(Guid applicationId, UserCreat "" )}.ToAsyncEnumerable(); - var (newCompanyUserId, _, password, error) = await _userProvisioningService.CreateOwnCompanyIdpUsersAsync(companyNameIdpAliasData, userCreationInfoIdps, identity.UserId).SingleAsync().ConfigureAwait(false); + var (newCompanyUserId, _, password, error) = await _userProvisioningService.CreateOwnCompanyIdpUsersAsync(companyNameIdpAliasData, userCreationInfoIdps).SingleAsync().ConfigureAwait(false); if (error != null) { diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/CompanyDataBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/CompanyDataBusinessLogicTests.cs index 57f5a93390..ef94f2180d 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/CompanyDataBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/CompanyDataBusinessLogicTests.cs @@ -31,8 +31,8 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.BusinessLogic; diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs index 1ff619e415..a67c47afa0 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs @@ -24,7 +24,6 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; using Org.Eclipse.TractusX.Portal.Backend.Daps.Library; using Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; @@ -32,10 +31,10 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.BusinessLogic; @@ -580,7 +579,7 @@ public async Task DeleteConnectorAsync_WithDocumentId_ExpectedCalls() var connector = new Connector(connectorId, null!, null!, null!); var selfDescriptionDocumentId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(A._, _identity.CompanyId)) - .Returns((true, "123", selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.ACTIVE, true)); + .Returns((true, true, "123", selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.ACTIVE, true)); A.CallTo(() => _documentRepository.AttachAndModifyDocument(A._, A>._, A>._)) .Invokes((Guid DocId, Action? initialize, Action modify) @@ -617,7 +616,7 @@ public async Task DeleteConnectorAsync_WithOutDocumentId_ExpectedCalls() var connectorId = Guid.NewGuid(); var connector = new Connector(connectorId, null!, null!, null!); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, "12345", null, null, ConnectorStatusId.ACTIVE, true)); + .Returns((true, true, "12345", null, null, ConnectorStatusId.ACTIVE, true)); A.CallTo(() => _connectorsRepository.AttachAndModifyConnector(A._, A>._, A>._)) .Invokes((Guid _, Action? initialize, Action setOptionalFields) => { @@ -641,7 +640,7 @@ public async Task DeleteConnectorAsync_WithInactiveConnector_ThrowsConflictExcep // Arrange var connectorId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, null, null, null, ConnectorStatusId.ACTIVE, false)); + .Returns((true, true, null, null, null, ConnectorStatusId.ACTIVE, false)); // Act async Task Act() => await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); @@ -657,7 +656,7 @@ public async Task DeleteConnectorAsync_WithEmptyDapsClientId_ThrowsUnexpectedCon // Arrange var connectorId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, null, null, null, ConnectorStatusId.ACTIVE, true)); + .Returns((true, true, null, null, null, ConnectorStatusId.ACTIVE, true)); // Act async Task Act() => await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); @@ -673,7 +672,7 @@ public async Task DeleteConnectorAsync_ThrowsNotFoundException() // Arrange var connectorId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns(((bool, string?, Guid?, DocumentStatusId?, ConnectorStatusId, bool))default); + .Returns(((bool, bool, string?, Guid?, DocumentStatusId?, ConnectorStatusId, bool))default); // Act async Task Act() => await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); @@ -683,6 +682,22 @@ public async Task DeleteConnectorAsync_ThrowsNotFoundException() ex.Message.Should().Be($"Connector {connectorId} does not exist"); } + [Fact] + public async Task DeleteConnectorAsync_ThrowsForbiddenException() + { + // Arrange + var connectorId = Guid.NewGuid(); + A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) + .Returns((true, false, null, null, null, default, true)); + + // Act + async Task Act() => await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + + // Assert + var ex = await Assert.ThrowsAsync(Act); + ex.Message.Should().Be($"company {_identity.CompanyId} is neither provider nor host-company of connector {connectorId}"); + } + #endregion #region GetManagedConnectorForIamUserAsync diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/DocumentsBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/DocumentsBusinessLogicTests.cs index 4ea760d574..1078806779 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/DocumentsBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/DocumentsBusinessLogicTests.cs @@ -20,13 +20,12 @@ using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.BusinessLogic; diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/IdentityProviderBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/IdentityProviderBusinessLogicTests.cs index 0a7f58fffb..61868a475c 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/IdentityProviderBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/IdentityProviderBusinessLogicTests.cs @@ -20,17 +20,15 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.IO; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; -using PortalBackend.PortalEntities.Identity; using System.Text; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic.Tests; @@ -185,7 +183,6 @@ public async Task TestUploadOwnCompanyUsersIdentityProviderLinkDataAsyncEmailCha SetupFakes(users, lines); var changedEmailResult = (string?)null; - var lastEditorId = (Guid?)null; A.CallTo(() => _userRepository.AttachAndModifyCompanyUser(A._, null, A>._)) .Invokes(x => @@ -193,10 +190,9 @@ public async Task TestUploadOwnCompanyUsersIdentityProviderLinkDataAsyncEmailCha var companyUserId = x.Arguments.Get("companyUserId")!; var setOptionalParameters = x.Arguments.Get>("setOptionalParameters"); - var companyUser = new CompanyUser(companyUserId, Guid.Empty); + var companyUser = new CompanyUser(companyUserId); setOptionalParameters?.Invoke(companyUser); changedEmailResult = companyUser.Email; - lastEditorId = companyUser.LastEditorId; } ); diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/InvitationBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/InvitationBusinessLogicTests.cs index b233866fe1..81346e3e6b 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/InvitationBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/InvitationBusinessLogicTests.cs @@ -20,12 +20,10 @@ using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; using Org.Eclipse.TractusX.Portal.Backend.Mailing.SendMail; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; @@ -33,7 +31,6 @@ using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Service; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic.Tests; @@ -52,7 +49,6 @@ public class InvitationBusinessLogicTests private readonly string _companyName; private readonly string _idpName; private readonly Guid _companyId; - private readonly IdentityData _identity; private readonly Guid _identityProviderId; private readonly Guid _applicationId; private readonly Func _processLine; @@ -80,7 +76,6 @@ public InvitationBusinessLogicTests() _companyId = _fixture.Create(); _identityProviderId = _fixture.Create(); _applicationId = _fixture.Create(); - _identity = new(Guid.NewGuid().ToString(), Guid.NewGuid(), IdentityTypeId.COMPANY_USER, Guid.NewGuid()); _processLine = A.Fake>(); @@ -108,7 +103,7 @@ public async Task TestExecuteInvitationSuccess() _mailingService, _options); - await sut.ExecuteInvitation(invitationData, _identity.UserId).ConfigureAwait(false); + await sut.ExecuteInvitation(invitationData).ConfigureAwait(false); A.CallTo(() => _provisioningManager.GetNextCentralIdentityProviderNameAsync()).MustHaveHappened(); A.CallTo(() => _provisioningManager.SetupSharedIdpAsync(A.That.IsEqualTo(_idpName), A.That.IsEqualTo(invitationData.organisationName), A._)).MustHaveHappened(); @@ -121,7 +116,6 @@ public async Task TestExecuteInvitationSuccess() A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync( A.That.Matches(d => d.CompanyId == _companyId), A>._, - A._, A._)).MustHaveHappened(); A.CallTo(() => _processLine(A.That.Matches(u => u.FirstName == invitationData.firstName))).MustHaveHappened(); @@ -151,7 +145,7 @@ public async Task TestExecuteInvitationNoEmailThrows() _mailingService, _options); - Task Act() => sut.ExecuteInvitation(invitationData, _identity.UserId); + Task Act() => sut.ExecuteInvitation(invitationData); var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); error.Message.Should().Be("email must not be empty (Parameter 'email')"); @@ -180,7 +174,7 @@ public async Task TestExecuteInvitationNoOrganisationNameThrows() _mailingService, _options); - Task Act() => sut.ExecuteInvitation(invitationData, _identity.UserId); + Task Act() => sut.ExecuteInvitation(invitationData); var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); error.Message.Should().Be("organisationName must not be empty (Parameter 'organisationName')"); @@ -215,7 +209,7 @@ public async Task TestExecuteInvitationCreateUserErrorThrows() _mailingService, _options); - Task Act() => sut.ExecuteInvitation(invitationData, _identity.UserId); + Task Act() => sut.ExecuteInvitation(invitationData); var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); error.Message.Should().Be(_error.Message); @@ -246,7 +240,7 @@ public async Task TestExecuteInvitationCreateUserThrowsThrows() _mailingService, _options); - Task Act() => sut.ExecuteInvitation(invitationData, _identity.UserId); + Task Act() => sut.ExecuteInvitation(invitationData); var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); error.Message.Should().Be(_error.Message); @@ -285,8 +279,8 @@ private void SetupFakes() A.CallTo(() => _provisioningManager.GetNextCentralIdentityProviderNameAsync()).Returns(_idpName); - A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._, A._)) - .ReturnsLazily((CompanyNameIdpAliasData _, IAsyncEnumerable userCreationInfos, Guid _, CancellationToken _) => + A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._)) + .ReturnsLazily((CompanyNameIdpAliasData _, IAsyncEnumerable userCreationInfos, CancellationToken _) => userCreationInfos.Select(userCreationInfo => _processLine(userCreationInfo))); A.CallTo(() => _processLine(A._)).ReturnsLazily( diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs index e84e543963..e56810b584 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs @@ -455,7 +455,7 @@ public async Task DeclineRegistrationVerification_WithDecline_StateAndCommentSet SetupForDeclineRegistrationVerification(entry, application, company, checklistStatusId); // Act - await _logic.DeclineRegistrationVerification(IdWithBpn, comment, Guid.NewGuid()).ConfigureAwait(false); + await _logic.DeclineRegistrationVerification(IdWithBpn, comment).ConfigureAwait(false); // Assert A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs index 2c7ecf9568..e547342dd2 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/ServiceAccountBusinessLogicTests.cs @@ -21,7 +21,6 @@ using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; @@ -29,11 +28,11 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Enums; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Service; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.BusinessLogic; @@ -423,7 +422,7 @@ public async Task DeleteOwnCompanyServiceAccountAsync_WithNotExistingServiceAcco var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!); // Act - async Task Act() => await sut.DeleteOwnCompanyServiceAccountAsync(serviceAccountId, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await sut.DeleteOwnCompanyServiceAccountAsync(serviceAccountId, _identity.CompanyId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -439,7 +438,7 @@ public async Task DeleteOwnCompanyServiceAccountAsync_WithInvalidConnectorStatus var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!); // Act - async Task Act() => await sut.DeleteOwnCompanyServiceAccountAsync(ValidServiceAccountId, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await sut.DeleteOwnCompanyServiceAccountAsync(ValidServiceAccountId, _identity.CompanyId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -465,7 +464,7 @@ public async Task DeleteOwnCompanyServiceAccountAsync_WithoutClient_CallsExpecte var sut = new ServiceAccountBusinessLogic(_provisioningManager, _portalRepositories, _options, null!); // Act - await sut.DeleteOwnCompanyServiceAccountAsync(ValidServiceAccountId, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + await sut.DeleteOwnCompanyServiceAccountAsync(ValidServiceAccountId, _identity.CompanyId).ConfigureAwait(false); // Assert if (withClient) diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/SubscriptionConfigurationBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/SubscriptionConfigurationBusinessLogicTests.cs index 15433e675e..d8002a55a0 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/SubscriptionConfigurationBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/SubscriptionConfigurationBusinessLogicTests.cs @@ -19,16 +19,15 @@ ********************************************************************************/ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Processes.Library; using Org.Eclipse.TractusX.Portal.Backend.Processes.OfferSubscription.Library; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.BusinessLogic; @@ -190,7 +189,7 @@ public async Task SetProviderCompanyDetailsAsync_EmptyProviderDetailsId_ReturnsE .Returns((Guid.Empty, null!)); // Act - await _sut.SetProviderCompanyDetailsAsync(providerDetailData, (_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + await _sut.SetProviderCompanyDetailsAsync(providerDetailData, _identity.CompanyId).ConfigureAwait(false); // Assert A.CallTo(() => _companyRepository.CreateProviderCompanyDetail(A._, A._, A>._)).MustHaveHappened(); @@ -225,7 +224,7 @@ public async Task SetProviderCompanyDetailsAsync_WithServiceProviderDetailsId_Re }); //Act - await _sut.SetProviderCompanyDetailsAsync(providerDetailData, (_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + await _sut.SetProviderCompanyDetailsAsync(providerDetailData, _identity.CompanyId).ConfigureAwait(false); //Assert A.CallTo(() => _companyRepository.CreateProviderCompanyDetail(A._, A._, null)).MustNotHaveHappened(); @@ -245,7 +244,7 @@ public async Task SetServiceProviderCompanyDetailsAsync_WithUnknownUser_ThrowsEx var providerDetailData = new ProviderDetailData("https://www.service-url.com", null); //Act - async Task Action() => await _sut.SetProviderCompanyDetailsAsync(providerDetailData, (Guid.NewGuid(), Guid.NewGuid())).ConfigureAwait(false); + async Task Action() => await _sut.SetProviderCompanyDetailsAsync(providerDetailData, Guid.NewGuid()).ConfigureAwait(false); //Assert await Assert.ThrowsAsync(Action); @@ -261,7 +260,7 @@ public async Task SetServiceProviderCompanyDetailsAsync_WithNotServiceProvider_T var providerDetailData = new ProviderDetailData("https://www.service-url.com", null); //Act - async Task Action() => await _sut.SetProviderCompanyDetailsAsync(providerDetailData, (_noServiceProviderIdentity.UserId, _noServiceProviderIdentity.CompanyId)).ConfigureAwait(false); + async Task Action() => await _sut.SetProviderCompanyDetailsAsync(providerDetailData, _noServiceProviderIdentity.CompanyId).ConfigureAwait(false); //Assert var ex = await Assert.ThrowsAsync(Action); @@ -283,7 +282,7 @@ public async Task SetServiceProviderCompanyDetailsAsync_WithInvalidUrl_ThrowsExc var providerDetailData = new ProviderDetailData(url!, null); //Act - async Task Action() => await _sut.SetProviderCompanyDetailsAsync(providerDetailData, (_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Action() => await _sut.SetProviderCompanyDetailsAsync(providerDetailData, _identity.CompanyId).ConfigureAwait(false); //Assert var ex = await Assert.ThrowsAsync(Action); diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/UserBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/UserBusinessLogicTests.cs index 5502d618aa..41703ae599 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/UserBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/UserBusinessLogicTests.cs @@ -21,7 +21,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; @@ -31,12 +30,12 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Service; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic.Tests; @@ -1345,8 +1344,8 @@ private void SetupFakesForUserCreation(bool isBulkUserCreation) A.CallTo(() => _userProvisioningService.GetCompanyNameIdpAliasData(A._, A._)).Returns((_fixture.Create(), _fixture.Create())); } - A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._, A._)) - .ReturnsLazily((CompanyNameIdpAliasData _, IAsyncEnumerable userCreationInfos, Guid _, CancellationToken _) => + A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._)) + .ReturnsLazily((CompanyNameIdpAliasData _, IAsyncEnumerable userCreationInfos, CancellationToken _) => userCreationInfos.Select(userCreationInfo => _processLine(userCreationInfo))); A.CallTo(() => _userProvisioningService.GetIdentityProviderDisplayName(A._)).Returns(_displayName); diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/UserUploadBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/UserUploadBusinessLogicTests.cs index 0b6e5fd441..468e09b539 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/UserUploadBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/UserUploadBusinessLogicTests.cs @@ -20,15 +20,14 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.IO; using Org.Eclipse.TractusX.Portal.Backend.Mailing.SendMail; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Service; -using PortalBackend.PortalEntities.Identity; using System.Text; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic.Tests; @@ -509,8 +508,8 @@ private void SetupFakes(IEnumerable lines) .ReturnsLazily((string clientId, IEnumerable roles, Guid _) => roles.Select(role => _fixture.Build().With(x => x.ClientClientId, clientId).With(x => x.UserRoleText, role).Create())); - A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._, A._)) - .ReturnsLazily((CompanyNameIdpAliasData _, IAsyncEnumerable userCreationInfos, Guid _, CancellationToken _) => + A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._)) + .ReturnsLazily((CompanyNameIdpAliasData _, IAsyncEnumerable userCreationInfos, CancellationToken _) => userCreationInfos.Select(userCreationInfo => _processLine(userCreationInfo))); A.CallTo(() => _processLine(A._)).ReturnsLazily( diff --git a/tests/administration/Administration.Service.Tests/Controllers/CompanyDataControllerTests.cs b/tests/administration/Administration.Service.Tests/Controllers/CompanyDataControllerTests.cs index 040e7e5537..7981e9214f 100644 --- a/tests/administration/Administration.Service.Tests/Controllers/CompanyDataControllerTests.cs +++ b/tests/administration/Administration.Service.Tests/Controllers/CompanyDataControllerTests.cs @@ -21,14 +21,13 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Extensions; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using System.Net; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.Controllers; diff --git a/tests/administration/Administration.Service.Tests/Controllers/ConnectorsControllerTests.cs b/tests/administration/Administration.Service.Tests/Controllers/ConnectorsControllerTests.cs index c32fa3d9fd..345f812a5b 100644 --- a/tests/administration/Administration.Service.Tests/Controllers/ConnectorsControllerTests.cs +++ b/tests/administration/Administration.Service.Tests/Controllers/ConnectorsControllerTests.cs @@ -22,14 +22,13 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.Controllers; diff --git a/tests/administration/Administration.Service.Tests/Controllers/DocumentsControllerTests.cs b/tests/administration/Administration.Service.Tests/Controllers/DocumentsControllerTests.cs index acb331f927..41fc8540fa 100644 --- a/tests/administration/Administration.Service.Tests/Controllers/DocumentsControllerTests.cs +++ b/tests/administration/Administration.Service.Tests/Controllers/DocumentsControllerTests.cs @@ -20,11 +20,10 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using System.Text; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.Controllers; diff --git a/tests/administration/Administration.Service.Tests/Controllers/RegistrationControllerTest.cs b/tests/administration/Administration.Service.Tests/Controllers/RegistrationControllerTest.cs index e4ee2e2450..8fc502fff4 100644 --- a/tests/administration/Administration.Service.Tests/Controllers/RegistrationControllerTest.cs +++ b/tests/administration/Administration.Service.Tests/Controllers/RegistrationControllerTest.cs @@ -23,13 +23,11 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; using Org.Eclipse.TractusX.Portal.Backend.Clearinghouse.Library.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using System.Text; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.Controllers; @@ -110,7 +108,7 @@ public async Task DeclineApplication_ReturnsExpectedResult() var result = await this._controller.DeclineApplication(applicationId, new RegistrationDeclineData("test")).ConfigureAwait(false); //Assert - A.CallTo(() => _logic.DeclineRegistrationVerification(applicationId, "test", _identity.UserId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.DeclineRegistrationVerification(applicationId, "test")).MustHaveHappenedOnceExactly(); Assert.IsType(result); } diff --git a/tests/administration/Administration.Service.Tests/Controllers/ServiceAccountControllerTests.cs b/tests/administration/Administration.Service.Tests/Controllers/ServiceAccountControllerTests.cs index 6bba9ba2eb..7575a1d485 100644 --- a/tests/administration/Administration.Service.Tests/Controllers/ServiceAccountControllerTests.cs +++ b/tests/administration/Administration.Service.Tests/Controllers/ServiceAccountControllerTests.cs @@ -22,12 +22,11 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.Controllers; diff --git a/tests/administration/Administration.Service.Tests/Controllers/SubscriptionConfigurationControllerTests.cs b/tests/administration/Administration.Service.Tests/Controllers/SubscriptionConfigurationControllerTests.cs index 62fc023a91..5a0a7008f6 100644 --- a/tests/administration/Administration.Service.Tests/Controllers/SubscriptionConfigurationControllerTests.cs +++ b/tests/administration/Administration.Service.Tests/Controllers/SubscriptionConfigurationControllerTests.cs @@ -23,8 +23,8 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.Controllers; @@ -114,7 +114,7 @@ public async Task SetCompanyDetail_WithValidData_ReturnsNoContent() var result = await this._controller.SetProviderCompanyDetail(data).ConfigureAwait(false); //Assert - A.CallTo(() => _logic.SetProviderCompanyDetailsAsync(data, new(_identity.UserId, _identity.CompanyId))).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.SetProviderCompanyDetailsAsync(data, _identity.CompanyId)).MustHaveHappenedOnceExactly(); Assert.IsType(result); } diff --git a/tests/administration/Administration.Service.Tests/Controllers/UserControllerTest.cs b/tests/administration/Administration.Service.Tests/Controllers/UserControllerTest.cs index 44a296eb30..c35e7bda60 100644 --- a/tests/administration/Administration.Service.Tests/Controllers/UserControllerTest.cs +++ b/tests/administration/Administration.Service.Tests/Controllers/UserControllerTest.cs @@ -22,11 +22,10 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.Controllers; diff --git a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs index 8a931323cb..20957d0567 100644 --- a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs +++ b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs @@ -23,7 +23,6 @@ using FakeItEasy; using FluentAssertions; using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; @@ -35,8 +34,8 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; using Xunit; diff --git a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppChangeBusinessLogicTest.cs b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppChangeBusinessLogicTest.cs index 2ce5d15585..77fdd705ba 100644 --- a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppChangeBusinessLogicTest.cs +++ b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppChangeBusinessLogicTest.cs @@ -24,7 +24,6 @@ using FluentAssertions; using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; using Org.Eclipse.TractusX.Portal.Backend.Notifications.Library; @@ -35,10 +34,10 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; using Xunit; @@ -656,7 +655,7 @@ public async Task UpdateTenantUrlAsync_WithValidData_CallsExpected() setOptionalParameters(existingOffer); }); // Act - await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert A.CallTo(() => _provisioningManager.UpdateClient(clientClientId, data.Url, A._)).MustHaveHappenedOnceExactly(); @@ -710,7 +709,7 @@ public async Task UpdateTenantUrlAsync_WithoutRequesterButValidData_CallsExpecte setOptionalParameters(existingOffer); }); // Act - await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert A.CallTo(() => _provisioningManager.UpdateClient(clientClientId, data.Url, A._)).MustHaveHappenedOnceExactly(); @@ -761,7 +760,7 @@ public async Task UpdateTenantUrlAsync_WithoutClientId_CallsExpected() setOptionalParameters(existingOffer); }); // Act - await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert A.CallTo(() => _provisioningManager.UpdateClient(clientClientId, data.Url, A._)).MustNotHaveHappened(); @@ -785,7 +784,7 @@ public async Task UpdateTenantUrlAsync_WithSameUrl_CallsNothing() A.CallTo(() => _offerSubscriptionsRepository.GetUpdateUrlDataAsync(appId, subscriptionId, _identity.CompanyId)) .Returns(new OfferUpdateUrlData("testApp", false, true, Guid.Empty, subscribingCompany, OfferSubscriptionStatusId.ACTIVE, new OfferUpdateUrlSubscriptionDetailData(detailId, clientClientId, oldUrl))); // Act - await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert A.CallTo(() => _provisioningManager.UpdateClient(clientClientId, oldUrl, A._)).MustNotHaveHappened(); @@ -804,7 +803,7 @@ public async Task UpdateTenantUrlAsync_WithInvalidUrl_ThrowsControllerArgumentEx var subscriptionId = _fixture.Create(); // Act - async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -828,7 +827,7 @@ public async Task UpdateTenantUrlAsync_WithoutApp_ThrowsNotFoundException() .Returns((OfferUpdateUrlData?)null); // Act - async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -854,7 +853,7 @@ public async Task UpdateTenantUrlAsync_WithSingleInstanceApp_ThrowsConflictExcep .Returns(new OfferUpdateUrlData("testApp", true, true, Guid.Empty, subscribingCompany, OfferSubscriptionStatusId.ACTIVE, new OfferUpdateUrlSubscriptionDetailData(detailId, clientClientId, oldUrl))); // Act - async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -880,7 +879,7 @@ public async Task UpdateTenantUrlAsync_WithUserNotFromProvidingCompany_ThrowsFor .Returns(new OfferUpdateUrlData("testApp", false, false, Guid.Empty, subscribingCompany, OfferSubscriptionStatusId.ACTIVE, new OfferUpdateUrlSubscriptionDetailData(detailId, clientClientId, oldUrl))); // Act - async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -906,7 +905,7 @@ public async Task UpdateTenantUrlAsync_WithInActiveApp_ThrowsConflictException() .Returns(new OfferUpdateUrlData("testApp", false, true, Guid.Empty, subscribingCompany, OfferSubscriptionStatusId.PENDING, new OfferUpdateUrlSubscriptionDetailData(detailId, clientClientId, oldUrl))); // Act - async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -930,7 +929,7 @@ public async Task UpdateTenantUrlAsync_WithoutSubscriptionDetails_ThrowsConflict .Returns(new OfferUpdateUrlData("testApp", false, true, Guid.Empty, subscribingCompany, OfferSubscriptionStatusId.ACTIVE, null)); // Act - async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); diff --git a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppReleaseBusinessLogicTest.cs b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppReleaseBusinessLogicTest.cs index 096506eeb2..ed5de71fea 100644 --- a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppReleaseBusinessLogicTest.cs +++ b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppReleaseBusinessLogicTest.cs @@ -24,7 +24,6 @@ using FluentAssertions; using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; @@ -36,8 +35,8 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; using Xunit; @@ -368,7 +367,7 @@ public async Task UpdateAppReleaseAsync_WithoutApp_ThrowsException() var data = _fixture.Create(); // Act - async Task Act() => await _sut.UpdateAppReleaseAsync(_notExistingAppId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateAppReleaseAsync(_notExistingAppId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); @@ -383,7 +382,7 @@ public async Task UpdateAppReleaseAsync_WithActiveApp_ThrowsException() var data = _fixture.Create(); // Act - async Task Act() => await _sut.UpdateAppReleaseAsync(_activeAppId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateAppReleaseAsync(_activeAppId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); @@ -398,7 +397,7 @@ public async Task UpdateAppReleaseAsync_WithInvalidUser_ThrowsException() var data = _fixture.Create(); // Act - async Task Act() => await _sut.UpdateAppReleaseAsync(_differentCompanyAppId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateAppReleaseAsync(_differentCompanyAppId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); @@ -415,7 +414,7 @@ public async Task UpdateAppReleaseAsync_WithInvalidLanguage_ThrowsException() .Create(); // Act - async Task Act() => await _sut.UpdateAppReleaseAsync(_existingAppId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await _sut.UpdateAppReleaseAsync(_existingAppId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); @@ -443,7 +442,7 @@ public async Task UpdateAppReleaseAsync_WithValidData_ReturnsExpected() }); // Act - await _sut.UpdateAppReleaseAsync(_existingAppId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + await _sut.UpdateAppReleaseAsync(_existingAppId, data, _identity.CompanyId).ConfigureAwait(false); // Assert A.CallTo(() => _offerRepository.AttachAndModifyOffer(A._, A>._, A>._)) diff --git a/tests/marketplace/Apps.Service.Tests/Controllers/AppChangeControllerTest.cs b/tests/marketplace/Apps.Service.Tests/Controllers/AppChangeControllerTest.cs index db66b5c94f..4ac2a93396 100644 --- a/tests/marketplace/Apps.Service.Tests/Controllers/AppChangeControllerTest.cs +++ b/tests/marketplace/Apps.Service.Tests/Controllers/AppChangeControllerTest.cs @@ -25,12 +25,11 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using Xunit; namespace Org.Eclipse.TractusX.Portal.Backend.Apps.Service.Controllers.Tests; @@ -145,7 +144,7 @@ public async Task UpdateTenantUrl_ReturnsExpected() var result = await this._controller.UpdateTenantUrl(appId, subscriptionId, data).ConfigureAwait(false); //Assert - A.CallTo(() => _logic.UpdateTenantUrlAsync(appId, subscriptionId, data, new ValueTuple(_identity.UserId, _identity.CompanyId))).MustHaveHappened(); + A.CallTo(() => _logic.UpdateTenantUrlAsync(appId, subscriptionId, data, _identity.CompanyId)).MustHaveHappened(); result.Should().BeOfType(); } } diff --git a/tests/marketplace/Apps.Service.Tests/Controllers/AppReleaseProcessControllerTest.cs b/tests/marketplace/Apps.Service.Tests/Controllers/AppReleaseProcessControllerTest.cs index 5c14929338..98c48fbcea 100644 --- a/tests/marketplace/Apps.Service.Tests/Controllers/AppReleaseProcessControllerTest.cs +++ b/tests/marketplace/Apps.Service.Tests/Controllers/AppReleaseProcessControllerTest.cs @@ -25,14 +25,13 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using Xunit; namespace Org.Eclipse.TractusX.Portal.Backend.Apps.Service.Controllers.Tests; @@ -270,7 +269,7 @@ public async Task UpdateAppRelease_ReturnsNoContent() "test@gmail.com", "9456321678" ); - A.CallTo(() => _logic.UpdateAppReleaseAsync(A._, A._, new ValueTuple(_identity.UserId, _identity.CompanyId))) + A.CallTo(() => _logic.UpdateAppReleaseAsync(A._, A._, _identity.CompanyId)) .ReturnsLazily(() => Task.CompletedTask); // Act @@ -278,7 +277,7 @@ public async Task UpdateAppRelease_ReturnsNoContent() // Assert Assert.IsType(result); - A.CallTo(() => _logic.UpdateAppReleaseAsync(appId, data, A>.That.Matches(x => x.Item1 == _identity.UserId && x.Item2 == _identity.CompanyId))).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.UpdateAppReleaseAsync(appId, data, _identity.CompanyId)).MustHaveHappenedOnceExactly(); } [Fact] diff --git a/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs b/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs index 0d327266ad..9a9df579f0 100644 --- a/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs +++ b/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs @@ -25,14 +25,13 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; using Xunit; diff --git a/tests/marketplace/Offer.Library.Web.Tests/OfferDocumentServiceTests.cs b/tests/marketplace/Offer.Library.Web.Tests/OfferDocumentServiceTests.cs index 65630dbced..71ed7deae2 100644 --- a/tests/marketplace/Offer.Library.Web.Tests/OfferDocumentServiceTests.cs +++ b/tests/marketplace/Offer.Library.Web.Tests/OfferDocumentServiceTests.cs @@ -18,17 +18,15 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; -using PortalBackend.PortalEntities.Identity; namespace Offer.Library.Web.Tests; diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs index bfd1540ab4..7cabaa7749 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs @@ -18,7 +18,6 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; @@ -29,8 +28,8 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Tests.Service; diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs index f371997913..ff8f061c5c 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferSetupServiceTests.cs @@ -18,7 +18,6 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; using Org.Eclipse.TractusX.Portal.Backend.Mailing.SendMail; @@ -28,6 +27,7 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Processes.Library; using Org.Eclipse.TractusX.Portal.Backend.Processes.OfferSubscription.Library; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library; @@ -35,7 +35,6 @@ using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Service; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Tests.Service; @@ -119,7 +118,7 @@ public OfferSetupServiceTests() public async Task AutoSetup_WithValidData_ReturnsExpectedNotificationAndSecret(OfferTypeId offerTypeId, bool technicalUserRequired, bool isSingleInstance) { // Arrange - var offerSubscription = new OfferSubscription(Guid.NewGuid(), Guid.Empty, Guid.Empty, OfferSubscriptionStatusId.PENDING, Guid.Empty, Guid.Empty); + var offerSubscription = new OfferSubscription(Guid.NewGuid(), Guid.Empty, Guid.Empty, OfferSubscriptionStatusId.PENDING, Guid.Empty); var companyServiceAccount = new CompanyServiceAccount(Guid.NewGuid(), "test", "test", CompanyServiceAccountTypeId.OWN); var createNotificationsEnumerator = SetupAutoSetup(offerTypeId, offerSubscription, isSingleInstance, companyServiceAccount); var clientId = Guid.NewGuid(); @@ -243,7 +242,7 @@ public async Task AutoSetup_WithValidData_ReturnsExpectedNotificationAndSecret(O public async Task AutoSetup_WithMultipleTechnicalUsers_ThrowsException() { // Arrange - var offerSubscription = new OfferSubscription(Guid.NewGuid(), Guid.Empty, Guid.Empty, OfferSubscriptionStatusId.PENDING, Guid.Empty, Guid.Empty); + var offerSubscription = new OfferSubscription(Guid.NewGuid(), Guid.Empty, Guid.Empty, OfferSubscriptionStatusId.PENDING, Guid.Empty); var companyServiceAccount = new CompanyServiceAccount(Guid.NewGuid(), "test", "test", CompanyServiceAccountTypeId.OWN); SetupAutoSetup(OfferTypeId.APP, offerSubscription, false, companyServiceAccount); var clientId = Guid.NewGuid(); @@ -1081,7 +1080,7 @@ public async Task ActivateSubscription_WithNotExistingOfferSubscription_ThrowsNo public async Task ActivateSubscription_WithValidData_ReturnsExpected(string? requesterEmail, bool isSingleInstance, OfferTypeId offerTypeId) { // Arrange - var offerSubscription = new OfferSubscription(Guid.NewGuid(), _validOfferId, CompanyUserCompanyId, OfferSubscriptionStatusId.PENDING, _identity.UserId, _identity.UserId); + var offerSubscription = new OfferSubscription(Guid.NewGuid(), _validOfferId, CompanyUserCompanyId, OfferSubscriptionStatusId.PENDING, _identity.UserId); var subscriptionProcessData = new List { new(offerSubscription.Id, "https://www.test.de") diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferSubscriptionServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferSubscriptionServiceTests.cs index 3e3beda795..54cd7ca068 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferSubscriptionServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferSubscriptionServiceTests.cs @@ -18,7 +18,6 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; @@ -28,7 +27,7 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using System.Collections.Immutable; namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Tests.Service; @@ -123,10 +122,10 @@ public async Task AddOfferSubscription_WithExistingId_CreatesServiceSubscription A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(A._, A._, A._)) .Returns(false); var companyAssignedApps = new List(); - A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._, A._)) - .Invokes((Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId, Guid creatorId) => + A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._)) + .Invokes((Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId) => { - var companyAssignedApp = new OfferSubscription(_newOfferSubscriptionId, offerId, companyId, offerSubscriptionStatusId, requesterId, creatorId); + var companyAssignedApp = new OfferSubscription(_newOfferSubscriptionId, offerId, companyId, offerSubscriptionStatusId, requesterId); companyAssignedApps.Add(companyAssignedApp); }); @@ -152,10 +151,10 @@ public async Task AddOfferSubscription_WithSalesManagerEqualsReceiver_CreatesSer A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(A._, A._, A._)) .Returns(false); var companyAssignedApps = new List(); - A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._, A._)) - .Invokes((Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId, Guid creatorId) => + A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._)) + .Invokes((Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId) => { - var companyAssignedApp = new OfferSubscription(_newOfferSubscriptionId, offerId, companyId, offerSubscriptionStatusId, requesterId, creatorId); + var companyAssignedApp = new OfferSubscription(_newOfferSubscriptionId, offerId, companyId, offerSubscriptionStatusId, requesterId); companyAssignedApps.Add(companyAssignedApp); }); @@ -176,10 +175,10 @@ public async Task AddOfferSubscription_WithExistingIdWithoutProviderEmail_Create A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(A._, A._, A._)) .Returns(false); var companyAssignedApps = new List(); - A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._, A._)) - .Invokes((Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId, Guid creatorId) => + A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._)) + .Invokes((Guid offerId, Guid companyId, OfferSubscriptionStatusId offerSubscriptionStatusId, Guid requesterId) => { - var companyAssignedApp = new OfferSubscription(_newOfferSubscriptionId, offerId, companyId, offerSubscriptionStatusId, requesterId, creatorId); + var companyAssignedApp = new OfferSubscription(_newOfferSubscriptionId, offerId, companyId, offerSubscriptionStatusId, requesterId); companyAssignedApps.Add(companyAssignedApp); }); @@ -205,7 +204,7 @@ public async Task AddOfferSubscription_WithExistingAppSubscriptionAndProcessStep // Assert A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(_existingOfferId, _companyId, OfferTypeId.APP)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._, A._)).MustHaveHappened(); + A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._)).MustHaveHappened(); A.CallTo(() => _offerSubscriptionsRepository.AttachAndModifyOfferSubscription(subscriptionId, A>._)).MustNotHaveHappened(); A.CallTo(() => _processStepRepository.CreateProcess(A._)).MustHaveHappened(); A.CallTo(() => _processStepRepository.CreateProcessStepRange(A>._)).MustHaveHappened(); @@ -226,7 +225,7 @@ public async Task AddOfferSubscription_WithExistingActiveAppSubscription_Throws( // Assert A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(_existingOfferId, _companyId, OfferTypeId.APP)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._, A._)).MustNotHaveHappened(); + A.CallTo(() => _offerSubscriptionsRepository.CreateOfferSubscription(A._, A._, A._, A._)).MustNotHaveHappened(); A.CallTo(() => _offerSubscriptionsRepository.AttachAndModifyOfferSubscription(subscriptionId, A>._)).MustNotHaveHappened(); A.CallTo(() => _processStepRepository.CreateProcess(A._)).MustNotHaveHappened(); A.CallTo(() => _processStepRepository.CreateProcessStepRange(A>._)).MustNotHaveHappened(); diff --git a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs index 1c3126d090..4bb53257f6 100644 --- a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs +++ b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs @@ -23,7 +23,6 @@ using FakeItEasy; using FluentAssertions; using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; @@ -34,9 +33,9 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.ViewModels; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; using Xunit; diff --git a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceChangeBusinessLogicTests.cs b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceChangeBusinessLogicTests.cs index bf6a7bac32..778ae7cc99 100644 --- a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceChangeBusinessLogicTests.cs +++ b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceChangeBusinessLogicTests.cs @@ -21,14 +21,12 @@ using AutoFixture; using AutoFixture.AutoFakeItEasy; using FakeItEasy; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Service; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.BusinessLogic; -using PortalBackend.PortalEntities.Identity; using Xunit; namespace Org.Eclipse.TractusX.Portal.Backend.Services.Service.Tests.BusinessLogic; diff --git a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceReleaseBusinessLogicTest.cs b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceReleaseBusinessLogicTest.cs index 093e4d7fc7..92d6b60da9 100644 --- a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceReleaseBusinessLogicTest.cs +++ b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceReleaseBusinessLogicTest.cs @@ -23,7 +23,6 @@ using FakeItEasy; using FluentAssertions; using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; @@ -35,10 +34,10 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.ViewModels; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; using Xunit; @@ -389,7 +388,7 @@ public async Task UpdateServiceAsync_WithoutService_ThrowsException() var sut = new ServiceReleaseBusinessLogic(_portalRepositories, _offerService, _offerDocumentService, Options.Create(new ServiceSettings())); // Act - async Task Act() => await sut.UpdateServiceAsync(_notExistingServiceId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await sut.UpdateServiceAsync(_notExistingServiceId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); @@ -405,7 +404,7 @@ public async Task UpdateServiceAsync_WithActiveService_ThrowsException() var sut = new ServiceReleaseBusinessLogic(_portalRepositories, _offerService, _offerDocumentService, Options.Create(new ServiceSettings())); // Act - async Task Act() => await sut.UpdateServiceAsync(_activeServiceId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await sut.UpdateServiceAsync(_activeServiceId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); @@ -421,7 +420,7 @@ public async Task UpdateServiceAsync_WithInvalidUser_ThrowsException() var sut = new ServiceReleaseBusinessLogic(_portalRepositories, _offerService, _offerDocumentService, Options.Create(new ServiceSettings())); // Act - async Task Act() => await sut.UpdateServiceAsync(_differentCompanyServiceId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + async Task Act() => await sut.UpdateServiceAsync(_differentCompanyServiceId, data, _identity.CompanyId).ConfigureAwait(false); // Assert var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); @@ -464,7 +463,7 @@ public async Task UpdateServiceAsync_WithValidData_ReturnsExpected() var sut = new ServiceReleaseBusinessLogic(_portalRepositories, _offerService, _offerDocumentService, Options.Create(settings)); // Act - await sut.UpdateServiceAsync(_existingServiceId, data, new ValueTuple(_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); + await sut.UpdateServiceAsync(_existingServiceId, data, _identity.CompanyId).ConfigureAwait(false); // Assert A.CallTo(() => _offerRepository.AttachAndModifyOffer(A._, A>._, A>._)) diff --git a/tests/marketplace/Services.Service.Tests/Controllers/ServiceChangeControllerTest.cs b/tests/marketplace/Services.Service.Tests/Controllers/ServiceChangeControllerTest.cs index 66da3c1d1d..68d4030e9a 100644 --- a/tests/marketplace/Services.Service.Tests/Controllers/ServiceChangeControllerTest.cs +++ b/tests/marketplace/Services.Service.Tests/Controllers/ServiceChangeControllerTest.cs @@ -21,13 +21,11 @@ using AutoFixture; using FakeItEasy; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using Xunit; namespace Org.Eclipse.TractusX.Portal.Backend.Services.Service.Tests.Controllers; diff --git a/tests/marketplace/Services.Service.Tests/Controllers/ServiceControllerTest.cs b/tests/marketplace/Services.Service.Tests/Controllers/ServiceControllerTest.cs index a1025898d6..ceba7a189c 100644 --- a/tests/marketplace/Services.Service.Tests/Controllers/ServiceControllerTest.cs +++ b/tests/marketplace/Services.Service.Tests/Controllers/ServiceControllerTest.cs @@ -22,16 +22,15 @@ using FakeItEasy; using FluentAssertions; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.ViewModels; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; using Xunit; diff --git a/tests/marketplace/Services.Service.Tests/Controllers/ServiceReleaseControllerTest.cs b/tests/marketplace/Services.Service.Tests/Controllers/ServiceReleaseControllerTest.cs index 45d021e80b..c0ea3e03af 100644 --- a/tests/marketplace/Services.Service.Tests/Controllers/ServiceReleaseControllerTest.cs +++ b/tests/marketplace/Services.Service.Tests/Controllers/ServiceReleaseControllerTest.cs @@ -23,17 +23,16 @@ using FluentAssertions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.ViewModels; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using Xunit; namespace Org.Eclipse.TractusX.Portal.Backend.Services.Service.Tests.Controllers; @@ -216,14 +215,14 @@ public async Task UpdateService_ReturnsExpected() //Arrange var serviceId = _fixture.Create(); var data = _fixture.Create(); - A.CallTo(() => _logic.UpdateServiceAsync(A._, A._, new ValueTuple(_identity.UserId, _identity.CompanyId))) + A.CallTo(() => _logic.UpdateServiceAsync(A._, A._, _identity.CompanyId)) .Returns(Task.CompletedTask); //Act var result = await this._controller.UpdateService(serviceId, data).ConfigureAwait(false); //Assert - A.CallTo(() => _logic.UpdateServiceAsync(serviceId, data, new ValueTuple(_identity.UserId, _identity.CompanyId))).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.UpdateServiceAsync(serviceId, data, _identity.CompanyId)).MustHaveHappenedOnceExactly(); Assert.IsType(result); } diff --git a/tests/notifications/Notifications.Service.Tests/BusinessLogic/NotificationBusinessLogicTests.cs b/tests/notifications/Notifications.Service.Tests/BusinessLogic/NotificationBusinessLogicTests.cs index 60b61f4230..3e81ce1d53 100644 --- a/tests/notifications/Notifications.Service.Tests/BusinessLogic/NotificationBusinessLogicTests.cs +++ b/tests/notifications/Notifications.Service.Tests/BusinessLogic/NotificationBusinessLogicTests.cs @@ -23,7 +23,6 @@ using FakeItEasy; using FluentAssertions; using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Notifications.Service.BusinessLogic; @@ -33,8 +32,8 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; -using PortalBackend.PortalEntities.Identity; using Xunit; namespace Org.Eclipse.TractusX.Portal.Backend.Notifications.Service.Tests.BusinessLogic; diff --git a/tests/notifications/Notifications.Service.Tests/Controllers/NotificationControllerTest.cs b/tests/notifications/Notifications.Service.Tests/Controllers/NotificationControllerTest.cs index 321be6591e..1c4db921f6 100644 --- a/tests/notifications/Notifications.Service.Tests/Controllers/NotificationControllerTest.cs +++ b/tests/notifications/Notifications.Service.Tests/Controllers/NotificationControllerTest.cs @@ -22,15 +22,14 @@ using FakeItEasy; using FluentAssertions; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Notifications.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Notifications.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Notifications.Service.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using Xunit; namespace Org.Eclipse.TractusX.Portal.Backend.Notifications.Service.Tests.Controllers; diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/ApplicationChecklistRepositoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/ApplicationChecklistRepositoryTests.cs index 68fbe33587..2a62498e83 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/ApplicationChecklistRepositoryTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/ApplicationChecklistRepositoryTests.cs @@ -174,7 +174,7 @@ public async Task GetChecklistProcessStepData_WithExisting_ReturnsExpected() // Assert result.Should().NotBeNull(); result!.IsSubmitted.Should().BeTrue(); - result.Checklist.Should().HaveCount(5).And.Contain(checklistData); + result.Checklist.Should().HaveCount(5).And.ContainInOrder(checklistData!); result.Process!.Id.Should().Be(new Guid("1f9a3232-9772-4ecb-8f50-c16e97772dfe")); result.Process.ProcessTypeId.Should().Be(ProcessTypeId.APPLICATION_CHECKLIST); result.Process.LockExpiryDate.Should().Be(DateTimeOffset.Parse("2023-03-01 00:00:00.000000 +00:00")); diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs index 98534f0f69..324c5219d0 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs @@ -81,7 +81,6 @@ public async Task CreateConnector_WithServiceAccount_ReturnsExpected() var result = sut.CreateConnector("Test connector", "de", "https://www.test.de", con => { con.ProviderId = new Guid("2dc4249f-b5ca-4d42-bef1-7a7a950a4f87"); - con.LastEditorId = new Guid("d0c8ae19-d4f3-49cc-9cb4-6c766d4680f2"); }); // Assert @@ -89,9 +88,9 @@ public async Task CreateConnector_WithServiceAccount_ReturnsExpected() var changedEntries = changeTracker.Entries().ToList(); result.Name.Should().Be("Test connector"); changeTracker.HasChanges().Should().BeTrue(); - changedEntries.Should().NotBeEmpty(); - changedEntries.Should().HaveCount(1); - changedEntries.Single().Entity.Should().BeOfType().Which.Name.Should().Be("Test connector"); + changedEntries.Should().ContainSingle() + .Which.Entity.Should().BeOfType() + .Which.Name.Should().Be("Test connector"); } #endregion @@ -260,6 +259,7 @@ public async Task GetSelfDescriptionDocumentDataAsync_WithoutDocumentId_ReturnsE // Assert result.Should().NotBeNull(); result.IsValidConnectorId.Should().BeTrue(); + result.IsProvidingOrHostCompany.Should().BeTrue(); result.SelfDescriptionDocumentId.Should().BeNull(); result.DocumentStatusId.Should().BeNull(); } @@ -276,10 +276,26 @@ public async Task GetSelfDescriptionDocumentDataAsync_WithDocumentId_ReturnsExpe // Assert result.Should().NotBeNull(); result.IsValidConnectorId.Should().BeTrue(); + result.IsProvidingOrHostCompany.Should().BeTrue(); result.SelfDescriptionDocumentId.Should().Be(new Guid("e020787d-1e04-4c0b-9c06-bd1cd44724b3")); result.DocumentStatusId.Should().Be(DocumentStatusId.LOCKED); } + [Fact] + public async Task GetSelfDescriptionDocumentDataAsync_WithoutExistingCompanyId_ReturnsExpected() + { + // Arrange + var (sut, _) = await CreateSut().ConfigureAwait(false); + + // Act + var result = await sut.GetConnectorDeleteDataAsync(new Guid("7e86a0b8-6903-496b-96d1-0ef508206839"), Guid.NewGuid()).ConfigureAwait(false); + + // Assert + result.Should().NotBeNull(); + result.IsValidConnectorId.Should().BeTrue(); + result.IsProvidingOrHostCompany.Should().BeFalse(); + } + [Fact] public async Task GetSelfDescriptionDocumentDataAsync_WithoutExistingConnectorId_ReturnsExpected() { diff --git a/tests/provisioning/Provisioning.Library.Tests/UserProvisioningServiceCreateUsersTests.cs b/tests/provisioning/Provisioning.Library.Tests/UserProvisioningServiceCreateUsersTests.cs index d95010afac..1373f68f2b 100644 --- a/tests/provisioning/Provisioning.Library.Tests/UserProvisioningServiceCreateUsersTests.cs +++ b/tests/provisioning/Provisioning.Library.Tests/UserProvisioningServiceCreateUsersTests.cs @@ -39,7 +39,6 @@ public class UserProvisioningServiceCreateUsersTests private readonly int _indexSpecialUser; private readonly string _firstNameSpecialUser; private readonly Guid _companyUserIdSpecialUser; - private readonly Guid _userId; private readonly IProvisioningManager _provisioningManager; private readonly IPortalRepositories _portalRepositories; private readonly IUserRepository _userRepository; @@ -94,7 +93,6 @@ public async Task TestFixtureSetup() await sut.CreateOwnCompanyIdpUsersAsync( _companyNameIdpAliasData, userCreationInfoIdp, - _userId, _cancellationTokenSource.Token ).ToListAsync().ConfigureAwait(false); @@ -116,7 +114,6 @@ public async Task TestSharedIdpFixtureSetup() await sut.CreateOwnCompanyIdpUsersAsync( _companyNameIdpAliasDataSharedIdp, userCreationInfoIdp, - _userId, _cancellationTokenSource.Token ).ToListAsync().ConfigureAwait(false); @@ -138,7 +135,6 @@ public async Task TestCreateUsersAllSuccess() var result = await sut.CreateOwnCompanyIdpUsersAsync( _companyNameIdpAliasData, userCreationInfoIdp.ToAsyncEnumerable(), - _userId, _cancellationTokenSource.Token ).ToListAsync().ConfigureAwait(false); @@ -171,7 +167,6 @@ public async Task TestCreateUsersRolesAssignmentError() var result = await sut.CreateOwnCompanyIdpUsersAsync( _companyNameIdpAliasData, userCreationInfoIdp.ToAsyncEnumerable(), - _userId, _cancellationTokenSource.Token ).ToListAsync().ConfigureAwait(false); @@ -205,7 +200,6 @@ public async Task TestCreateUsersRolesAssignmentNoRolesAssignedSuccess() var result = await sut.CreateOwnCompanyIdpUsersAsync( _companyNameIdpAliasData, userCreationInfoIdp.ToAsyncEnumerable(), - _userId, _cancellationTokenSource.Token ).ToListAsync().ConfigureAwait(false); @@ -235,7 +229,6 @@ public async Task TestCreateUsersDuplicateKeycloakUserError() var result = await sut.CreateOwnCompanyIdpUsersAsync( _companyNameIdpAliasData, userCreationInfoIdp.ToAsyncEnumerable(), - _userId, _cancellationTokenSource.Token ).ToListAsync().ConfigureAwait(false); @@ -269,8 +262,8 @@ public async Task TestCreateUsersNotExistingCompanyUserWithoutKeycloakUserSucces { UserEntityId = centralUserId }); - A.CallTo(() => _userRepository.CreateCompanyUser(A._, userInfo.FirstName, A._, A._, A._)) - .ReturnsLazily((Guid _, string? firstName, string? lastName, string email, Guid creatorId) => new CompanyUser(identityId, creatorId) { Firstname = firstName, Lastname = lastName, Email = email }); + A.CallTo(() => _userRepository.CreateCompanyUser(A._, userInfo.FirstName, A._, A._)) + .ReturnsLazily((Guid _, string? firstName, string? lastName, string email) => new CompanyUser(identityId) { Firstname = firstName, Lastname = lastName, Email = email }); A.CallTo(() => _provisioningManager.CreateCentralUserAsync(A.That.Matches(u => u.FirstName == userInfo.FirstName), A)>>._)) .Returns(centralUserId); @@ -278,7 +271,6 @@ public async Task TestCreateUsersNotExistingCompanyUserWithoutKeycloakUserSucces var result = await sut.CreateOwnCompanyIdpUsersAsync( _companyNameIdpAliasData, userCreationInfoIdp.ToAsyncEnumerable(), - _userId, _cancellationTokenSource.Token ).ToListAsync().ConfigureAwait(false); @@ -286,8 +278,8 @@ public async Task TestCreateUsersNotExistingCompanyUserWithoutKeycloakUserSucces A.CallTo(() => _provisioningManager.CreateCentralUserAsync(A._, A)>>._)).MustHaveHappened(userCreationInfoIdp.Count, Times.Exactly); A.CallTo(() => _provisioningManager.CreateCentralUserAsync(A.That.Matches(u => u.FirstName == userInfo.FirstName), A)>>._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _userRepository.CreateIdentity(_companyNameIdpAliasData.CompanyId, UserStatusId.ACTIVE)).MustHaveHappened(userCreationInfoIdp.Count, Times.Exactly); - A.CallTo(() => _userRepository.CreateCompanyUser(A._, A._, A._, A._, _companyNameIdpAliasData.CompanyUserId)).MustHaveHappened(userCreationInfoIdp.Count, Times.Exactly); - A.CallTo(() => _userRepository.CreateCompanyUser(A._, userInfo.FirstName, userInfo.LastName, userInfo.Email, _companyNameIdpAliasData.CompanyUserId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _userRepository.CreateCompanyUser(A._, A._, A._, A._)).MustHaveHappened(userCreationInfoIdp.Count, Times.Exactly); + A.CallTo(() => _userRepository.CreateCompanyUser(A._, userInfo.FirstName, userInfo.LastName, userInfo.Email)).MustHaveHappenedOnceExactly(); A.CallTo(() => _businessPartnerRepository.CreateCompanyUserAssignedBusinessPartner(A._, _companyNameIdpAliasData.BusinessPartnerNumber!)).MustHaveHappened(userCreationInfoIdp.Count, Times.Exactly); A.CallTo(() => _businessPartnerRepository.CreateCompanyUserAssignedBusinessPartner(identityId, _companyNameIdpAliasData.BusinessPartnerNumber!)).MustHaveHappenedOnceExactly(); @@ -315,7 +307,6 @@ public async Task TestCreateUsersExistingCompanyUserWithoutKeycloakUserSuccess() var result = await sut.CreateOwnCompanyIdpUsersAsync( _companyNameIdpAliasData, userCreationInfoIdp.ToAsyncEnumerable(), - _userId, _cancellationTokenSource.Token ).ToListAsync().ConfigureAwait(false); @@ -323,8 +314,8 @@ public async Task TestCreateUsersExistingCompanyUserWithoutKeycloakUserSuccess() A.CallTo(() => _provisioningManager.CreateCentralUserAsync(A._, A)>>._)).MustHaveHappened(userCreationInfoIdp.Count, Times.Exactly); A.CallTo(() => _provisioningManager.CreateCentralUserAsync(A.That.Matches(u => u.FirstName == userInfo.FirstName), A)>>._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _userRepository.CreateIdentity(A._, UserStatusId.ACTIVE)).MustHaveHappened(userCreationInfoIdp.Count - 1, Times.Exactly); - A.CallTo(() => _userRepository.CreateCompanyUser(A._, A._, A._, A._, _companyNameIdpAliasData.CompanyUserId)).MustHaveHappened(userCreationInfoIdp.Count - 1, Times.Exactly); - A.CallTo(() => _userRepository.CreateCompanyUser(A._, userInfo.FirstName, A._, A._, A._)).MustNotHaveHappened(); + A.CallTo(() => _userRepository.CreateCompanyUser(A._, A._, A._, A._)).MustHaveHappened(userCreationInfoIdp.Count - 1, Times.Exactly); + A.CallTo(() => _userRepository.CreateCompanyUser(A._, userInfo.FirstName, A._, A._)).MustNotHaveHappened(); A.CallTo(() => _businessPartnerRepository.CreateCompanyUserAssignedBusinessPartner(A._, _companyNameIdpAliasData.BusinessPartnerNumber!)).MustHaveHappened(userCreationInfoIdp.Count - 1, Times.Exactly); A.CallTo(() => _businessPartnerRepository.CreateCompanyUserAssignedBusinessPartner(companyUserId, A._)).MustNotHaveHappened(); @@ -425,11 +416,10 @@ private void SetupRepositories() userStatusId, IdentityTypeId.COMPANY_USER)); - A.CallTo(() => _userRepository.CreateCompanyUser(A._, A._, A._, A._, A._)) - .ReturnsLazily((Guid _, string firstName, string _, string _, Guid lastEditorId) => + A.CallTo(() => _userRepository.CreateCompanyUser(A._, A._, A._, A._)) + .ReturnsLazily((Guid _, string firstName, string _, string _) => new CompanyUser( - firstName == _firstNameSpecialUser ? _companyUserIdSpecialUser : Guid.NewGuid(), - lastEditorId)); + firstName == _firstNameSpecialUser ? _companyUserIdSpecialUser : Guid.NewGuid())); A.CallTo(() => _businessPartnerRepository.CreateCompanyUserAssignedBusinessPartner(A._, A._)) .ReturnsLazily((Guid companyUserId, string businessPartnerNumber) => new CompanyUserAssignedBusinessPartner(companyUserId, businessPartnerNumber)); diff --git a/tests/registration/Registration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs b/tests/registration/Registration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs index 8560d23791..5d21aca39f 100644 --- a/tests/registration/Registration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs +++ b/tests/registration/Registration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs @@ -24,7 +24,6 @@ using FluentAssertions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; using Org.Eclipse.TractusX.Portal.Backend.Mailing.SendMail; @@ -33,6 +32,7 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Processes.ApplicationChecklist.Library; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; @@ -42,7 +42,6 @@ using Org.Eclipse.TractusX.Portal.Backend.Registration.Service.Model; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using System.Collections.Immutable; using Xunit; @@ -1261,7 +1260,7 @@ public async Task TestInviteNewUserAsyncSuccess() await sut.InviteNewUserAsync(_existingApplicationId, userCreationInfo, (_identity.UserId, _identity.CompanyId)).ConfigureAwait(false); - A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._, A._)).MustHaveHappened(); + A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._)).MustHaveHappened(); A.CallTo(() => _applicationRepository.CreateInvitation(A.That.IsEqualTo(_existingApplicationId), A._)).MustHaveHappened(); A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappened(); A.CallTo(() => _mailingService.SendMails(A.That.IsEqualTo(userCreationInfo.eMail), A>.That.Matches(x => x["companyName"] == _displayName), A>._)).MustHaveHappened(); @@ -1354,7 +1353,7 @@ public async Task TestInviteNewUserAsyncCreationErrorThrows() var error = await Assert.ThrowsAsync(Act).ConfigureAwait(false); error.Message.Should().Be(_error.Message); - A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._, A._)).MustHaveHappened(); + A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._)).MustHaveHappened(); A.CallTo(() => _applicationRepository.CreateInvitation(A.That.IsEqualTo(_existingApplicationId), A._)).MustNotHaveHappened(); A.CallTo(() => _portalRepositories.SaveAsync()).MustNotHaveHappened(); A.CallTo(() => _mailingService.SendMails(A.That.IsEqualTo(userCreationInfo.eMail), A>._, A>._)).MustNotHaveHappened(); @@ -2560,8 +2559,8 @@ private void SetupRepositories() private void SetupFakesForInvitation() { - A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._, A._)) - .ReturnsLazily((CompanyNameIdpAliasData _, IAsyncEnumerable userCreationInfos, Guid _, CancellationToken _) => + A.CallTo(() => _userProvisioningService.CreateOwnCompanyIdpUsersAsync(A._, A>._, A._)) + .ReturnsLazily((CompanyNameIdpAliasData _, IAsyncEnumerable userCreationInfos, CancellationToken _) => userCreationInfos.Select(userCreationInfo => _processLine(userCreationInfo))); A.CallTo(() => _userProvisioningService.GetRoleDatas(A>._)) diff --git a/tests/registration/Registration.Service.Tests/Controller/RegistrationControllerTest.cs b/tests/registration/Registration.Service.Tests/Controller/RegistrationControllerTest.cs index b329b749e2..8303199fcc 100644 --- a/tests/registration/Registration.Service.Tests/Controller/RegistrationControllerTest.cs +++ b/tests/registration/Registration.Service.Tests/Controller/RegistrationControllerTest.cs @@ -23,15 +23,14 @@ using FluentAssertions; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Registration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Registration.Service.Controllers; using Org.Eclipse.TractusX.Portal.Backend.Registration.Service.Model; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -using PortalBackend.PortalEntities.Identity; using System.Text; using Xunit; diff --git a/tests/shared/Tests.Shared/Extensions/ControllerExtensions.cs b/tests/shared/Tests.Shared/Extensions/ControllerExtensions.cs index e24f7f2191..639fc60194 100644 --- a/tests/shared/Tests.Shared/Extensions/ControllerExtensions.cs +++ b/tests/shared/Tests.Shared/Extensions/ControllerExtensions.cs @@ -20,11 +20,9 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using System.Security.Claims; namespace Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; diff --git a/tests/shared/Tests.Shared/FakeIdentityService.cs b/tests/shared/Tests.Shared/FakeIdentityService.cs index 5719cd3ba6..99c5e3abd9 100644 --- a/tests/shared/Tests.Shared/FakeIdentityService.cs +++ b/tests/shared/Tests.Shared/FakeIdentityService.cs @@ -19,8 +19,7 @@ ********************************************************************************/ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identity; -using PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; namespace Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; diff --git a/tests/shared/Tests.Shared/IntegrationTests/IntegrationTestFactory.cs b/tests/shared/Tests.Shared/IntegrationTests/IntegrationTestFactory.cs index 5740613edd..32ef5e047b 100644 --- a/tests/shared/Tests.Shared/IntegrationTests/IntegrationTestFactory.cs +++ b/tests/shared/Tests.Shared/IntegrationTests/IntegrationTestFactory.cs @@ -33,7 +33,7 @@ using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.Migrations.Seeder; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identity; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Xunit; namespace Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.IntegrationTests; diff --git a/tests/shared/Tests.Shared/TestSeeds/BaseSeed.cs b/tests/shared/Tests.Shared/TestSeeds/BaseSeed.cs index f7f1b158be..0fc937adcb 100644 --- a/tests/shared/Tests.Shared/TestSeeds/BaseSeed.cs +++ b/tests/shared/Tests.Shared/TestSeeds/BaseSeed.cs @@ -128,55 +128,55 @@ public static Action SeedBasedata() => dbContext => dbContext.CompanyUsers.AddRange(new List { - new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058019990"), null) + new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058019990")) { Email = "tester.user1@test.de", Firstname = "Test User 1", Lastname = "cx-user-2", }, - new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058019991"), null) + new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058019991")) { Email = "tester.user2@test.de", Firstname = "Test User 2", Lastname = "cx-admin-2", }, - new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058019992"), null) + new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058019992")) { Email = "tester.user3@test.de", Firstname = "Test User 3", Lastname = "company-admin-2", }, - new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058019993"), new Guid("ac1cf001-7fbc-1f2f-817f-bce058019990")) + new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058019993")) { Email = "tester.user4@test.de", Firstname = "Test User 4", Lastname = "it-admin-2", }, - new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058020000"), new Guid("ac1cf001-7fbc-1f2f-817f-bce058019990")) + new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058020000")) { Email = "tester.user5@test.de", Firstname = "Test User 5", Lastname = "CX User", }, - new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001"), new Guid("ac1cf001-7fbc-1f2f-817f-bce058019990")) + new(new Guid("ac1cf001-7fbc-1f2f-817f-bce058020001")) { Email = "tester.user6@test.de", Firstname = "Test User 6", Lastname = "CX Admin", }, - new(new Guid("40ed8c0d-b506-4c15-b2a9-85fee4b0c280"), new Guid("ac1cf001-7fbc-1f2f-817f-bce058019990")) + new(new Guid("40ed8c0d-b506-4c15-b2a9-85fee4b0c280")) { Email = "tester.user7@test.de", Firstname = "Test User 7", Lastname = "Inactive", }, - new(new Guid("22b7bfef-19f5-4d8a-9fb4-af1a5e978f21"), new Guid("ac1cf001-7fbc-1f2f-817f-bce058019990")) + new(new Guid("22b7bfef-19f5-4d8a-9fb4-af1a5e978f21")) { Email = "tester.user8@test.de", Firstname = "Test User 8", Lastname = "Deleted", }, - new(new Guid("adf37b09-53f3-48ea-b8fb-8cbb7fd79324"), new Guid("ac1cf001-7fbc-1f2f-817f-bce058019990")) + new(new Guid("adf37b09-53f3-48ea-b8fb-8cbb7fd79324")) { Email = "tester.user@test.de", Firstname = "Test User",