mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-18 22:07:32 +00:00
51febd7e4e
* add specs that cover the b2b demo * update cypress * test handling manager roles * use shared mocha contexts * use beforeEach instead of before * improve readability * improve application test * remove static waits * remove old awaitDesired * test owned project authorizations * simplify ensure.ts * test granted projects authz * disable prevSubject for shouldNotExist * await non-existence, then expect no error * update dependencies * fix tests from scratch * fix settings tests from scratch * Apply suggestions from code review Co-authored-by: Max Peintner <max@caos.ch> * Implement code review suggestions * use spread operator * settings properties must match * add check settings object * revert spread operator Co-authored-by: Max Peintner <max@caos.ch>
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { ensureItemDoesntExist, ensureItemExists } from './ensure';
|
|
import { API } from './types';
|
|
|
|
export function ensureHumanUserExists(api: API, username: string): Cypress.Chainable<number> {
|
|
return ensureItemExists(
|
|
api,
|
|
`${api.mgmtBaseURL}/users/_search`,
|
|
(user: any) => user.userName === username,
|
|
`${api.mgmtBaseURL}/users/human`,
|
|
{
|
|
user_name: username,
|
|
profile: {
|
|
first_name: 'e2efirstName',
|
|
last_name: 'e2elastName',
|
|
},
|
|
email: {
|
|
email: 'e2e@email.ch',
|
|
},
|
|
phone: {
|
|
phone: '+41 123456789',
|
|
},
|
|
},
|
|
undefined,
|
|
'userId',
|
|
);
|
|
}
|
|
|
|
export function ensureMachineUserExists(api: API, username: string): Cypress.Chainable<number> {
|
|
return ensureItemExists(
|
|
api,
|
|
`${api.mgmtBaseURL}/users/_search`,
|
|
(user: any) => user.userName === username,
|
|
`${api.mgmtBaseURL}/users/machine`,
|
|
{
|
|
user_name: username,
|
|
name: 'e2emachinename',
|
|
description: 'e2emachinedescription',
|
|
},
|
|
undefined,
|
|
'userId',
|
|
);
|
|
}
|
|
|
|
export function ensureUserDoesntExist(api: API, username: string): Cypress.Chainable<null> {
|
|
return ensureItemDoesntExist(
|
|
api,
|
|
`${api.mgmtBaseURL}/users/_search`,
|
|
(user: any) => user.userName === username,
|
|
(user) => `${api.mgmtBaseURL}/users/${user.id}`,
|
|
);
|
|
}
|