Skip to content

Commit

Permalink
release(1.6.0-RC4) merge main to dev #176
Browse files Browse the repository at this point in the history
Reviewed-By: Norbert Truchsess <[email protected]>
  • Loading branch information
Phil91 authored Jul 31, 2023
2 parents 0e21972 + a950e5b commit f2546d9
Show file tree
Hide file tree
Showing 180 changed files with 9,490 additions and 2,066 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

New features, fixed bugs, known defects and other noteworthy changes to each release of the Catena-X Portal Backend.

## 1.6.0-RC4

### Change
* Apps Service
* Change the appInstanceId to iamClientId for the /{appId}/subscription/{subscriptionId}/provider endpoint
* BPDM Service
* BPDM Service calls are changed to the new bpdm endpoints

### Technical Support
* reinclude http request & response messages in logging
* lastEditorId is now set whenever a auditable entity is changed

### Bugfix
* Apps Service
* Fix /api/apps/business endpoint to return correct results
* Fix POST /api/apps/appreleaseprocess/consent/{appId}/agreementConsents to save consents and set the correct user id
* Services Service
* Fix POST /api/services/servicerelease/consent/{serviceId}/agreementConsents to save consents and set the correct user id
* Administration Service
* Ignore inactive credentials when trying to create a new credential
* AutoSetup
* fix an error that occurred when autoSetup was executed by a service-account caused by the the creator of a notification being linked to a companyUser instead of identities

## 1.6.0-RC3

### Change
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile-maintenance-service
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ COPY src/framework/Framework.Linq/ src/framework/Framework.Linq/
COPY src/framework/Framework.Models/ src/framework/Framework.Models/
COPY src/framework/Framework.Logging/ src/framework/Framework.Logging/
COPY src/framework/Framework.ErrorHandling.Library/ src/framework/Framework.ErrorHandling.Library/
COPY src/framework/Framework.ProcessIdentity/ src/framework/Framework.ProcessIdentity/
RUN dotnet restore "src/maintenance/Maintenance.App/Maintenance.App.csproj"
WORKDIR /src/maintenance/Maintenance.App
RUN dotnet build "Maintenance.App.csproj" -c Release -o /app/build
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile-portal-migrations
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ COPY /src/framework/Framework.Models /src/framework/Framework.Models
COPY /src/framework/Framework.Linq /src/framework/Framework.Linq
COPY /src/framework/Framework.ErrorHandling.Library /src/framework/Framework.ErrorHandling.Library
COPY /src/framework/Framework.BaseDependencies /src/framework/Framework.BaseDependencies
COPY /src/framework/Framework.ProcessIdentity /src/framework/Framework.ProcessIdentity/
COPY /src/framework/Framework.Seeding /src/framework/Framework.Seeding
WORKDIR /src/portalbackend/PortalBackend.Migrations
RUN dotnet build "PortalBackend.Migrations.csproj" -c Release -o /migrations/build
Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.6.0</VersionPrefix>
<VersionSuffix>RC3</VersionSuffix>
<VersionSuffix>RC4</VersionSuffix>
</PropertyGroup>
</Project>
</Project>
15 changes: 15 additions & 0 deletions src/Portal.Backend.sln
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.Authorization", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.Models.Tests", "..\tests\framework\Framework.Models.Tests\Framework.Models.Tests.csproj", "{EA9BA26E-83F6-47C4-BA3B-880AF1AD6A82}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.ProcessIdentity", "framework\Framework.ProcessIdentity\Framework.ProcessIdentity.csproj", "{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1298,6 +1300,18 @@ Global
{EA9BA26E-83F6-47C4-BA3B-880AF1AD6A82}.Release|x64.Build.0 = Release|Any CPU
{EA9BA26E-83F6-47C4-BA3B-880AF1AD6A82}.Release|x86.ActiveCfg = Release|Any CPU
{EA9BA26E-83F6-47C4-BA3B-880AF1AD6A82}.Release|x86.Build.0 = Release|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Debug|x64.ActiveCfg = Debug|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Debug|x64.Build.0 = Debug|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Debug|x86.ActiveCfg = Debug|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Debug|x86.Build.0 = Debug|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Release|Any CPU.Build.0 = Release|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Release|x64.ActiveCfg = Release|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Release|x64.Build.0 = Release|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Release|x86.ActiveCfg = Release|Any CPU
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1396,5 +1410,6 @@ Global
{1694E75F-ABCE-4573-B805-18ED50F148FD} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{031237BF-7B2A-4B37-9E37-4D4C575FDD22} = {23500169-FC01-4D2B-A997-E7FAE2169FC0}
{CB9FFDD9-7F41-44DA-BFA8-C157A96D51F6} = {23500169-FC01-4D2B-A997-E7FAE2169FC0}
{4CA307AB-A0F8-4AA5-A09D-91F47DA3054A} = {23500169-FC01-4D2B-A997-E7FAE2169FC0}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ public async Task ApproveCredential(Guid userId, Guid credentialId, Cancellation
{
c.CompanySsiDetailStatusId = CompanySsiDetailStatusId.ACTIVE;
c.DateLastChanged = _dateTimeProvider.OffsetNow;
c.LastEditorId = userId;
});

