diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a3832c3cd..33da10bdd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ New features, fixed bugs, known defects and other noteworthy changes to each release of the Catena-X Portal Backend. +## 1.6.0-RC8 + +### Change +* Administration Service + * remove PUT: users/{companyUserId}/resetpassword +* Marketplace Service: + * add GET: /api/apps/owncompany/activesubscriptions + * add GET: /api/Apps/owncompany/subscriptions + +### Technical Support +* Iam Seeding + * change base image from aspnet to runtime + * change name in Docker Hub notice +* Migration Jobs + * change base image from aspnet to runtime +* All Services + * add missing file headers + ## 1.6.0-RC7 ### Change diff --git a/docker/Dockerfile-iam-seeding b/docker/Dockerfile-iam-seeding index a22f369aca..9bdee0530a 100644 --- a/docker/Dockerfile-iam-seeding +++ b/docker/Dockerfile-iam-seeding @@ -17,7 +17,7 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base +FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine AS base FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build WORKDIR / diff --git a/docker/Dockerfile-portal-migrations b/docker/Dockerfile-portal-migrations index 04f73b1dd4..ceb233b64f 100644 --- a/docker/Dockerfile-portal-migrations +++ b/docker/Dockerfile-portal-migrations @@ -17,7 +17,7 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base +FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine AS base FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build WORKDIR / diff --git a/docker/Dockerfile-provisioning-migrations b/docker/Dockerfile-provisioning-migrations index 9e7a44ff10..0e48c32055 100644 --- a/docker/Dockerfile-provisioning-migrations +++ b/docker/Dockerfile-provisioning-migrations @@ -17,7 +17,7 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base +FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine AS base FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build WORKDIR / diff --git a/docker/notice-iam-seeding.md b/docker/notice-iam-seeding.md index cf19ebf822..f0a43e64df 100644 --- a/docker/notice-iam-seeding.md +++ b/docker/notice-iam-seeding.md @@ -4,7 +4,7 @@ DockerHub: [https://hub.docker.com/r/tractusx/portal-iam-seeding](https://hub.do Eclipse Tractus-X product(s) installed within the image: -__Portal Checklist Worker__ +__Portal IAM Seeding job__ - GitHub: https://github.com/eclipse-tractusx/portal-backend - Project home: https://projects.eclipse.org/projects/automotive.tractusx diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d0671e5510..ba237f9bc5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -21,6 +21,6 @@ 1.6.0 - RC7 + RC8 diff --git a/src/administration/Administration.Service/Controllers/UserController.cs b/src/administration/Administration.Service/Controllers/UserController.cs index d456c42f2b..ab44558c89 100644 --- a/src/administration/Administration.Service/Controllers/UserController.cs +++ b/src/administration/Administration.Service/Controllers/UserController.cs @@ -442,13 +442,6 @@ public Task UpdateOwnUserDetails([FromRoute] Guid companyUse public Task DeleteOwnUser([FromRoute] Guid companyUserId) => this.WithUserId(userId => _logic.DeleteOwnUserAsync(companyUserId, userId)); - [Obsolete("to be replaced by endpoint /user/owncompany/users/{companyUserId}/resetPassword. remove as soon frontend is adjusted")] - [HttpPut] - [Authorize(Roles = "modify_user_account")] - [Route("users/{companyUserId}/resetpassword")] - public Task ResetUserPassword([FromRoute] Guid companyUserId) => - this.WithUserIdAndCompanyId(identity => _logic.ExecuteOwnCompanyUserPasswordReset(companyUserId, identity)); - /// /// Get for given app id all the company assigned users /// diff --git a/src/administration/Administration.Service/Models/SsiCertificateData.cs b/src/administration/Administration.Service/Models/SsiCertificateData.cs index 6678259b73..86dd817b51 100644 --- a/src/administration/Administration.Service/Models/SsiCertificateData.cs +++ b/src/administration/Administration.Service/Models/SsiCertificateData.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; diff --git a/src/externalsystems/Bpdm.Library/Models/BpdmSharingState.cs b/src/externalsystems/Bpdm.Library/Models/BpdmSharingState.cs index 78da8a3c0c..dc6086a8a8 100644 --- a/src/externalsystems/Bpdm.Library/Models/BpdmSharingState.cs +++ b/src/externalsystems/Bpdm.Library/Models/BpdmSharingState.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + namespace Org.Eclipse.TractusX.Portal.Backend.Bpdm.Library.Models; public record BpdmPaginationSharingStateOutput( diff --git a/src/framework/Framework.Seeding/JsonHelper/SnakeCaseNamingPolicy.cs b/src/framework/Framework.Seeding/JsonHelper/SnakeCaseNamingPolicy.cs index 34691bb8db..1793437ac2 100644 --- a/src/framework/Framework.Seeding/JsonHelper/SnakeCaseNamingPolicy.cs +++ b/src/framework/Framework.Seeding/JsonHelper/SnakeCaseNamingPolicy.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 Newtonsoft.Json.Serialization; using System.Text.Json; diff --git a/src/framework/Framework.Token/GetTokenSettings.cs b/src/framework/Framework.Token/GetTokenSettings.cs index 14339a87f7..800c6ad586 100644 --- a/src/framework/Framework.Token/GetTokenSettings.cs +++ b/src/framework/Framework.Token/GetTokenSettings.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + namespace Org.Eclipse.TractusX.Portal.Backend.Framework.Token; public record GetTokenSettings(string HttpClientName, string Username, string Password, string ClientId, string GrantType, string ClientSecret, string Scope); diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs index 2eb532655b..e80b0be8d5 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs @@ -273,4 +273,12 @@ public Task GetSubscriptionDetailForProvider( /// public Task GetSubscriptionDetailForSubscriber(Guid appId, Guid subscriptionId, Guid companyId) => _offerService.GetSubscriptionDetailsForSubscriberAsync(appId, subscriptionId, companyId, OfferTypeId.APP, _settings.SalesManagerRoles); + + /// + public IAsyncEnumerable GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync(Guid companyId) => + _portalRepositories.GetInstance().GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync(companyId, OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE); + + /// + public IAsyncEnumerable GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync(Guid companyId) => + _portalRepositories.GetInstance().GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync(companyId, OfferTypeId.APP); } diff --git a/src/marketplace/Apps.Service/BusinessLogic/IAppsBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/IAppsBusinessLogic.cs index a8988ed175..6e4de9a33b 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/IAppsBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/IAppsBusinessLogic.cs @@ -180,4 +180,18 @@ public interface IAppsBusinessLogic /// Id of the users company /// Returns the details of the subscription Task GetSubscriptionDetailForSubscriber(Guid appId, Guid subscriptionId, Guid companyId); + + /// + /// Retrieves Active subscription statuses of subscribed apps of the provided user's company. + /// + /// Id of the users company. + /// Returns the details of the Active subscription status for App user + IAsyncEnumerable GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync(Guid companyId); + + /// + /// Retrieves Active and Pending subscription statuses of subscribed apps of the provided user's company. + /// + /// Id of the users company. + /// Returns the details of the Active and Pending subscription status for App user + IAsyncEnumerable GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync(Guid companyId); } diff --git a/src/marketplace/Apps.Service/Controllers/AppsController.cs b/src/marketplace/Apps.Service/Controllers/AppsController.cs index f1e2f9a49c..9b47bba273 100644 --- a/src/marketplace/Apps.Service/Controllers/AppsController.cs +++ b/src/marketplace/Apps.Service/Controllers/AppsController.cs @@ -405,4 +405,35 @@ public Task GetSubscriptionDetailForProvider( [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] public Task GetSubscriptionDetailForSubscriber([FromRoute] Guid appId, [FromRoute] Guid subscriptionId) => this.WithCompanyId(companyId => _appsBusinessLogic.GetSubscriptionDetailForSubscriber(appId, subscriptionId, companyId)); + + /// + /// Retrieves Active subscription statuses of apps. + /// + /// Example: GET: /api/apps/subscribed/activesubscriptions + /// Returns list of applicable active apps subscription statuses. + /// If sub claim is empty/invalid or user does not exist. + [HttpGet] + [Route("subscribed/activesubscriptions")] + [Authorize(Roles = "view_subscription")] + [Authorize(Policy = PolicyTypes.ValidCompany)] + [ProducesResponseType(typeof(ActiveOfferSubscriptionStatusData), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)] + public IAsyncEnumerable GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync() => + this.WithCompanyId(companyId => _appsBusinessLogic.GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync(companyId)); + + /// + /// Retrieves subscription statuses of apps. + /// + /// Example: GET: /api/apps/subscribed/subscriptions + /// Returns list of applicable active apps subscription statuses. + /// If sub claim is empty/invalid or user does not exist. + [HttpGet] + [Route("subscribed/subscriptions")] + [Authorize(Roles = "view_subscription")] + [Authorize(Policy = PolicyTypes.ValidCompany)] + [ProducesResponseType(typeof(OfferSubscriptionData), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)] + public IAsyncEnumerable GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync() => + this.WithCompanyId(companyId => _appsBusinessLogic.GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync(companyId)); + } diff --git a/src/marketplace/Apps.Service/Extensions/AppExtensions.cs b/src/marketplace/Apps.Service/Extensions/AppExtensions.cs index 63559249bd..2914deaaff 100644 --- a/src/marketplace/Apps.Service/Extensions/AppExtensions.cs +++ b/src/marketplace/Apps.Service/Extensions/AppExtensions.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Apps.Service.ViewModels; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; diff --git a/src/marketplace/Offers.Library/Models/OfferDeclineRequest.cs b/src/marketplace/Offers.Library/Models/OfferDeclineRequest.cs index 01b2bd907f..dd996515c3 100644 --- a/src/marketplace/Offers.Library/Models/OfferDeclineRequest.cs +++ b/src/marketplace/Offers.Library/Models/OfferDeclineRequest.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 System.Text.Json.Serialization; namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/AppUseCaseData.cs b/src/portalbackend/PortalBackend.DBAccess/Models/AppUseCaseData.cs index bb19a2134b..a1ff192b28 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/AppUseCaseData.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/AppUseCaseData.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; public record AppUseCaseData(Guid Id, string Label); diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/OfferDocumentContentData.cs b/src/portalbackend/PortalBackend.DBAccess/Models/OfferDocumentContentData.cs index 19a2649824..6d66d56b82 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/OfferDocumentContentData.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/OfferDocumentContentData.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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; namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/OfferSubscriptionStatusData.cs b/src/portalbackend/PortalBackend.DBAccess/Models/OfferSubscriptionStatusData.cs index ca45f8debf..911c0360b1 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/OfferSubscriptionStatusData.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/OfferSubscriptionStatusData.cs @@ -19,6 +19,7 @@ ********************************************************************************/ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using System.Text.Json.Serialization; namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; @@ -28,12 +29,36 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; /// Id of the Offer /// Name of the Offer /// When called from /provider name of the company subscribing the offer, otherwise the provider company's name -/// Status of the offer subscription +/// Status of the offer subscription /// Id of the documents public record OfferSubscriptionStatusData( - Guid OfferId, - string? OfferName, - string Provider, - OfferSubscriptionStatusId OfferSubscriptionStatusId, - Guid? DocumentId + [property: JsonPropertyName("offerId")] Guid OfferId, + [property: JsonPropertyName("name")] string? OfferName, + [property: JsonPropertyName("provider")] string Provider, + [property: JsonPropertyName("status")] OfferSubscriptionStatusId OfferSubscriptionStatusId, + [property: JsonPropertyName("image")] Guid? DocumentId +); + +/// +/// Offer Subscriptions Status Data +/// +/// Id of the Offer +/// Name of the Offer +/// When called from /provider name of the company subscribing the offer, otherwise the provider company's name +/// Id of the documents +public record ActiveOfferSubscriptionStatusData( + [property: JsonPropertyName("offerId")] Guid OfferId, + [property: JsonPropertyName("name")] string? OfferName, + [property: JsonPropertyName("provider")] string Provider, + [property: JsonPropertyName("image")] Guid? DocumentId +); + +/// +/// Offer Subscription data +/// +/// Id of the Offer +/// Status of the offer subscription +public record OfferSubscriptionData( + [property: JsonPropertyName("offerId")] Guid OfferId, + [property: JsonPropertyName("status")] OfferSubscriptionStatusId OfferSubscriptionStatusId ); diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/OperatorBpnData.cs b/src/portalbackend/PortalBackend.DBAccess/Models/OperatorBpnData.cs index 33615fdcdc..3bf2472f12 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/OperatorBpnData.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/OperatorBpnData.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; public record OperatorBpnData( diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs index e04840a32d..2e751b23da 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/IOfferSubscriptionsRepository.cs @@ -164,4 +164,21 @@ public interface IOfferSubscriptionsRepository IAsyncEnumerable GetProcessStepsForSubscription(Guid offerSubscriptionId); Task<(bool Exists, bool IsOfferProvider, bool OfferSubscriptionAlreadyLinked, OfferSubscriptionStatusId OfferSubscriptionStatus, Guid? SelfDescriptionDocumentId, Guid CompanyId, string? ProviderBpn)> CheckOfferSubscriptionWithOfferProvider(Guid subscriptionId, Guid offerProvidingCompanyId); IAsyncEnumerable GetConnectorOfferSubscriptionData(bool? connectorIdSet, Guid companyId); + + /// + /// Gets the apps Active offer subscription statuses for the user + /// + /// Id of users company + /// Id of the offer type + /// Id of the document type + /// apps offer subscription statuses for the user + IAsyncEnumerable GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync(Guid userCompanyId, OfferTypeId offerTypeId, DocumentTypeId documentTypeId); + + /// + /// Gets the apps offer subscription statuses for the user + /// + /// Id of users company + /// Id of the offer type + /// apps offer subscription statuses for the user + IAsyncEnumerable GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync(Guid userCompanyId, OfferTypeId offerTypeId); } diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs index f03b2ceb1d..58b348f810 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs @@ -504,4 +504,34 @@ public IAsyncEnumerable GetConnectorOfferSubscri os.ConnectorAssignedOfferSubscriptions.Select(c => c.ConnectorId) )) .ToAsyncEnumerable(); + + /// + public IAsyncEnumerable GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync(Guid userCompanyId, OfferTypeId offerTypeId, DocumentTypeId documentTypeId) => + _context.OfferSubscriptions + .AsNoTracking() + .Where(os => + os.Offer!.OfferTypeId == offerTypeId && os.OfferSubscriptionStatusId == OfferSubscriptionStatusId.ACTIVE && + os.CompanyId == userCompanyId) + .Select(os => new ActiveOfferSubscriptionStatusData( + os.OfferId, + os.Offer!.Name, + os.Offer.Provider, + os.Offer.Documents + .Where(document => + document.DocumentTypeId == documentTypeId + && document.DocumentStatusId == DocumentStatusId.LOCKED) + .Select(document => document.Id).FirstOrDefault() + )).ToAsyncEnumerable(); + + /// + public IAsyncEnumerable GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync(Guid userCompanyId, OfferTypeId offerTypeId) => + _context.OfferSubscriptions + .AsNoTracking() + .Where(os => + os.Offer!.OfferTypeId == offerTypeId && os.OfferSubscriptionStatusId != OfferSubscriptionStatusId.INACTIVE && + os.CompanyId == userCompanyId) + .Select(os => new OfferSubscriptionData( + os.OfferId, + os.OfferSubscriptionStatusId + )).ToAsyncEnumerable(); } diff --git a/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230405.cs b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230405.cs index e15393e97f..34fd4b5593 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230405.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230405.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Auditing; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using System.ComponentModel.DataAnnotations; diff --git a/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230503.cs b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230503.cs index f8ace44fd3..95ca008f9f 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230503.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230503.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Auditing; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using System.ComponentModel.DataAnnotations; diff --git a/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230803.cs b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230803.cs index bee876476e..847532b352 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230803.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230803.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Auditing; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using System.ComponentModel.DataAnnotations; diff --git a/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditIdentity20230526.cs b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditIdentity20230526.cs index 97c26dee12..b8e9f40b94 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditIdentity20230526.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditIdentity20230526.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Auditing; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using System.ComponentModel.DataAnnotations; diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/Identity.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/Identity.cs index 7e1f4bf1bb..401086a929 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/Identity.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/Identity.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Auditing; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Base; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscriptionProcessData.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscriptionProcessData.cs index e3d9815a1e..e0ad41e3e7 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscriptionProcessData.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/OfferSubscriptionProcessData.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; public class OfferSubscriptionProcessData diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/VerifiedCredentialExternalType.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/VerifiedCredentialExternalType.cs index 7d0834b63c..869db351a1 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/VerifiedCredentialExternalType.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/VerifiedCredentialExternalType.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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; namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/VerifiedCredentialExternalTypeUseCaseDetailVersion.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/VerifiedCredentialExternalTypeUseCaseDetailVersion.cs index 81169739fe..9ad1bbf7d3 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/VerifiedCredentialExternalTypeUseCaseDetailVersion.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/VerifiedCredentialExternalTypeUseCaseDetailVersion.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Base; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; diff --git a/src/portalbackend/PortalBackend.PortalEntities/Enums/MediaTypeId.cs b/src/portalbackend/PortalBackend.PortalEntities/Enums/MediaTypeId.cs index 0e2b584d30..c8db665208 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Enums/MediaTypeId.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Enums/MediaTypeId.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; public enum MediaTypeId diff --git a/src/portalbackend/PortalBackend.PortalEntities/Enums/VerifiedCredentialExternalTypeId.cs b/src/portalbackend/PortalBackend.PortalEntities/Enums/VerifiedCredentialExternalTypeId.cs index 10b4cc76b8..e4070950c3 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Enums/VerifiedCredentialExternalTypeId.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Enums/VerifiedCredentialExternalTypeId.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 System.Runtime.Serialization; namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; diff --git a/src/provisioning/Provisioning.Library/Extensions/ProtocolMapperSettings.cs b/src/provisioning/Provisioning.Library/Extensions/ProtocolMapperSettings.cs index 8ad296c3e2..2c71fd848c 100644 --- a/src/provisioning/Provisioning.Library/Extensions/ProtocolMapperSettings.cs +++ b/src/provisioning/Provisioning.Library/Extensions/ProtocolMapperSettings.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Library.Models.ProtocolMappers; diff --git a/src/provisioning/Provisioning.Library/Models/CompanyNameIdpAliasData.cs b/src/provisioning/Provisioning.Library/Models/CompanyNameIdpAliasData.cs index 5849839980..7db4c78cc6 100644 --- a/src/provisioning/Provisioning.Library/Models/CompanyNameIdpAliasData.cs +++ b/src/provisioning/Provisioning.Library/Models/CompanyNameIdpAliasData.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + namespace Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; public record CompanyNameIdpAliasData(Guid CompanyId, string CompanyName, string? BusinessPartnerNumber, string IdpAlias, bool IsSharedIdp); diff --git a/tests/administration/Administration.Service.Tests/Usings.cs b/tests/administration/Administration.Service.Tests/Usings.cs index a02813547a..65016aec51 100644 --- a/tests/administration/Administration.Service.Tests/Usings.cs +++ b/tests/administration/Administration.Service.Tests/Usings.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + global using AutoFixture; global using AutoFixture.AutoFakeItEasy; global using FakeItEasy; diff --git a/tests/framework/Framework.Web.Tests/Usings.cs b/tests/framework/Framework.Web.Tests/Usings.cs index a02813547a..65016aec51 100644 --- a/tests/framework/Framework.Web.Tests/Usings.cs +++ b/tests/framework/Framework.Web.Tests/Usings.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + global using AutoFixture; global using AutoFixture.AutoFakeItEasy; global using FakeItEasy; diff --git a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs index 9d26323018..acefda9521 100644 --- a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs +++ b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs @@ -749,4 +749,51 @@ public async Task GetAppDetailsByIdAsync_WithNullProperties_ReturnsExpected() } #endregion + + #region GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync + + [Fact] + public async Task GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync_ReturnsExpected() + { + // Arrange + var identity = _fixture.Create(); + var data = _fixture.CreateMany(5).ToAsyncEnumerable(); + A.CallTo(() => _offerSubscriptionRepository.GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync(A._, A._, A._)) + .Returns(data); + + var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, _fixture.Create>(), _mailingService); + + // Act + var result = await sut.GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync(identity.CompanyId).ToListAsync().ConfigureAwait(false); + + // Assert + result.Should().HaveCount(5); + A.CallTo(() => _offerSubscriptionRepository.GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync(identity.CompanyId, OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE)).MustHaveHappenedOnceExactly(); + } + + #endregion + + #region GetOwnCompanySubscribedAppOfferSubscriptionDataForUser + + [Fact] + public async Task GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync_ReturnsExpected() + { + // Arrange + var identity = _fixture.Create(); + var data = _fixture.CreateMany(5).ToAsyncEnumerable(); + A.CallTo(() => _offerSubscriptionRepository.GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync(A._, A._)) + .Returns(data); + + var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, _fixture.Create>(), _mailingService); + + // Act + var result = await sut.GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync(identity.CompanyId).ToListAsync().ConfigureAwait(false); + + // Assert + result.Should().HaveCount(5); + A.CallTo(() => _offerSubscriptionRepository.GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync(identity.CompanyId, OfferTypeId.APP)).MustHaveHappenedOnceExactly(); + } + + #endregion + } diff --git a/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs b/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs index 47f25a5647..d6027b29d2 100644 --- a/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs +++ b/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs @@ -397,4 +397,45 @@ public async Task GetSubscriptionDetailForSubscriber_ReturnsExpected() A.CallTo(() => _logic.GetSubscriptionDetailForSubscriber(appId, subscriptionId, _identity.CompanyId)).MustHaveHappenedOnceExactly(); result.Should().Be(data); } + + #region GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUser + + [Fact] + public async Task GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync_ReturnsExpectedCount() + { + //Arrange + var data = _fixture.CreateMany(3).ToImmutableArray().ToAsyncEnumerable(); + A.CallTo(() => _logic.GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync(A._)) + .Returns(data); + + //Act + var result = await this._controller.GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync().ToListAsync().ConfigureAwait(false); + + //Assert + A.CallTo(() => _logic.GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync(_identity.CompanyId)).MustHaveHappenedOnceExactly(); + result.Should().HaveCount(3); + } + + #endregion + + #region GetOwnCompanySubscribedAppOfferSubscriptionDataForUser + + [Fact] + public async Task GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync_ReturnsExpectedCount() + { + //Arrange + var data = _fixture.CreateMany(3).ToImmutableArray().ToAsyncEnumerable(); + A.CallTo(() => _logic.GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync(A._)) + .Returns(data); + + //Act + var result = await this._controller.GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync().ToListAsync().ConfigureAwait(false); + + //Assert + A.CallTo(() => _logic.GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync(_identity.CompanyId)).MustHaveHappenedOnceExactly(); + result.Should().HaveCount(3); + } + + #endregion + } diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs index 3607cad41d..ec8ec5f005 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs @@ -2400,8 +2400,8 @@ public async Task GetSubscriptionDetailsForSubscriber_WithValidData_ReturnsExpec #region GetCompanySubscribedOfferSubscriptionStatusesForUser [Theory] - [InlineData(OfferTypeId.SERVICE, DocumentTypeId.SERVICE_LEADIMAGE)] [InlineData(OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE)] + [InlineData(OfferTypeId.SERVICE, DocumentTypeId.SERVICE_LEADIMAGE)] public async Task GetCompanySubscribedOfferSubscriptionStatusesForUserAsync_ReturnsExpected(OfferTypeId offerTypeId, DocumentTypeId documentTypeId) { // Arrange @@ -2426,8 +2426,8 @@ public async Task GetCompanySubscribedOfferSubscriptionStatusesForUserAsync_Retu } [Theory] - [InlineData(OfferTypeId.SERVICE, DocumentTypeId.SERVICE_LEADIMAGE)] [InlineData(OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE)] + [InlineData(OfferTypeId.SERVICE, DocumentTypeId.SERVICE_LEADIMAGE)] public async Task GetCompanySubscribedOfferSubscriptionStatusesForUserAsync_WithQueryNullResult_ReturnsExpected(OfferTypeId offerTypeId, DocumentTypeId documentTypeId) { // Arrange diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/ContentTypeMapperExtensionsTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/ContentTypeMapperExtensionsTests.cs index d6feb6956e..782156e12f 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/ContentTypeMapperExtensionsTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/ContentTypeMapperExtensionsTests.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Extensions; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/InvitationRepositoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/InvitationRepositoryTests.cs index a060ad8650..42faca6e45 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/InvitationRepositoryTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/InvitationRepositoryTests.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Tests.Setup; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs index 6ba40adcc1..901ce426d6 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs @@ -971,23 +971,72 @@ public async Task GetConnectorOfferSubscriptionData_WithoutConnectorIdSet_Return #endregion - #region GetCompanyAssignedOfferSubscriptionDataForCompanyUser + #region GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync [Fact] - public async Task GetCompanyAssignedOfferSubscriptionDataForCompanyUserAsync_ReturnsExpected() + public async Task GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync_ReturnsExpected() { // Arrange var (sut, _) = await CreateSut().ConfigureAwait(false); // Act - var result = await sut.GetCompanyAssignedOfferSubscriptionDataForCompanyUserAsync(new Guid("e8886159-9258-44a5-88d8-f5735a197a09"), new Guid("2dc4249f-b5ca-4d42-bef1-7a7a950a4f87")).ConfigureAwait(false); + var result = await sut.GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync(new Guid("2dc4249f-b5ca-4d42-bef1-7a7a950a4f87"), OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE).ToListAsync().ConfigureAwait(false); // Assert - result.IsSubscribingCompany.Should().BeTrue(); - result.IsValidSubscriptionId.Should().BeTrue(); - result.OfferSubscriptionStatusId.Should().Be(OfferSubscriptionStatusId.PENDING); - result.ConnectorIds.Should().Contain(new Guid("bd644d9c-ca12-4488-ae38-6eb902c9bec0")); - result.ServiceAccounts.Should().BeEmpty(); + result.Should().NotBeNull(); + result.Should().HaveCount(1).And.Satisfy( + x => x.OfferId == new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007") && + x.OfferName == "Trace-X" && + x.Provider == "Catena-X" && + x.DocumentId == new Guid("e020787d-1e04-4c0b-9c06-bd1cd44724b1")); + } + + [Fact] + public async Task GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync_ReturnsEmpty() + { + // Arrange + var (sut, _) = await CreateSut().ConfigureAwait(false); + + // Act + var result = await sut.GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync(Guid.NewGuid(), OfferTypeId.APP, DocumentTypeId.APP_LEADIMAGE).ToListAsync().ConfigureAwait(false); + + // Assert + result.Should().BeEmpty(); + } + + #endregion + + #region GetCompanyActiveSubscribedOfferSubscriptionStatuses + + [Fact] + public async Task GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync_ReturnsExpected() + { + // Arrange + var (sut, _) = await CreateSut().ConfigureAwait(false); + + // Act + var result = await sut.GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync(new Guid("2dc4249f-b5ca-4d42-bef1-7a7a950a4f87"), OfferTypeId.APP).ToListAsync().ConfigureAwait(false); + + // Assert + result.Should().NotBeNull(); + result.Should().HaveCount(2).And.Satisfy( + x => x.OfferId == new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007") && + x.OfferSubscriptionStatusId == OfferSubscriptionStatusId.ACTIVE, + x => x.OfferId == new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007") && + x.OfferSubscriptionStatusId == OfferSubscriptionStatusId.PENDING); + } + + [Fact] + public async Task GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync_ReturnsEmpty() + { + // Arrange + var (sut, _) = await CreateSut().ConfigureAwait(false); + + // Act + var result = await sut.GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync(Guid.NewGuid(), OfferTypeId.APP).ToListAsync().ConfigureAwait(false); + + // Assert + result.Should().BeEmpty(); } #endregion diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/PortalDbContextTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/PortalDbContextTests.cs index b9133d69f0..6193051d14 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/PortalDbContextTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/PortalDbContextTests.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 Microsoft.EntityFrameworkCore; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Tests.Setup; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; diff --git a/tests/provisioning/Provisioning.Library.Tests/FlurlSetup/FlurlSetupExtensions.cs b/tests/provisioning/Provisioning.Library.Tests/FlurlSetup/FlurlSetupExtensions.cs index a3c1244777..f38b866588 100644 --- a/tests/provisioning/Provisioning.Library.Tests/FlurlSetup/FlurlSetupExtensions.cs +++ b/tests/provisioning/Provisioning.Library.Tests/FlurlSetup/FlurlSetupExtensions.cs @@ -1,3 +1,22 @@ +/******************************************************************************** + * 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 Flurl.Http.Testing; using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Library.Models.Clients; using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Library.Models.OpenIDConfiguration;