2023-12-01 12:58:45 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
|
|
|
|
fdescribe('loopback model MailAliasAccount', () => {
|
|
|
|
it('should fail to add a mail Alias if the worker doesnt have ACLs', async() => {
|
|
|
|
const tx = await models.MailAliasAccount.beginTransaction({});
|
|
|
|
let error;
|
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx, accessToken: {userId: 1}};
|
|
|
|
await models.MailAliasAccount.create({mailAliasFk: 2, roleFk: 5}, options);
|
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
error = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(error.message).toEqual('The alias cant be modified');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should add a mail Alias', async() => {
|
|
|
|
const tx = await models.MailAliasAccount.beginTransaction({});
|
|
|
|
let error;
|
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx, accessToken: {userId: 9}};
|
2023-12-04 08:40:57 +00:00
|
|
|
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
2023-12-01 12:58:45 +00:00
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
error = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(error).toBeUndefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should add a mail Alias of an inherit role', async() => {
|
|
|
|
const tx = await models.MailAliasAccount.beginTransaction({});
|
|
|
|
let error;
|
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx, accessToken: {userId: 9}};
|
2023-12-04 08:40:57 +00:00
|
|
|
await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options);
|
2023-12-01 12:58:45 +00:00
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
error = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(error).toBeUndefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete a mail Alias', async() => {
|
|
|
|
const tx = await models.MailAliasAccount.beginTransaction({});
|
|
|
|
let error;
|
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx, accessToken: {userId: 1}};
|
|
|
|
const mailAclId = 2;
|
|
|
|
await models.MailAliasAccount.destroyAll({id: mailAclId}, options);
|
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
error = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(error).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|