move addon config db code to addonconfigs.js

This commit is contained in:
Girish Ramakrishnan
2021-08-19 21:39:27 -07:00
parent 411cc7daa1
commit c5fff756d1
9 changed files with 300 additions and 339 deletions

View File

@@ -6,7 +6,7 @@
'use strict';
const appdb = require('../appdb.js'),
const addonConfigs = require('../addonconfigs.js'),
async = require('async'),
common = require('./common.js'),
constants = require('../constants.js'),
@@ -15,8 +15,7 @@ const appdb = require('../appdb.js'),
ldap = require('ldapjs'),
ldapServer = require('../ldap.js'),
mail = require('../mail.js'),
safe = require('safetydance'),
util = require('util');
safe = require('safetydance');
async function ldapBind(dn, password) {
return new Promise((resolve, reject) => {
@@ -417,9 +416,7 @@ describe('Ldap', function () {
});
it('allows with valid password', async function () {
const setAddonConfig = util.promisify(appdb.setAddonConfig);
await setAddonConfig(app.id, 'sendmail', [{ name: 'MAIL_SMTP_USERNAME', value : `${app.location}.app@${domain.domain}` }, { name: 'MAIL_SMTP_PASSWORD', value : 'sendmailpassword' }]),
await addonConfigs.set(app.id, 'sendmail', [{ name: 'MAIL_SMTP_USERNAME', value : `${app.location}.app@${domain.domain}` }, { name: 'MAIL_SMTP_PASSWORD', value : 'sendmailpassword' }]),
await ldapBind(`cn=${app.location}.app@${domain.domain},ou=sendmail,dc=cloudron`, 'sendmailpassword');
});
@@ -469,8 +466,7 @@ describe('Ldap', function () {
});
it('allows with valid password', async function () {
const setAddonConfig = util.promisify(appdb.setAddonConfig);
await setAddonConfig(app.id, 'recvmail', [{ name: 'MAIL_IMAP_USERNAME', value : `${app.location}.app@${domain.domain}` }, { name: 'MAIL_IMAP_PASSWORD', value : 'recvmailpassword' }]),
await addonConfigs.set(app.id, 'recvmail', [{ name: 'MAIL_IMAP_USERNAME', value : `${app.location}.app@${domain.domain}` }, { name: 'MAIL_IMAP_PASSWORD', value : 'recvmailpassword' }]),
await ldapBind(`cn=${app.location}.app@${domain.domain},ou=recvmail,dc=cloudron`, 'recvmailpassword');
});
});