Skip to content

Commit

Permalink
feat(apps): allow app release submit with no technicaluser profile (#566
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AnuragNagpure authored Mar 13, 2024
1 parent 5372210 commit bd445bd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 37 deletions.
4 changes: 0 additions & 4 deletions src/marketplace/Offers.Library/Service/OfferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,6 @@ public async Task SubmitOfferAsync(Guid offerId, OfferTypeId offerTypeId, IEnume
{
throw new ConflictException("The app has no roles assigned");
}
if (!offerDetails.HasTechnicalUserProfiles)
{
throw new ConflictException("Technical user profile setup is missing for the app");
}
if (!offerDetails.HasPrivacyPolicies)
{
throw new ConflictException("PrivacyPolicies is missing for the app");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public record OfferReleaseData(
bool IsDescriptionLongNotSet,
bool IsDescriptionShortNotSet,
bool HasUserRoles,
bool HasTechnicalUserProfiles,
bool HasPrivacyPolicies,
IEnumerable<(Guid DocumentId, DocumentStatusId StatusId, DocumentTypeId DocumentTypeId)> DocumentDatas
);
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ public void RemoveAppLanguages(IEnumerable<(Guid appId, string languageShortName
o.OfferDescriptions.Any(description => description.DescriptionLong == ""),
o.OfferDescriptions.Any(description => description.DescriptionShort == ""),
o.UserRoles.Any(),
o.TechnicalUserProfiles.Any(tup => tup.TechnicalUserProfileAssignedUserRoles.Any()),
o.OfferAssignedPrivacyPolicies.Any(),
o.Documents.Where(doc => doc.DocumentStatusId == DocumentStatusId.PENDING || doc.DocumentStatusId == DocumentStatusId.LOCKED)
.Select(doc => new ValueTuple<Guid, DocumentStatusId, DocumentTypeId>(doc.Id, doc.DocumentStatusId, doc.DocumentTypeId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public async Task SubmitOffer_WithNotExistingOffer_ThrowsNotFoundException(Offer
public async Task SubmitOffer_WithInvalidOffer_ThrowsConflictException(string? name, string? providerCompanyId, bool isDescriptionLongNotSet, bool isDescriptionShortNotSet, bool hasUserRoles)
{
// Arrange
A.CallTo(() => _offerRepository.GetOfferReleaseDataByIdAsync(A<Guid>._, A<OfferTypeId>._)).Returns(new OfferReleaseData(name, providerCompanyId == null ? null : new Guid(providerCompanyId), _fixture.Create<string>(), isDescriptionLongNotSet, isDescriptionShortNotSet, hasUserRoles, true, true, new[] { (Guid.NewGuid(), DocumentStatusId.PENDING, DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS) }));
A.CallTo(() => _offerRepository.GetOfferReleaseDataByIdAsync(A<Guid>._, A<OfferTypeId>._)).Returns(new OfferReleaseData(name, providerCompanyId == null ? null : new Guid(providerCompanyId), _fixture.Create<string>(), isDescriptionLongNotSet, isDescriptionShortNotSet, hasUserRoles, true, new[] { (Guid.NewGuid(), DocumentStatusId.PENDING, DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS) }));

// Act
async Task Act() => await _sut.SubmitOfferAsync(Guid.NewGuid(), _fixture.Create<OfferTypeId>(), _fixture.CreateMany<NotificationTypeId>(1), _fixture.CreateMany<UserRoleConfig>(), new[] { DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS }).ConfigureAwait(false);
Expand Down Expand Up @@ -702,7 +702,6 @@ public async Task SubmitOffer_WithValidOfferData_UpdatesAppAndSendsNotification(
.With(x => x.IsDescriptionLongNotSet, false)
.With(x => x.IsDescriptionShortNotSet, false)
.With(x => x.HasPrivacyPolicies, true)
.With(x => x.HasTechnicalUserProfiles, true)
.With(x => x.DocumentDatas, new[] {
(Guid.NewGuid(), DocumentStatusId.PENDING, DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS),
(Guid.NewGuid(), DocumentStatusId.INACTIVE, DocumentTypeId.APP_LEADIMAGE),
Expand Down Expand Up @@ -754,29 +753,6 @@ public async Task SubmitOffer_WithValidOfferData_UpdatesAppAndSendsNotification(
A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly();
}

[Fact]
public async Task SubmitOffer_WithInvalidTechnicalUserProfiles_ThrowsConflictException()
{
// Arrange
var data = _fixture.Build<OfferReleaseData>()
.With(x => x.IsDescriptionLongNotSet, false)
.With(x => x.IsDescriptionShortNotSet, false)
.With(x => x.HasUserRoles, true)
.With(x => x.HasTechnicalUserProfiles, false)
.With(x => x.DocumentDatas, new[] { (Guid.NewGuid(), DocumentStatusId.PENDING, DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS) })
.Create();

A.CallTo(() => _offerRepository.GetOfferReleaseDataByIdAsync(A<Guid>._, A<OfferTypeId>._)).Returns(data);
var sut = new OfferService(_portalRepositories, null!, null!, _identityService, _offerSetupService, _logger);

// Act
async Task Act() => await sut.SubmitOfferAsync(Guid.NewGuid(), _fixture.Create<OfferTypeId>(), _fixture.CreateMany<NotificationTypeId>(1), _fixture.CreateMany<UserRoleConfig>(), new[] { DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS }).ConfigureAwait(false);

// Assert
var result = await Assert.ThrowsAsync<ConflictException>(Act).ConfigureAwait(false);
result.Message.Should().StartWith("Technical user profile setup is missing for the app");
}

[Fact]
public async Task SubmitOffer_WithInvalidPrivacyPolicies_ThrowsConflictException()
{
Expand All @@ -785,7 +761,6 @@ public async Task SubmitOffer_WithInvalidPrivacyPolicies_ThrowsConflictException
.With(x => x.IsDescriptionLongNotSet, false)
.With(x => x.IsDescriptionShortNotSet, false)
.With(x => x.HasUserRoles, true)
.With(x => x.HasTechnicalUserProfiles, true)
.With(x => x.HasPrivacyPolicies, false)
.With(x => x.DocumentDatas, new[] { (Guid.NewGuid(), DocumentStatusId.PENDING, DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS) })
.Create();
Expand Down Expand Up @@ -985,7 +960,7 @@ public async Task SubmitService_WithNotExistingOffer_ThrowsNotFoundException(Off
public async Task SubmitService_WithInvalidOffer_ThrowsConflictException(string? name, string? providerCompanyId, bool isDescriptionLongNotSet, bool isDescriptionShortNotSet, bool hasUserRoles)
{
// Arrange
A.CallTo(() => _offerRepository.GetOfferReleaseDataByIdAsync(A<Guid>._, A<OfferTypeId>._)).Returns(new OfferReleaseData(name, providerCompanyId == null ? null : new Guid(providerCompanyId), _fixture.Create<string>(), isDescriptionLongNotSet, isDescriptionShortNotSet, hasUserRoles, true, true, new[] { (Guid.NewGuid(), DocumentStatusId.PENDING, DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS) }));
A.CallTo(() => _offerRepository.GetOfferReleaseDataByIdAsync(A<Guid>._, A<OfferTypeId>._)).Returns(new OfferReleaseData(name, providerCompanyId == null ? null : new Guid(providerCompanyId), _fixture.Create<string>(), isDescriptionLongNotSet, isDescriptionShortNotSet, hasUserRoles, true, new[] { (Guid.NewGuid(), DocumentStatusId.PENDING, DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS) }));

// Act
async Task Act() => await _sut.SubmitServiceAsync(Guid.NewGuid(), _fixture.Create<OfferTypeId>(), _fixture.CreateMany<NotificationTypeId>(1), _fixture.CreateMany<UserRoleConfig>()).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,9 @@ public async Task CreateUpdateDeleteOfferDescriptions_Deleted_ReturnsExpectedRes
#region GetOfferReleaseDataById

[Theory]
[InlineData("99C5FD12-8085-4DE2-ABFD-215E1EE4BAA9", "Test App", "Catena-X", "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", false, false)]
[InlineData("99C5FD12-8085-4DE2-ABFD-215E1EE4BAA7", "Latest App", "Catena-X", "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", true, true)]
public async Task GetOfferReleaseDataByIdAsync_ReturnsExpected(Guid offerId, string name, string companyName, Guid companyId, bool hasTechnicalUserProfiles, bool hasPrivacyPolicies)
[InlineData("99C5FD12-8085-4DE2-ABFD-215E1EE4BAA9", "Test App", "Catena-X", "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", false)]
[InlineData("99C5FD12-8085-4DE2-ABFD-215E1EE4BAA7", "Latest App", "Catena-X", "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", true)]
public async Task GetOfferReleaseDataByIdAsync_ReturnsExpected(Guid offerId, string name, string companyName, Guid companyId, bool hasPrivacyPolicies)
{
// Arrange
var sut = await CreateSut().ConfigureAwait(false);
Expand All @@ -838,7 +838,6 @@ public async Task GetOfferReleaseDataByIdAsync_ReturnsExpected(Guid offerId, str
result!.CompanyName.Should().Be(companyName);
result!.ProviderCompanyId.Should().Be(companyId);
result.HasPrivacyPolicies.Should().Be(hasPrivacyPolicies);
result.HasTechnicalUserProfiles.Should().Be(hasTechnicalUserProfiles);
}

#endregion
Expand Down

0 comments on commit bd445bd

Please sign in to comment.