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(offersubscription): suppress activation of external serviceaccounts on activation of offersubscription #864

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 @@ -712,7 +712,7 @@ private async Task EnableClientAndServiceAccount(Guid offerSubscriptionId, Subsc

try
{
foreach (var serviceAccountClientId in offerDetails.ServiceAccountClientIds)
foreach (var serviceAccountClientId in offerDetails.InternalServiceAccountClientIds)
{
await _provisioningManager.EnableClient(serviceAccountClientId).ConfigureAwait(ConfigureAwaitOptions.None);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ public record SubscriptionActivationData(
Guid? SalesManagerId,
Guid? ProviderCompanyId,
string? ClientClientId,
IEnumerable<string> ServiceAccountClientIds
IEnumerable<string> InternalServiceAccountClientIds
);
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public Task<Guid> GetOfferSubscriptionDataForProcessIdAsync(Guid processId) =>
x.Offer.OfferTypeId == OfferTypeId.APP && (x.Offer.AppInstanceSetup == null || !x.Offer.AppInstanceSetup!.IsSingleInstance) ?
x.AppSubscriptionDetail!.AppInstance!.IamClient!.ClientClientId :
null,
x.CompanyServiceAccounts.Where(sa => sa.ClientClientId != null).Select(sa => sa.ClientClientId!)
x.CompanyServiceAccounts.Where(sa => sa.CompanyServiceAccountKindId == CompanyServiceAccountKindId.INTERNAL && sa.ClientClientId != null).Select(sa => sa.ClientClientId!)
))
.SingleOrDefaultAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ public async Task GetSubscriptionActivationDataByIdAsync_WithValidData_ReturnsEx
result!.OfferName.Should().Be("Trace-X");
result.InstanceData.Should().Be((true, "https://test.com"));
result.Status.Should().Be(OfferSubscriptionStatusId.ACTIVE);
result.InternalServiceAccountClientIds.Should().ContainSingle().Which.Should().Be("sa-os-internal");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task OfferSubscriptionView_GetAll_ReturnsExpected()

// Act
var result = await sut.OfferSubscriptionView.ToListAsync();
result.Should().HaveCount(14);
result.Should().HaveCount(15);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,23 @@
"company_service_account_kind_id": 1,
"offer_subscription_id": null,
"client_client_id": "sa-x-0"
},
{
"id": "a946f314-f53e-4c72-9124-40b72bcc59aa",
"name": "offersubscription-sa-0",
"description": "internal test user for offersubscription",
"company_service_account_type_id": 2,
"company_service_account_kind_id": 1,
"offer_subscription_id": "ed4de48d-fd4b-4384-a72f-ecae3c6cc5ba",
"client_client_id": "sa-os-internal"
},
{
"id": "4ce1b774-3d00-4e07-9a53-ae1f64193392",
"name": "offersubscription-sa-0",
"description": "internal test user for offersubscription",
"company_service_account_type_id": 2,
"company_service_account_kind_id": 2,
"offer_subscription_id": "ed4de48d-fd4b-4384-a72f-ecae3c6cc5ba",
"client_client_id": "sa-os-external"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,23 @@
"user_entity_id": "3d8142f1-860b-48aa-8c2b-1ccb18699f66",
"identity_type_id": 2,
"last_editor_id":"8b42e6de-7b59-4217-a63c-198e83d93777"
},
{
"id": "a946f314-f53e-4c72-9124-40b72bcc59aa",
"date_created": "2024-07-22 18:01:33.439000 +00:00",
"company_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87",
"user_status_id": 1,
"user_entity_id": null,
"identity_type_id": 2,
"last_editor_id":"8b42e6de-7b59-4217-a63c-198e83d93777"
},
{
"id": "4ce1b774-3d00-4e07-9a53-ae1f64193392",
"date_created": "2024-07-22 18:01:33.439000 +00:00",
"company_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87",
"user_status_id": 1,
"user_entity_id": null,
"identity_type_id": 2,
"last_editor_id":"8b42e6de-7b59-4217-a63c-198e83d93777"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -291,23 +291,23 @@ public async Task GetOwnCompanyServiceAccountsUntracked_WithOwnerTrue_ReturnsExp

// Assert
result.Should().NotBeNull();
result!.Count.Should().Be(15);
result!.Count.Should().Be(17);
result.Data.Should().HaveCount(10)
.And.AllSatisfy(x => x.Should().Match<Models.CompanyServiceAccountData>(y =>
y.CompanyServiceAccountTypeId == CompanyServiceAccountTypeId.OWN &&
y.UserStatusId == UserStatusId.ACTIVE))
.And.BeInAscendingOrder(x => x.Name)
.And.Satisfy(
x => x.ServiceAccountId == new Guid("4ce1b774-3d00-4e07-9a53-ae1f64193392"),
x => x.ServiceAccountId == new Guid("a946f314-f53e-4c72-9124-40b72bcc59aa"),
x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201029"),
x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201026"),
x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201027"),
x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201030"),
x => x.ServiceAccountId == new Guid("f3498fe6-e0e5-413b-a725-39bf5c7c1959"),
x => x.ServiceAccountId == new Guid("ab7f01ea-cbb9-4d58-9efa-ea992395f997"),
x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201031"),
x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201032"),
x => x.ServiceAccountId == new Guid("33480038-9acf-40e2-9127-c9c7a9cbed99"),
x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201023"));
x => x.ServiceAccountId == new Guid("7e85a0b8-0001-ab67-10d1-0ef508201032"));
}

[Fact]
Expand Down
Loading