Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolved apps-business endpoint empty results #172

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public IAsyncEnumerable<AppData> GetAllActiveAppsAsync(string? languageShortName
app.UseCaseNames));

/// <inheritdoc/>
public IAsyncEnumerable<BusinessAppData> GetAllUserUserBusinessAppsAsync(Guid companyId) =>
public IAsyncEnumerable<BusinessAppData> GetAllUserUserBusinessAppsAsync(Guid userId) =>
_portalRepositories.GetInstance<IOfferSubscriptionsRepository>()
.GetAllBusinessAppDataForUserIdAsync(companyId)
.GetAllBusinessAppDataForUserIdAsync(userId)
.Select(x =>
new BusinessAppData(
x.OfferId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public interface IAppsBusinessLogic
/// <summary>
/// Get all apps that a user has been assigned roles in.
/// </summary>
/// <param name="companyId">Id of the user to get available apps for.</param>
/// <param name="userId">Id of the user to get available apps for.</param>
/// <returns>List of available apps for user.</returns>
public IAsyncEnumerable<BusinessAppData> GetAllUserUserBusinessAppsAsync(Guid companyId);
public IAsyncEnumerable<BusinessAppData> GetAllUserUserBusinessAppsAsync(Guid userId);

/// <summary>
/// Get detailed application data for a single app by id.
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 @@ -74,11 +74,11 @@ public IAsyncEnumerable<AppData> GetAllActiveAppsAsync([FromQuery] string? lang
[HttpGet]
[Route("business")]
[Authorize(Roles = "view_apps")]
[Authorize(Policy = PolicyTypes.ValidCompany)]
[Authorize(Policy = PolicyTypes.CompanyUser)]
[ProducesResponseType(typeof(IAsyncEnumerable<BusinessAppData>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
public IAsyncEnumerable<BusinessAppData> GetAllBusinessAppsForCurrentUserAsync() =>
this.WithCompanyId(companyId => _appsBusinessLogic.GetAllUserUserBusinessAppsAsync(companyId));
this.WithUserId(userId => _appsBusinessLogic.GetAllUserUserBusinessAppsAsync(userId));

/// <summary>
/// Retrieves app details for an app referenced by id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading