Skip to content
Snippets Groups Projects
Verified Commit 307a2367 authored by Sebastian Bergandy's avatar Sebastian Bergandy :keyboard:
Browse files

OZG-7837 extract function

parent a6b64d3c
Branches
Tags
1 merge request!95OZG-7383 add realm-management roles for admin
......@@ -85,9 +85,7 @@ Cypress.Commands.add('getUserInfo', () => {
return cy.request({
method: HttpMethod.GET,
url: `${getKeycloakBaseRealmUrl()}/userinfo`,
headers: {
[Header.AUTHORIZATION]: `bearer ${window.sessionStorage.getItem(ACCES_TOKEN)}`,
},
headers: { ...buildBearerTokenAuthorizationHeader() },
});
});
......@@ -96,9 +94,7 @@ Cypress.Commands.add('findUser', (username: string) =>
.request<UserRepresentation[]>({
method: HttpMethod.GET,
url: getUsersApiUrl(),
headers: {
[Header.AUTHORIZATION]: `Bearer ${getAccessToken()}`,
},
headers: { ...buildBearerTokenAuthorizationHeader() },
})
.then<UserRepresentation>((response: Cypress.Response<UserRepresentation[]>) => {
const users: UserRepresentation[] = response.body;
......@@ -112,9 +108,7 @@ Cypress.Commands.add('verifyEmail', (userId: string) =>
cy.request<void>({
method: HttpMethod.PUT,
url: getUsersApiUrl() + '/' + userId,
headers: {
[Header.AUTHORIZATION]: `Bearer ${getAccessToken()}`,
},
headers: { ...buildBearerTokenAuthorizationHeader() },
body: { emailVerified: true },
}),
);
......@@ -123,13 +117,17 @@ Cypress.Commands.add('resetPassword', (userId: string, newPassword: string) =>
cy.request<void>({
method: HttpMethod.PUT,
url: getUsersApiUrl() + '/' + userId + '/reset-password',
headers: {
[Header.AUTHORIZATION]: `Bearer ${getAccessToken()}`,
},
headers: { ...buildBearerTokenAuthorizationHeader() },
body: { type: 'password', temporary: false, value: newPassword },
}),
);
function buildBearerTokenAuthorizationHeader(): object {
return {
[Header.AUTHORIZATION]: `Bearer ${getAccessToken()}`,
};
}
function getAccessToken(): string | null {
return window.sessionStorage.getItem(ACCES_TOKEN);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment