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