switch (data.Kind)
Expand Down Expand Up @@ -475,7 +474,6 @@ public async Task RejectCredential(Guid userId, Guid credentialId)
{
c.CompanySsiDetailStatusId = CompanySsiDetailStatusId.INACTIVE;
c.DateLastChanged = _dateTimeProvider.OffsetNow;
c.LastEditorId = userId;
});

await _portalRepositories.SaveAsync().ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ public async Task<ConnectorData> GetCompanyConnectorData(Guid connectorId, Guid
}

/// <inheritdoc/>
public Task<Guid> CreateConnectorAsync(ConnectorInputModel connectorInputModel, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken)
public Task<Guid> CreateConnectorAsync(ConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken)
{
ValidateCertificationType(connectorInputModel.Certificate);
return CreateConnectorInternalAsync(connectorInputModel, identity, cancellationToken);
return CreateConnectorInternalAsync(connectorInputModel, companyId, cancellationToken);
}

public Task<Guid> CreateManagedConnectorAsync(ManagedConnectorInputModel connectorInputModel, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken)
public Task<Guid> CreateManagedConnectorAsync(ManagedConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken)
{
ValidateCertificationType(connectorInputModel.Certificate);
return CreateManagedConnectorInternalAsync(connectorInputModel, identity, cancellationToken);
return CreateManagedConnectorInternalAsync(connectorInputModel, companyId, cancellationToken);
}

private void ValidateCertificationType(IFormFile? certificate)
Expand All @@ -135,45 +135,44 @@ private void ValidateCertificationType(IFormFile? certificate)
}
}

private async Task<Guid> CreateConnectorInternalAsync(ConnectorInputModel connectorInputModel, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken)
private async Task<Guid> CreateConnectorInternalAsync(ConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken)
{
var (name, connectorUrl, location, certificate, technicalUserId) = connectorInputModel;
await CheckLocationExists(location);

var result = await _portalRepositories
.GetInstance<ICompanyRepository>()
.GetCompanyBpnAndSelfDescriptionDocumentByIdAsync(identity.CompanyId)
.GetCompanyBpnAndSelfDescriptionDocumentByIdAsync(companyId)
.ConfigureAwait(false);

if (string.IsNullOrEmpty(result.Bpn))
{
throw new UnexpectedConditionException($"provider company {identity.CompanyId} has no businessPartnerNumber assigned");
throw new UnexpectedConditionException($"provider company {companyId} has no businessPartnerNumber assigned");
}

if (result.SelfDescriptionDocumentId is null)
{
throw new UnexpectedConditionException($"provider company {identity.CompanyId} has no self description document");
throw new UnexpectedConditionException($"provider company {companyId} has no self description document");
}
await ValidateTechnicalUser(technicalUserId, identity.CompanyId).ConfigureAwait(false);
await ValidateTechnicalUser(technicalUserId, companyId).ConfigureAwait(false);

var connectorRequestModel = new ConnectorRequestModel(name, connectorUrl, ConnectorTypeId.COMPANY_CONNECTOR, location, identity.CompanyId, identity.CompanyId, technicalUserId);
var connectorRequestModel = new ConnectorRequestModel(name, connectorUrl, ConnectorTypeId.COMPANY_CONNECTOR, location, companyId, companyId, technicalUserId);
return await CreateAndRegisterConnectorAsync(
connectorRequestModel,
result.Bpn,
result.SelfDescriptionDocumentId.Value,
certificate,
identity.UserId,
null,
cancellationToken).ConfigureAwait(false);
}

