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

FAT-17146-C589233 #4378

Merged
merged 1 commit into from
Oct 22, 2024
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
@@ -0,0 +1,58 @@
import Users from '../../../support/fragments/users/users';

describe('Eureka', () => {
describe('Login', () => {
const selfCallpath = '/users-keycloak/_self?expandPermissions=true*';
const permissionName = 'ui-checkout.all';
let userA;
let userB;
let roleId;
let capabSetId;

const capabSetToAssign = { type: 'Data', resource: 'UI-Checkout', action: 'Manage' };

before('Create user, get data', () => {
cy.getAdminToken();
cy.createTempUser([]).then((userAProperties) => {
userA = userAProperties;
cy.assignCapabilitiesToExistingUser(userA.userId, [], [capabSetToAssign]);
});
cy.createTempUser([]).then((userBProperties) => {
userB = userBProperties;
cy.createAuthorizationRoleApi().then((role) => {
roleId = role.id;
cy.getCapabilitySetIdViaApi(capabSetToAssign).then((setId) => {
capabSetId = setId;
cy.addCapabilitySetsToNewRoleApi(roleId, [capabSetId]);
cy.addRolesToNewUserApi(userB.userId, [roleId]);
});
});
});
});

after('Delete user', () => {
cy.getAdminToken();
Users.deleteViaApi(userA.userId);
Users.deleteViaApi(userB.userId);
cy.deleteAuthorizationRoleApi(roleId);
});

it(
'C589233 Permission associated with assigned capability set is returned from "_self" endpoint upon login (eureka)',
{ tags: ['criticalPath', 'eureka', 'C589233'] },
() => {
cy.intercept('GET', selfCallpath).as('selfCall');
cy.login(userA.username, userA.password);
cy.wait('@selfCall').then((call) => {
expect(call.response.statusCode).to.eq(200);
expect(call.response.body.permissions.permissions).to.include(permissionName);
});
cy.login(userB.username, userB.password);
cy.wait('@selfCall').then((call) => {
expect(call.response.statusCode).to.eq(200);
expect(call.response.body.permissions.permissions).to.include(permissionName);
});
},
);
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/eureka/users/user-entities-cleanup.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Eureka', () => {
'C436914 User-related entities are deleted when user is deleted (eureka)',
{ tags: ['backend', 'eureka', 'eurekaPhase1', 'C436914'] },
() => {
Users.deleteViaApi(testData.user.userId).then((status) => {
Users.deleteViaApi(testData.user.userId, true).then((status) => {
cy.expect(status).equals(204);
cy.getAuthorizationPoliciesForEntityApi(
AUTHORIZATION_POLICY_TYPES.USER,
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/fragments/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ export default {
preferredFirstName: response.body.personal.preferredFirstName,
})),

deleteViaApi: (userId) => cy
deleteViaApi: (userId, fromKeycloak = false) => cy
.okapiRequest({
method: 'DELETE',
path: `bl-users/by-id/${userId}`,
path: `${fromKeycloak ? 'users-keycloak/users/' : 'bl-users/by-id/'}${userId}`,
isDefaultSearchParamsRequired: false,
failOnStatusCode: false,
})
Expand Down
Loading