mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 20:38:00 +00:00
681541f41b
adds possibilities to cap authenticated requests and execution seconds of actions on a defined intervall
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { requestHeaders } from './apiauth';
|
|
import { API } from './types';
|
|
import { ensureSetting } from './ensure';
|
|
|
|
export enum Policy {
|
|
Label = 'label',
|
|
}
|
|
|
|
export function resetPolicy(api: API, policy: Policy) {
|
|
cy.request({
|
|
method: 'DELETE',
|
|
url: `${api.mgmtBaseURL}/policies/${policy}`,
|
|
headers: requestHeaders(api),
|
|
}).then((res) => {
|
|
expect(res.status).to.equal(200);
|
|
return null;
|
|
});
|
|
}
|
|
|
|
export function ensureDomainPolicy(
|
|
api: API,
|
|
userLoginMustBeDomain: boolean,
|
|
validateOrgDomains: boolean,
|
|
smtpSenderAddressMatchesInstanceDomain: boolean,
|
|
) {
|
|
return ensureSetting(
|
|
api,
|
|
`${api.adminBaseURL}/policies/domain`,
|
|
(body: any) => {
|
|
const result = {
|
|
sequence: parseInt(<string>body.policy?.details?.sequence),
|
|
id: body.policy?.details?.resourceOwner,
|
|
entity: null,
|
|
};
|
|
if (
|
|
body.policy &&
|
|
(body.policy.userLoginMustBeDomain ? body.policy.userLoginMustBeDomain : false) == userLoginMustBeDomain &&
|
|
(body.policy.validateOrgDomains ? body.policy.validateOrgDomains : false) == validateOrgDomains &&
|
|
(body.policy.smtpSenderAddressMatchesInstanceDomain ? body.policy.smtpSenderAddressMatchesInstanceDomain : false) ==
|
|
smtpSenderAddressMatchesInstanceDomain
|
|
) {
|
|
return { ...result, entity: body.policy };
|
|
}
|
|
return result;
|
|
},
|
|
`${api.adminBaseURL}/policies/domain`,
|
|
{
|
|
userLoginMustBeDomain: userLoginMustBeDomain,
|
|
validateOrgDomains: validateOrgDomains,
|
|
smtpSenderAddressMatchesInstanceDomain: smtpSenderAddressMatchesInstanceDomain,
|
|
},
|
|
);
|
|
}
|