private async Task<Guid> CreateManagedConnectorInternalAsync(ManagedConnectorInputModel connectorInputModel, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken)
private async Task<Guid> CreateManagedConnectorInternalAsync(ManagedConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken)
{
var (name, connectorUrl, location, subscriptionId, certificate, technicalUserId) = connectorInputModel;
await CheckLocationExists(location).ConfigureAwait(false);

var result = await _portalRepositories.GetInstance<IOfferSubscriptionsRepository>()
.CheckOfferSubscriptionWithOfferProvider(subscriptionId, identity.CompanyId)
.CheckOfferSubscriptionWithOfferProvider(subscriptionId, companyId)
.ConfigureAwait(false);

if (!result.Exists)
Expand Down Expand Up @@ -209,13 +208,12 @@ private async Task<Guid> CreateManagedConnectorInternalAsync(ManagedConnectorInp

await ValidateTechnicalUser(technicalUserId, result.CompanyId).ConfigureAwait(false);

var connectorRequestModel = new ConnectorRequestModel(name, connectorUrl, ConnectorTypeId.CONNECTOR_AS_A_SERVICE, location, result.CompanyId, identity.CompanyId, technicalUserId);
var connectorRequestModel = new ConnectorRequestModel(name, connectorUrl, ConnectorTypeId.CONNECTOR_AS_A_SERVICE, location, result.CompanyId, companyId, technicalUserId);
return await CreateAndRegisterConnectorAsync(
connectorRequestModel,
result.ProviderBpn,
result.SelfDescriptionDocumentId!.Value,
certificate,
identity.UserId,
subscriptionId,
cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -248,7 +246,6 @@ private async Task<Guid> CreateAndRegisterConnectorAsync(
string businessPartnerNumber,
Guid selfDescriptionDocumentId,
IFormFile? file,
Guid userId,
Guid? subscriptionId,
CancellationToken cancellationToken)
{
Expand All @@ -264,7 +261,6 @@ private async Task<Guid> CreateAndRegisterConnectorAsync(
connector.ProviderId = provider;
connector.HostId = host;
connector.TypeId = type;
connector.LastEditorId = userId;
connector.DateLastChanged = DateTimeOffset.UtcNow;
if (technicalUserId != null)
{
Expand Down Expand Up @@ -314,24 +310,29 @@ await _sdFactoryBusinessLogic
}

/// <inheritdoc/>
public async Task DeleteConnectorAsync(Guid connectorId, Guid userId, CancellationToken cancellationToken)
public async Task DeleteConnectorAsync(Guid connectorId, Guid companyId, CancellationToken cancellationToken)
{
var connectorsRepository = _portalRepositories.GetInstance<IConnectorsRepository>();
var (isValidConnectorId, dapsClientId, selfDescriptionDocumentId,
documentStatus, connectorStatus, dapsRegistrationSuccess) = await connectorsRepository.GetConnectorDeleteDataAsync(connectorId).ConfigureAwait(false);
var (isValidConnectorId, isProvidingOrHostCompany, dapsClientId, selfDescriptionDocumentId,
documentStatus, connectorStatus, dapsRegistrationSuccess) = await connectorsRepository.GetConnectorDeleteDataAsync(connectorId, companyId).ConfigureAwait(false);

if (!isValidConnectorId)
{
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:
await DeleteUpdateConnectorDetail(connectorId, userId, dapsClientId, connectorsRepository, cancellationToken);
await DeleteUpdateConnectorDetail(connectorId, dapsClientId, connectorsRepository, cancellationToken);
break;
case (true, ConnectorStatusId.ACTIVE) when selfDescriptionDocumentId != null && documentStatus != null:
await DeleteConnector(connectorId, userId, dapsClientId, selfDescriptionDocumentId.Value, documentStatus.Value, connectorsRepository, cancellationToken);
await DeleteConnector(connectorId, dapsClientId, selfDescriptionDocumentId.Value, documentStatus.Value, connectorsRepository, cancellationToken);
break;
case (false, ConnectorStatusId.PENDING) when selfDescriptionDocumentId == null:
await DeleteConnectorWithoutDocuments(connectorId, connectorsRepository);
Expand All @@ -346,17 +347,17 @@ public async Task DeleteConnectorAsync(Guid connectorId, Guid userId, Cancellati
}
}

private async Task DeleteConnector(Guid connectorId, Guid userId, string? dapsClientId, Guid selfDescriptionDocumentId, DocumentStatusId documentStatus, IConnectorsRepository connectorsRepository, CancellationToken cancellationToken)
private async Task DeleteConnector(Guid connectorId, string? dapsClientId, Guid selfDescriptionDocumentId, DocumentStatusId documentStatus, IConnectorsRepository connectorsRepository, CancellationToken cancellationToken)
{
_portalRepositories.GetInstance<IDocumentRepository>().AttachAndModifyDocument(
selfDescriptionDocumentId,
a => { a.DocumentStatusId = documentStatus; },
a => { a.DocumentStatusId = DocumentStatusId.INACTIVE; });

await DeleteUpdateConnectorDetail(connectorId, userId, dapsClientId, connectorsRepository, cancellationToken);
await DeleteUpdateConnectorDetail(connectorId, dapsClientId, connectorsRepository, cancellationToken);
}

private async Task DeleteUpdateConnectorDetail(Guid connectorId, Guid userId, string? dapsClientId, IConnectorsRepository connectorsRepository, CancellationToken cancellationToken)
private async Task DeleteUpdateConnectorDetail(Guid connectorId, string? dapsClientId, IConnectorsRepository connectorsRepository, CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(dapsClientId))
{
Expand All @@ -367,7 +368,6 @@ private async Task DeleteUpdateConnectorDetail(Guid connectorId, Guid userId, st
connectorsRepository.AttachAndModifyConnector(connectorId, null, con =>
{
con.StatusId = ConnectorStatusId.INACTIVE;
con.LastEditorId = userId;
con.DateLastChanged = DateTimeOffset.UtcNow;
});
await _dapsService.DeleteDapsClient(dapsClientId, cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -437,7 +437,6 @@ public async Task<bool> TriggerDapsAsync(Guid connectorId, IFormFile certificate
con.DapsRegistrationSuccessful = true;
con.StatusId = ConnectorStatusId.ACTIVE;
con.DateLastChanged = DateTimeOffset.UtcNow;
con.LastEditorId = identity.UserId;
});

connectorsRepository.CreateConnectorClientDetails(connectorId, response.ClientId);
Expand Down Expand Up @@ -520,7 +519,10 @@ private async Task UpdateConnectorUrlInternal(Guid connectorId, ConnectorUpdateR
await _dapsService
.UpdateDapsConnectorUrl(connector.DapsClientId, data.ConnectorUrl, bpn, cancellationToken)
.ConfigureAwait(false);
connectorsRepository.AttachAndModifyConnector(connectorId, null, con => { con.ConnectorUrl = data.ConnectorUrl; });
connectorsRepository.AttachAndModifyConnector(connectorId, null, con =>
{
con.ConnectorUrl = data.ConnectorUrl;
});

await _portalRepositories.SaveAsync().ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,27 @@ public interface IConnectorsBusinessLogic
/// Add a connector to persistence layer and calls the sd factory service with connector parameters.
/// </summary>
/// <param name="connectorInputModel">Connector parameters for creation.</param>
/// <param name="identity">identity (userId and companyId) of the user</param>
/// <param name="companyId">companyId of the user</param>
/// <param name="cancellationToken"></param>
/// <returns>View model of created connector.</returns>
Task<Guid> CreateConnectorAsync(ConnectorInputModel connectorInputModel, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken);
Task<Guid> CreateConnectorAsync(ConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken);

/// <summary>
/// Add a managed connector to persistence layer and calls the sd factory service with connector parameters.
/// </summary>
/// <param name="connectorInputModel">Connector parameters for creation.</param>
/// <param name="identity">identity (userId and companyId) of the user</param>
/// <param name="companyId">companyId of the user</param>
/// <param name="cancellationToken"></param>
/// <returns>View model of created connector.</returns>
Task<Guid> CreateManagedConnectorAsync(ManagedConnectorInputModel connectorInputModel, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken);
Task<Guid> CreateManagedConnectorAsync(ManagedConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken);

/// <summary>
/// Remove a connector from persistence layer by id.
/// </summary>
/// <param name="connectorId">ID of the connector to be deleted.</param>
/// <param name="userId">userId of the user</param>
/// <param name="companyId">companyId of the user</param>
/// <param name="cancellationToken">Cancellation Token</param>
Task DeleteConnectorAsync(Guid connectorId, Guid userId, CancellationToken cancellationToken);
Task DeleteConnectorAsync(Guid connectorId, Guid companyId, CancellationToken cancellationToken);

/// <summary>
/// Retrieve connector end point along with bpns
Expand Down
Loading

0 comments on commit f2546d9

Please sign in to comment.