2022-10-11 15:29:23 +02:00
|
|
|
import { requestHeaders } from './apiauth';
|
|
|
|
import { API } from './types';
|
2022-12-22 12:16:17 +01:00
|
|
|
import { ensureSetting } from './ensure';
|
2022-04-28 12:35:02 +02:00
|
|
|
|
|
|
|
export enum Policy {
|
2022-09-19 19:49:46 +02:00
|
|
|
Label = 'label',
|
2022-04-28 12:35:02 +02:00
|
|
|
}
|
|
|
|
|
2022-10-11 15:29:23 +02:00
|
|
|
export function resetPolicy(api: API, policy: Policy) {
|
2022-09-19 19:49:46 +02:00
|
|
|
cy.request({
|
|
|
|
method: 'DELETE',
|
2022-10-11 15:29:23 +02:00
|
|
|
url: `${api.mgmtBaseURL}/policies/${policy}`,
|
|
|
|
headers: requestHeaders(api),
|
2022-09-19 19:49:46 +02:00
|
|
|
}).then((res) => {
|
|
|
|
expect(res.status).to.equal(200);
|
|
|
|
return null;
|
|
|
|
});
|
|
|
|
}
|
2022-12-22 12:16:17 +01:00
|
|
|
|
|
|
|
export function ensureDomainPolicy(
|
|
|
|
api: API,
|
|
|
|
userLoginMustBeDomain: boolean,
|
|
|
|
validateOrgDomains: boolean,
|
|
|
|
smtpSenderAddressMatchesInstanceDomain: boolean,
|
2023-02-15 02:52:11 +01:00
|
|
|
) {
|
2022-12-22 12:16:17 +01:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|