74 lines
2.1 KiB
JavaScript
74 lines
2.1 KiB
JavaScript
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}};
|
|
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
|
|
|
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}};
|
|
await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options);
|
|
|
|
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();
|
|
});
|
|
});
|
|
|