From c59ef5fefc39bef932c08e75ab400f3093bfe56d Mon Sep 17 00:00:00 2001 From: VPrasannaK94 Date: Thu, 27 Jul 2023 16:52:02 +0530 Subject: [PATCH 1/2] fix: resolved apps-business endpoint empty results Ref: CPLP-3048 --- .../Apps.Service/BusinessLogic/AppsBusinessLogic.cs | 4 ++-- .../Apps.Service/BusinessLogic/IAppsBusinessLogic.cs | 4 ++-- src/marketplace/Apps.Service/Controllers/AppsController.cs | 2 +- .../Apps.Service.Tests/Controllers/AppsControllerTests.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs index 5457d95358..1406a84305 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs @@ -85,9 +85,9 @@ public IAsyncEnumerable GetAllActiveAppsAsync(string? languageShortName app.UseCaseNames)); /// - public IAsyncEnumerable GetAllUserUserBusinessAppsAsync(Guid companyId) => + public IAsyncEnumerable GetAllUserUserBusinessAppsAsync(Guid userId) => _portalRepositories.GetInstance() - .GetAllBusinessAppDataForUserIdAsync(companyId) + .GetAllBusinessAppDataForUserIdAsync(userId) .Select(x => new BusinessAppData( x.OfferId, diff --git a/src/marketplace/Apps.Service/BusinessLogic/IAppsBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/IAppsBusinessLogic.cs index bf69e52ef0..eddfea0c13 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/IAppsBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/IAppsBusinessLogic.cs @@ -41,9 +41,9 @@ public interface IAppsBusinessLogic /// /// Get all apps that a user has been assigned roles in. /// - /// Id of the user to get available apps for. + /// Id of the user to get available apps for. /// List of available apps for user. - public IAsyncEnumerable GetAllUserUserBusinessAppsAsync(Guid companyId); + public IAsyncEnumerable GetAllUserUserBusinessAppsAsync(Guid userId); /// /// Get detailed application data for a single app by id. diff --git a/src/marketplace/Apps.Service/Controllers/AppsController.cs b/src/marketplace/Apps.Service/Controllers/AppsController.cs index 4588c1e182..13068a1068 100644 --- a/src/marketplace/Apps.Service/Controllers/AppsController.cs +++ b/src/marketplace/Apps.Service/Controllers/AppsController.cs @@ -78,7 +78,7 @@ public IAsyncEnumerable GetAllActiveAppsAsync([FromQuery] string? lang [ProducesResponseType(typeof(IAsyncEnumerable), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)] public IAsyncEnumerable GetAllBusinessAppsForCurrentUserAsync() => - this.WithCompanyId(companyId => _appsBusinessLogic.GetAllUserUserBusinessAppsAsync(companyId)); + this.WithUserId(userId => _appsBusinessLogic.GetAllUserUserBusinessAppsAsync(userId)); /// /// Retrieves app details for an app referenced by id. diff --git a/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs b/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs index a318c9ff3e..5659085032 100644 --- a/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs +++ b/tests/marketplace/Apps.Service.Tests/Controllers/AppsControllerTests.cs @@ -85,7 +85,7 @@ public async Task GetAllBusinessAppsForCurrentUserAsync_ReturnsExpectedCount() var result = await this._controller.GetAllBusinessAppsForCurrentUserAsync().ToListAsync().ConfigureAwait(false); //Assert - A.CallTo(() => _logic.GetAllUserUserBusinessAppsAsync(_identity.CompanyId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.GetAllUserUserBusinessAppsAsync(_identity.UserId)).MustHaveHappenedOnceExactly(); result.Should().HaveCount(5); } From 8dfd780297b098e5087e605837fa90550530852c Mon Sep 17 00:00:00 2001 From: Norbert Truchsess Date: Thu, 27 Jul 2023 22:12:33 +0200 Subject: [PATCH 2/2] fix authorization --- src/marketplace/Apps.Service/Controllers/AppsController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/marketplace/Apps.Service/Controllers/AppsController.cs b/src/marketplace/Apps.Service/Controllers/AppsController.cs index 13068a1068..8cf4f58acf 100644 --- a/src/marketplace/Apps.Service/Controllers/AppsController.cs +++ b/src/marketplace/Apps.Service/Controllers/AppsController.cs @@ -74,7 +74,7 @@ public IAsyncEnumerable GetAllActiveAppsAsync([FromQuery] string? lang [HttpGet] [Route("business")] [Authorize(Roles = "view_apps")] - [Authorize(Policy = PolicyTypes.ValidCompany)] + [Authorize(Policy = PolicyTypes.CompanyUser)] [ProducesResponseType(typeof(IAsyncEnumerable), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)] public IAsyncEnumerable GetAllBusinessAppsForCurrentUserAsync() =>