Skip to content

Commit

Permalink
fix(offerSubscriptionDetail): responding External Service details (#75)…
Browse files Browse the repository at this point in the history
… (#1081)

* fix(offerSubscriptionDetail): responding External Service details (#75)
* remove nonexisting app-data from service response model
* fix inconsistent test-data and unit-tests
---------
Co-authored-by: Norbert Truchsess <[email protected]>
  • Loading branch information
tfjanjua authored Nov 13, 2024
1 parent b84fa1b commit cf3aa20
Show file tree
Hide file tree
Showing 29 changed files with 328 additions and 388 deletions.
79 changes: 40 additions & 39 deletions docs/api/apps-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/AppProviderSubscriptionDetailData'
$ref: '#/components/schemas/OfferProviderSubscriptionDetailData'
'403':
description: User's company does not provide the app.
content:
Expand Down Expand Up @@ -2828,44 +2828,6 @@ components:
description: the technicalUser Profile
additionalProperties: false
description: Response for the app creation
AppProviderSubscriptionDetailData:
type: object
properties:
id:
type: string
format: uuid
offerSubscriptionStatus:
$ref: '#/components/schemas/OfferSubscriptionStatusId'
name:
type: string
nullable: true
customer:
type: string
bpn:
type: string
nullable: true
contact:
type: array
items:
type: string
technicalUserData:
type: array
items:
$ref: '#/components/schemas/SubscriptionTechnicalUserData'
connectorData:
type: array
items:
$ref: '#/components/schemas/SubscriptionAssignedConnectorData'
tenantUrl:
type: string
nullable: true
appInstanceId:
type: string
processStepTypeId:
$ref: '#/components/schemas/ProcessStepTypeId'
externalService:
$ref: '#/components/schemas/SubscriptionExternalServiceData'
additionalProperties: false
AppRequestModel:
type: object
properties:
Expand Down Expand Up @@ -3435,6 +3397,45 @@ components:
message:
type: string
additionalProperties: false
OfferProviderSubscriptionDetailData:
type: object
properties:
id:
type: string
format: uuid
offerSubscriptionStatus:
$ref: '#/components/schemas/OfferSubscriptionStatusId'
name:
type: string
nullable: true
customer:
type: string
bpn:
type: string
nullable: true
contact:
type: array
items:
type: string
technicalUserData:
type: array
items:
$ref: '#/components/schemas/SubscriptionTechnicalUserData'
connectorData:
type: array
items:
$ref: '#/components/schemas/SubscriptionAssignedConnectorData'
tenantUrl:
type: string
nullable: true
appInstanceId:
type: string
nullable: true
processStepTypeId:
$ref: '#/components/schemas/ProcessStepTypeId'
externalService:
$ref: '#/components/schemas/SubscriptionExternalServiceData'
additionalProperties: false
OfferSorting:
enum:
- DateAsc
Expand Down
35 changes: 35 additions & 0 deletions docs/api/services-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2216,26 +2216,42 @@ components:
properties:
id:
type: string
description: Id of the Offer
format: uuid
offerSubscriptionStatus:
$ref: '#/components/schemas/OfferSubscriptionStatusId'
name:
type: string
description: Name of the Offer
nullable: true
customer:
type: string
description: Name of the company subscribing the offer
bpn:
type: string
description: 'When called from /provider bpn of the company subscribing the offer, otherwise the provider company''s bpn'
nullable: true
contact:
type: array
items:
type: string
description: 'When called from /provider the company admins of the subscribing company, otherwise the salesmanagers of the offer provider'
technicalUserData:
type: array
items:
$ref: '#/components/schemas/SubscriptionTechnicalUserData'
description: Information about the technical user
connectorData:
type: array
items:
$ref: '#/components/schemas/SubscriptionAssignedConnectorData'
description: ''
processStepTypeId:
$ref: '#/components/schemas/ProcessStepTypeId'
externalService:
$ref: '#/components/schemas/SubscriptionExternalServiceData'
additionalProperties: false
description: Detail data for a offer subscription
ServiceData:
type: object
properties:
Expand Down Expand Up @@ -2766,6 +2782,25 @@ components:
status:
$ref: '#/components/schemas/OfferSubscriptionStatusId'
additionalProperties: false
SubscriptionExternalServiceData:
type: object
properties:
trusted_issuer:
type: string
participant_id:
type: string
nullable: true
iatp_id:
type: string
nullable: true
did_resolver:
type: string
decentralIdentityManagementAuthUrl:
type: string
decentralIdentityManagementServiceUrl:
type: string
nullable: true
additionalProperties: false
SubscriptionStatusSorting:
enum:
- CompanyNameAsc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ public IAsyncEnumerable<AgreementData> GetAppAgreement(Guid appId) =>
_offerService.GetOfferDocumentContentAsync(appId, documentId, _settings.AppImageDocumentTypeIds, OfferTypeId.APP, cancellationToken);

/// <inheritdoc />
public Task<AppProviderSubscriptionDetailData> GetSubscriptionDetailForProvider(Guid appId, Guid subscriptionId) =>
_offerService.GetAppSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, _settings.CompanyAdminRoles, new WalletConfigData(_settings.IssuerDid, _settings.BpnDidResolverUrl, _settings.DecentralIdentityManagementAuthUrl));
public Task<OfferProviderSubscriptionDetailData> GetSubscriptionDetailForProvider(Guid appId, Guid subscriptionId) =>
_offerService.GetOfferSubscriptionDetailsForProviderAsync(appId, subscriptionId, OfferTypeId.APP, _settings.CompanyAdminRoles, new WalletConfigData(_settings.IssuerDid, _settings.BpnDidResolverUrl, _settings.DecentralIdentityManagementAuthUrl));

/// <inheritdoc />
public Task<SubscriberSubscriptionDetailData> GetSubscriptionDetailForSubscriber(Guid appId, Guid subscriptionId) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public interface IAppsBusinessLogic
/// <param name="appId">Id of the app</param>
/// <param name="subscriptionId">Id of the subscription</param>
/// <returns>Returns the details of the subscription</returns>
Task<AppProviderSubscriptionDetailData> GetSubscriptionDetailForProvider(Guid appId, Guid subscriptionId);
Task<OfferProviderSubscriptionDetailData> GetSubscriptionDetailForProvider(Guid appId, Guid subscriptionId);

/// <summary>
/// Gets the information for the subscription
Expand Down
4 changes: 2 additions & 2 deletions src/marketplace/Apps.Service/Controllers/AppsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ public async Task<FileResult> GetAppDocumentContentAsync([FromRoute] Guid appId,
[Authorize(Roles = "app_management")]
[Authorize(Policy = PolicyTypes.ValidCompany)]
[Route("{appId}/subscription/{subscriptionId}/provider")]
[ProducesResponseType(typeof(AppProviderSubscriptionDetailData), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(OfferProviderSubscriptionDetailData), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
[PublicUrl(CompanyRoleId.APP_PROVIDER)]
public Task<AppProviderSubscriptionDetailData> GetSubscriptionDetailForProvider([FromRoute] Guid appId, [FromRoute] Guid subscriptionId) =>
public Task<OfferProviderSubscriptionDetailData> GetSubscriptionDetailForProvider([FromRoute] Guid appId, [FromRoute] Guid subscriptionId) =>
_appsBusinessLogic.GetSubscriptionDetailForProvider(appId, subscriptionId);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using System.Text.Json.Serialization;

namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models;

/// <summary>
/// Detail data for a offer subscription
/// </summary>
/// <param name="Id">Id of the Offer</param>
/// <param name="OfferSubscriptionStatus">Status of the offer subscription</param>
/// <param name="Name">Name of the Offer</param>
/// <param name="Customer">Name of the company subscribing the offer</param>
/// <param name="Bpn">When called from /provider bpn of the company subscribing the offer, otherwise the provider company's bpn</param>
/// <param name="Contact">When called from /provider the company admins of the subscribing company, otherwise the salesmanagers of the offer provider</param>
/// <param name="TechnicalUserData">Information about the technical user</param>
/// <param name="TenantUrl">Url of Tenant</param>
/// <param name="AppInstanceId">Id of the app instance</param>
public record OfferProviderSubscriptionDetailData(
Guid Id,
OfferSubscriptionStatusId OfferSubscriptionStatus,
string? Name,
string Customer,
string? Bpn,
IEnumerable<string> Contact,
IEnumerable<SubscriptionTechnicalUserData> TechnicalUserData,
IEnumerable<SubscriptionAssignedConnectorData> ConnectorData,
string? TenantUrl,
string? AppInstanceId,
ProcessStepTypeId? ProcessStepTypeId,
SubscriptionExternalServiceData ExternalService
);
public record SubscriptionExternalServiceData(
[property: JsonPropertyName("trusted_issuer")] string TrustedIssuer,
[property: JsonPropertyName("participant_id")] string? ParticipantId,
[property: JsonPropertyName("iatp_id")] string? IatpId,
[property: JsonPropertyName("did_resolver")] string DidResolver,
[property: JsonPropertyName("decentralIdentityManagementAuthUrl")] string DecentralIdentityManagementAuthUrl,
[property: JsonPropertyName("decentralIdentityManagementServiceUrl")] string? DecentralIdentityManagementServiceUrl
);
12 changes: 1 addition & 11 deletions src/marketplace/Offers.Library/Service/IOfferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,6 @@ Task CreateOrUpdateOfferSubscriptionAgreementConsentAsync(Guid subscriptionId,
/// <param name="technicalUserProfileClient">Client to get the technicalUserProfiles</param>
Task UpdateTechnicalUserProfiles(Guid offerId, OfferTypeId offerTypeId, IEnumerable<TechnicalUserProfileData> data, string technicalUserProfileClient);

/// <summary>
/// Gets the information for the subscription for the provider
/// </summary>
/// <param name="offerId">Id of the offer</param>
/// <param name="subscriptionId">Id of the subscription</param>
/// <param name="offerTypeId">Offer type</param>
/// <param name="contactUserRoles">The roles of the users that will be listed as contact</param>
/// <returns>Returns the details of the subscription</returns>
Task<ProviderSubscriptionDetailData> GetSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable<UserRoleConfig> contactUserRoles);

/// <summary>
/// Gets the information for the subscription for the subscriber
/// </summary>
Expand Down Expand Up @@ -254,7 +244,7 @@ Task CreateOrUpdateOfferSubscriptionAgreementConsentAsync(Guid subscriptionId,
/// <param name="contactUserRoles">The roles of the users that will be listed as contact</param>
/// <param name="walletData">The information for the external service data</param>
/// <returns>Returns the details of the subscription</returns>
Task<AppProviderSubscriptionDetailData> GetAppSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable<UserRoleConfig> contactUserRoles, WalletConfigData walletData);
Task<OfferProviderSubscriptionDetailData> GetOfferSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable<UserRoleConfig> contactUserRoles, WalletConfigData walletData);

/// <summary>
/// Unsubscribe the Offer subscription by subscriptionId
Expand Down
10 changes: 3 additions & 7 deletions src/marketplace/Offers.Library/Service/OfferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -788,16 +788,12 @@ public async Task UpdateTechnicalUserProfiles(Guid offerId, OfferTypeId offerTyp
}

/// <inheritdoc />
public Task<ProviderSubscriptionDetailData> GetSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable<UserRoleConfig> contactUserRoles) =>
GetOfferSubscriptionDetailsInternal(offerId, subscriptionId, offerTypeId, contactUserRoles, OfferCompanyRole.Provider, portalRepositories.GetInstance<IOfferSubscriptionsRepository>().GetSubscriptionDetailsForProviderAsync);

/// <inheritdoc />
public async Task<AppProviderSubscriptionDetailData> GetAppSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable<UserRoleConfig> contactUserRoles, WalletConfigData walletData)
public async Task<OfferProviderSubscriptionDetailData> GetOfferSubscriptionDetailsForProviderAsync(Guid offerId, Guid subscriptionId, OfferTypeId offerTypeId, IEnumerable<UserRoleConfig> contactUserRoles, WalletConfigData walletData)
{
var data = await GetOfferSubscriptionDetailsInternal(offerId, subscriptionId, offerTypeId, contactUserRoles, OfferCompanyRole.Provider, portalRepositories.GetInstance<IOfferSubscriptionsRepository>().GetAppSubscriptionDetailsForProviderAsync)
var data = await GetOfferSubscriptionDetailsInternal(offerId, subscriptionId, offerTypeId, contactUserRoles, OfferCompanyRole.Provider, portalRepositories.GetInstance<IOfferSubscriptionsRepository>().GetOfferSubscriptionDetailsForProviderAsync)
.ConfigureAwait(ConfigureAwaitOptions.None);

return new AppProviderSubscriptionDetailData(
return new OfferProviderSubscriptionDetailData(
data.Id,
data.OfferSubscriptionStatus,
data.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,22 @@ private static IEnumerable<OfferStatusId> GetOfferStatusIds(ServiceStatusIdFilte
}

/// <inheritdoc />
public Task<ProviderSubscriptionDetailData> GetSubscriptionDetailForProvider(Guid serviceId, Guid subscriptionId) =>
_offerService.GetSubscriptionDetailsForProviderAsync(serviceId, subscriptionId, OfferTypeId.SERVICE, _settings.CompanyAdminRoles);
public async Task<ProviderSubscriptionDetailData> GetSubscriptionDetailForProvider(Guid serviceId, Guid subscriptionId)
{
var offerSubscriptionDetails = await _offerService.GetOfferSubscriptionDetailsForProviderAsync(serviceId, subscriptionId, OfferTypeId.SERVICE, _settings.CompanyAdminRoles, new WalletConfigData(_settings.IssuerDid, _settings.BpnDidResolverUrl, _settings.DecentralIdentityManagementAuthUrl)).ConfigureAwait(ConfigureAwaitOptions.None);
return new(
offerSubscriptionDetails.Id,
offerSubscriptionDetails.OfferSubscriptionStatus,
offerSubscriptionDetails.Name,
offerSubscriptionDetails.Customer,
offerSubscriptionDetails.Bpn,
offerSubscriptionDetails.Contact,
offerSubscriptionDetails.TechnicalUserData,
offerSubscriptionDetails.ConnectorData,
offerSubscriptionDetails.ProcessStepTypeId,
offerSubscriptionDetails.ExternalService
);
}

/// <inheritdoc />
public Task<SubscriberSubscriptionDetailData> GetSubscriptionDetailForSubscriber(Guid serviceId, Guid subscriptionId) =>
Expand Down
9 changes: 9 additions & 0 deletions src/marketplace/Services.Service/ServiceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ public class ServiceSettings
[Required]
[DistinctValues("x => x.ClientId")]
public IEnumerable<UserRoleConfig> DimUserRoles { get; set; } = null!;

[Required(AllowEmptyStrings = true)]
public string DecentralIdentityManagementAuthUrl { get; set; } = null!;

[Required(AllowEmptyStrings = true)]
public string IssuerDid { get; set; } = null!;

[Required(AllowEmptyStrings = true)]
public string BpnDidResolverUrl { get; set; } = null!;
}

public static class ServiceSettingsExtension
Expand Down
Loading

0 comments on commit cf3aa20

Please sign in to comment.