Skip to content

Commit

Permalink
fix(name): return clientClientId instead of serviceAccount name (#380)
Browse files Browse the repository at this point in the history
Return clientClientId instead of the serviceAccount name for endpoint: GET /api/Services/{serviceId}/subscription/{subscriptionID}/provider
-------------------------
Refs: CPLP-3505
Reviewed-By: Phil Schneider <[email protected]>
  • Loading branch information
AnuragNagpure authored Dec 12, 2023
1 parent f73c0f7 commit d20c582
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;

public record SubscriptionTechnicalUserData(
Guid Id,
string Name,
string? Name,
IEnumerable<string> Permissions
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public OfferSubscription AttachAndModifyOfferSubscription(Guid offerSubscription
x.Company!.Name,
x.Company.BusinessPartnerNumber,
x.Company.Identities.Where(x => x.IdentityTypeId == IdentityTypeId.COMPANY_USER).Select(i => i.CompanyUser!).Where(cu => cu.Email != null && cu.Identity!.IdentityAssignedRoles.Select(ur => ur.UserRole!).Any(ur => userRoleIds.Contains(ur.Id))).Select(cu => cu.Email!),
x.Subscription.CompanyServiceAccounts.Select(sa => new SubscriptionTechnicalUserData(sa.Id, sa.Name, sa.Identity!.IdentityAssignedRoles.Select(ur => ur.UserRole!).Select(ur => ur.UserRoleText))))
x.Subscription.CompanyServiceAccounts.Select(sa => new SubscriptionTechnicalUserData(sa.Id, sa.ClientClientId, sa.Identity!.IdentityAssignedRoles.Select(ur => ur.UserRole!).Select(ur => ur.UserRoleText))))
: null))
.SingleOrDefaultAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ public async Task GetSubscriptionDetailForProviderAsync_ReturnsExpected()
x.Name == "SDE with EDC" &&
x.Customer == "Catena-X" &&
x.Contact.SequenceEqual(new[] { "[email protected]" }) &&
x.OfferSubscriptionStatus == OfferSubscriptionStatusId.ACTIVE);
x.OfferSubscriptionStatus == OfferSubscriptionStatusId.ACTIVE
&& x.TechnicalUserData.All(x => x.Id == new Guid("d0c8ae19-d4f3-49cc-9cb4-6c766d4680f2") && x.Name == "sa-x-4"));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"description": "SA for offer subscription",
"company_service_account_type_id": 2,
"offer_subscription_id": "3DE6A31F-A5D1-4F60-AA3A-4B1A769BECBF",
"company_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87"
"company_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87",
"client_client_id":"sa-x-4"
},
{
"id": "d0c8ae19-d4f3-49cc-9cb4-6c766d4680f3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,10 @@
"identity_id": "8b42e6de-7b59-4217-a63c-198e83d93776",
"user_role_id": "aabcdfeb-6669-4c74-89f0-19cda090873e",
"last_editor_id": null
} ,
{
"identity_id": "d0c8ae19-d4f3-49cc-9cb4-6c766d4680f2",
"user_role_id": "aabcdfeb-6669-4c74-89f0-19cda090873e",
"last_editor_id": null
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public async Task GetNextServiceAccountsWithoutUserEntityId_ReturnsExpectedResul
results.Should().HaveCount(2)
.And.Satisfy(
x => x.ClientClientId == "sa-x-2" && x.ServiceAccountId == new Guid("93eecd4e-ca47-4dd2-85bf-775ea72eb009"),
x => x.ClientClientId == "sa-x-1" && x.ServiceAccountId == new Guid("d0c8ae19-d4f3-49cc-9cb4-6c766d4680f4"));
x => x.ClientClientId == "sa-x-4" && x.ServiceAccountId == new Guid("d0c8ae19-d4f3-49cc-9cb4-6c766d4680f2"));
}

#endregion
Expand Down

0 comments on commit d20c582

Please sign in to comment.