2015-11-24 21:59:52 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2015-12-01 02:07:21 +00:00
|
|
|
/* jslint node:true */
|
|
|
|
/* global it:false */
|
|
|
|
/* global xit:false */
|
|
|
|
/* global describe:false */
|
|
|
|
/* global before:false */
|
|
|
|
/* global after:false */
|
|
|
|
|
2015-11-24 21:59:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-05-03 16:38:42 +00:00
|
|
|
require('chromedriver');
|
|
|
|
|
2015-11-24 21:59:52 +00:00
|
|
|
var execSync = require('child_process').execSync,
|
|
|
|
expect = require('expect.js'),
|
|
|
|
fs = require('fs'),
|
|
|
|
path = require('path'),
|
|
|
|
rimraf = require('rimraf'),
|
2019-07-31 16:16:28 +00:00
|
|
|
superagent = require('superagent');
|
2015-11-24 21:59:52 +00:00
|
|
|
|
2015-11-25 08:28:22 +00:00
|
|
|
var by = require('selenium-webdriver').By,
|
2017-04-05 03:55:07 +00:00
|
|
|
until = require('selenium-webdriver').until,
|
|
|
|
Builder = require('selenium-webdriver').Builder;
|
2015-11-25 08:28:22 +00:00
|
|
|
|
2015-11-24 21:59:52 +00:00
|
|
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
|
|
|
|
|
|
describe('Application life cycle test', function () {
|
|
|
|
this.timeout(0);
|
2017-04-05 03:55:07 +00:00
|
|
|
var server, browser = new Builder().forBrowser('chrome').build();
|
2017-04-05 03:17:35 +00:00
|
|
|
var LOCATION = 'test';
|
2018-11-02 07:53:38 +00:00
|
|
|
var SSH_PORT = 29420;
|
2015-11-25 09:36:29 +00:00
|
|
|
var repodir = '/tmp/testrepo';
|
|
|
|
var app, reponame = 'testrepo';
|
|
|
|
var username = process.env.USERNAME;
|
|
|
|
var password = process.env.PASSWORD;
|
2017-06-02 21:31:59 +00:00
|
|
|
var TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 5000;
|
2019-06-05 00:23:35 +00:00
|
|
|
var email = process.env.EMAIL, token;
|
2015-11-24 21:59:52 +00:00
|
|
|
|
2015-11-25 08:34:37 +00:00
|
|
|
before(function (done) {
|
|
|
|
if (!process.env.USERNAME) return done(new Error('USERNAME env var not set'));
|
|
|
|
if (!process.env.PASSWORD) return done(new Error('PASSWORD env var not set'));
|
2019-06-05 00:23:35 +00:00
|
|
|
if (!process.env.EMAIL) return done(new Error('EMAIL env var not set'));
|
2015-11-25 08:34:37 +00:00
|
|
|
|
2015-11-25 03:47:03 +00:00
|
|
|
var seleniumJar= require('selenium-server-standalone-jar');
|
|
|
|
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
2015-11-25 08:28:22 +00:00
|
|
|
server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
2015-11-25 03:47:03 +00:00
|
|
|
server.start();
|
2015-11-25 08:56:04 +00:00
|
|
|
|
|
|
|
done();
|
2015-11-25 03:47:03 +00:00
|
|
|
});
|
|
|
|
|
2015-11-25 08:56:04 +00:00
|
|
|
after(function (done) {
|
2015-11-25 08:28:22 +00:00
|
|
|
browser.quit();
|
|
|
|
server.stop();
|
2015-11-25 09:36:29 +00:00
|
|
|
rimraf.sync(repodir);
|
2015-11-25 08:56:04 +00:00
|
|
|
done();
|
2015-11-25 08:28:22 +00:00
|
|
|
});
|
|
|
|
|
2019-06-05 00:23:35 +00:00
|
|
|
function waitForUrl(url) {
|
|
|
|
return browser.wait(function () {
|
2017-04-05 04:42:26 +00:00
|
|
|
return browser.getCurrentUrl().then(function (currentUrl) {
|
|
|
|
return currentUrl === url;
|
|
|
|
});
|
2019-06-05 00:23:35 +00:00
|
|
|
}, TIMEOUT);
|
2017-04-05 04:42:26 +00:00
|
|
|
}
|
|
|
|
|
2017-08-07 18:16:29 +00:00
|
|
|
function getAppInfo() {
|
|
|
|
var inspect = JSON.parse(execSync('cloudron inspect'));
|
|
|
|
|
|
|
|
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
|
|
|
|
|
|
|
expect(app).to.be.an('object');
|
|
|
|
}
|
|
|
|
|
2018-08-12 17:36:17 +00:00
|
|
|
function setAvatarOld(done) {
|
2017-06-02 21:25:09 +00:00
|
|
|
browser.get('https://' + app.fqdn + '/user/settings/avatar').then(function () {
|
|
|
|
return browser.findElement(by.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//button[contains(text(), "Update Avatar Setting")]')).click();
|
|
|
|
}).then(function () {
|
2017-10-14 18:37:34 +00:00
|
|
|
if (app.manifest.version === '1.0.3') {
|
|
|
|
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"updated successfully")]')), TIMEOUT);
|
|
|
|
} else {
|
|
|
|
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"Your avatar setting has been updated.")]')), TIMEOUT);
|
|
|
|
}
|
|
|
|
}).then(function () {
|
|
|
|
done();
|
2017-04-05 04:42:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-08-12 17:36:17 +00:00
|
|
|
function setAvatar(done) {
|
|
|
|
if (app.manifest.version === '1.5.4') return setAvatarOld(done);
|
|
|
|
|
|
|
|
browser.get('https://' + app.fqdn + '/user/settings').then(function () {
|
|
|
|
var button = browser.findElement(by.xpath('//label[contains(text(), "Use Custom Avatar")]'));
|
|
|
|
return browser.executeScript('arguments[0].scrollIntoView(false)', button);
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//label[contains(text(), "Use Custom Avatar")]')).click();
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//button[contains(text(), "Update Avatar")]')).click();
|
|
|
|
}).then(function () {
|
|
|
|
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"Your avatar has been updated.")]')), TIMEOUT);
|
|
|
|
}).then(function () {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-04-05 04:42:26 +00:00
|
|
|
function checkAvatar(done) {
|
2017-10-17 17:46:38 +00:00
|
|
|
return done();
|
2017-06-02 09:20:27 +00:00
|
|
|
superagent.get('https://' + app.fqdn + '/avatars/a3e6f3316fc1738e29d621e6a26e93d3').end(function (error, result) {
|
2017-04-05 04:42:26 +00:00
|
|
|
expect(error).to.be(null);
|
|
|
|
expect(result.statusCode).to.be(200);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function editFile(done) {
|
2017-06-02 21:25:09 +00:00
|
|
|
browser.get('https://' + app.fqdn + '/' + username + '/' + reponame + '/_edit/master/newfile').then(function () {
|
|
|
|
var cm = browser.findElement(by.xpath('//div[contains(@class,"CodeMirror")]'));
|
|
|
|
var text = 'yo';
|
|
|
|
return browser.executeScript('arguments[0].CodeMirror.setValue("' + text + '");', cm);
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//input[@name="commit_summary"]')).sendKeys('Dummy edit');
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//button[contains(text(), "Commit Changes")]')).click();
|
|
|
|
}).then(function () {
|
2019-06-05 00:23:35 +00:00
|
|
|
return waitForUrl('https://' + app.fqdn + '/' + username + '/' + reponame + '/src/branch/master/newfile');
|
|
|
|
}).then(function () {
|
|
|
|
done();
|
2017-06-02 21:25:09 +00:00
|
|
|
});
|
|
|
|
}
|
2017-04-05 04:42:26 +00:00
|
|
|
|
2019-06-05 00:23:35 +00:00
|
|
|
function login(username, password, done) {
|
2017-06-02 21:25:09 +00:00
|
|
|
browser.get('https://' + app.fqdn + '/user/login').then(function () {
|
|
|
|
return browser.findElement(by.id('user_name')).sendKeys(username);
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.id('password')).sendKeys(password);
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.tagName('form')).submit();
|
|
|
|
}).then(function () {
|
|
|
|
return browser.wait(until.elementLocated(by.linkText('Dashboard')), TIMEOUT);
|
|
|
|
}).then(function () {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
2017-04-05 04:42:26 +00:00
|
|
|
|
2019-06-05 00:23:35 +00:00
|
|
|
function adminLogin(done) {
|
|
|
|
login('root', 'changeme', done);
|
|
|
|
}
|
|
|
|
|
|
|
|
function logout(done) {
|
|
|
|
browser.get('https://' + app.fqdn + '/user/logout').then(function () {
|
|
|
|
return waitForUrl('https://' + app.fqdn + '/explore/repos');
|
|
|
|
}).then(function () {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-06-02 21:25:09 +00:00
|
|
|
function addPublicKey(done) {
|
|
|
|
var publicKey = fs.readFileSync(__dirname + '/id_rsa.pub', 'utf8');
|
|
|
|
|
2018-08-12 17:36:17 +00:00
|
|
|
const sshPage = 'https://' + app.fqdn + '/user/settings/keys';
|
2017-10-14 18:37:34 +00:00
|
|
|
|
|
|
|
browser.get(sshPage).then(function () {
|
2017-06-02 21:25:09 +00:00
|
|
|
return browser.findElement(by.xpath('//div[text()="Add Key"]')).click();
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.id('ssh-key-title')).sendKeys('testkey');
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.id('ssh-key-content')).sendKeys(publicKey.trim()); // #3480
|
2017-10-14 18:37:34 +00:00
|
|
|
}).then(function () {
|
|
|
|
var button = browser.findElement(by.xpath('//button[contains(text(), "Add Key")]'));
|
|
|
|
return browser.executeScript('arguments[0].scrollIntoView(false)', button);
|
2017-06-02 21:25:09 +00:00
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//button[contains(text(), "Add Key")]')).click();
|
|
|
|
}).then(function () {
|
2017-10-14 18:37:34 +00:00
|
|
|
if (app.manifest.version === '1.0.3') {
|
|
|
|
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(), "added successfully!")]')), TIMEOUT);
|
|
|
|
} else {
|
|
|
|
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(), "has been added.")]')), TIMEOUT);
|
|
|
|
}
|
2017-06-02 21:25:09 +00:00
|
|
|
}).then(function () {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function createRepo(done) {
|
2017-10-14 18:37:34 +00:00
|
|
|
var getRepoPage;
|
|
|
|
if (app.manifest.version === '1.0.3') {
|
|
|
|
getRepoPage = browser.get('https://' + app.fqdn).then(function () {
|
|
|
|
return browser.findElement(by.linkText('New Repository')).click();
|
|
|
|
}).then(function () {
|
|
|
|
return browser.wait(until.elementLocated(by.xpath('//*[contains(text(), "New Repository")]')), TIMEOUT);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
getRepoPage = browser.get('https://' + app.fqdn + '/repo/create');
|
|
|
|
}
|
|
|
|
|
|
|
|
getRepoPage.then(function () {
|
2017-06-02 21:25:09 +00:00
|
|
|
return browser.findElement(by.id('repo_name')).sendKeys(reponame);
|
2017-10-14 18:37:34 +00:00
|
|
|
}).then(function () {
|
|
|
|
var button = browser.findElement(by.xpath('//button[contains(text(), "Create Repository")]'));
|
|
|
|
return browser.executeScript('arguments[0].scrollIntoView(true)', button);
|
2017-06-02 21:25:09 +00:00
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.id('auto-init')).click();
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//button[contains(text(), "Create Repository")]')).click();
|
|
|
|
}).then(function () {
|
|
|
|
browser.wait(function () {
|
|
|
|
return browser.getCurrentUrl().then(function (url) {
|
|
|
|
return url === 'https://' + app.fqdn + '/' + username + '/' + reponame;
|
|
|
|
});
|
|
|
|
}, TIMEOUT);
|
|
|
|
}).then(function () {
|
|
|
|
done();
|
2017-04-05 04:42:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-06-02 21:25:09 +00:00
|
|
|
function checkCloneUrl(done) {
|
|
|
|
browser.get('https://' + app.fqdn + '/' + username + '/' + reponame).then(function () {
|
|
|
|
return browser.findElement(by.id('repo-clone-ssh')).click();
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.id('repo-clone-url')).getAttribute('value');
|
|
|
|
}).then(function (cloneUrl) {
|
2018-11-02 07:53:38 +00:00
|
|
|
expect(cloneUrl).to.be(`ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame}.git`);
|
2017-06-02 21:25:09 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-08-07 18:16:29 +00:00
|
|
|
function cloneRepo(done) {
|
2017-06-02 21:25:09 +00:00
|
|
|
rimraf.sync(repodir);
|
|
|
|
var env = Object.create(process.env);
|
|
|
|
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
|
2018-11-02 07:53:38 +00:00
|
|
|
execSync(`git clone ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame}.git ${repodir}`, { env: env });
|
2017-06-02 21:25:09 +00:00
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
2017-08-07 18:16:29 +00:00
|
|
|
function pushFile(done) {
|
|
|
|
var env = Object.create(process.env);
|
|
|
|
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
|
2018-11-02 07:53:38 +00:00
|
|
|
execSync(`touch newfile && git add newfile && git commit -a -mx && git push ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame} master`,
|
2017-08-07 18:16:29 +00:00
|
|
|
{ env: env, cwd: repodir });
|
|
|
|
rimraf.sync('/tmp/testrepo');
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
2018-08-02 17:15:05 +00:00
|
|
|
function addCustomFile(done) {
|
|
|
|
fs.writeFileSync('/tmp/customfile.txt', 'GOGS TEST', 'utf8');
|
2018-09-03 15:44:23 +00:00
|
|
|
execSync(`cloudron exec --app ${app.id} -- mkdir -p /app/data/custom/public`);
|
|
|
|
execSync(`cloudron push --app ${app.id} /tmp/customfile.txt /app/data/custom/public/customfile.txt`);
|
2018-08-02 17:15:05 +00:00
|
|
|
fs.unlinkSync('/tmp/customfile.txt');
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkCustomFile(done) {
|
|
|
|
superagent.get('https://' + app.fqdn + '/customfile.txt').end(function (error, result) {
|
|
|
|
if (error) return done(error);
|
|
|
|
|
|
|
|
expect(result.text).to.contain('GOGS TEST');
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-08-07 18:16:29 +00:00
|
|
|
function fileExists() {
|
|
|
|
expect(fs.existsSync(repodir + '/newfile')).to.be(true);
|
|
|
|
}
|
|
|
|
|
2018-01-18 19:01:41 +00:00
|
|
|
function sendMail(done) {
|
2018-11-02 07:53:38 +00:00
|
|
|
browser.get(`https://${app.fqdn}/admin/config`).then(function () {
|
2018-01-18 19:01:41 +00:00
|
|
|
var button = browser.findElement(by.xpath('//button[@id="test-mail-btn"]'));
|
|
|
|
return browser.executeScript('arguments[0].scrollIntoView(true)', button);
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//input[@name="email"]')).sendKeys('test@cloudron.io');
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//button[@id="test-mail-btn"]')).click();
|
|
|
|
}).then(function () {
|
2018-08-12 17:36:17 +00:00
|
|
|
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"A testing email has been sent to \'test@cloudron.io\'")]')), TIMEOUT);
|
2018-01-18 19:01:41 +00:00
|
|
|
}).then(function () {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-11-25 09:36:29 +00:00
|
|
|
xit('build app', function () {
|
2015-11-24 21:59:52 +00:00
|
|
|
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
|
|
|
|
2016-04-13 04:01:52 +00:00
|
|
|
it('can login', function (done) {
|
|
|
|
var inspect = JSON.parse(execSync('cloudron inspect'));
|
|
|
|
|
2018-11-02 07:53:38 +00:00
|
|
|
superagent.post(`https://${inspect.apiEndpoint}/api/v1/developer/login`).send({
|
2016-04-13 04:01:52 +00:00
|
|
|
username: username,
|
|
|
|
password: password
|
|
|
|
}).end(function (error, result) {
|
|
|
|
if (error) return done(error);
|
|
|
|
if (result.statusCode !== 200) return done(new Error('Login failed with status ' + result.statusCode));
|
|
|
|
|
2018-05-03 16:44:20 +00:00
|
|
|
token = result.body.accessToken;
|
2016-04-13 04:01:52 +00:00
|
|
|
|
2018-11-02 07:53:38 +00:00
|
|
|
superagent.get(`https://${inspect.apiEndpoint}/api/v1/profile`)
|
2016-04-13 04:01:52 +00:00
|
|
|
.query({ access_token: token }).end(function (error, result) {
|
|
|
|
if (error) return done(error);
|
|
|
|
if (result.statusCode !== 200) return done(new Error('Get profile failed with status ' + result.statusCode));
|
|
|
|
|
|
|
|
email = result.body.email;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-11-24 21:59:52 +00:00
|
|
|
it('install app', function () {
|
2018-11-02 07:53:38 +00:00
|
|
|
execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
2015-11-24 21:59:52 +00:00
|
|
|
});
|
|
|
|
|
2017-08-07 18:16:29 +00:00
|
|
|
it('can get app information', getAppInfo);
|
2015-11-24 21:59:52 +00:00
|
|
|
it('can get the main page', function (done) {
|
|
|
|
superagent.get('https://' + app.fqdn).end(function (error, result) {
|
|
|
|
expect(error).to.be(null);
|
|
|
|
expect(result.status).to.eql(200);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-06-05 00:23:35 +00:00
|
|
|
it('can admin login', adminLogin);
|
2018-01-18 19:01:41 +00:00
|
|
|
it('can send mail', sendMail);
|
2019-06-05 00:23:35 +00:00
|
|
|
it('can logout', logout);
|
|
|
|
|
|
|
|
it('can login', login.bind(null, username, password));
|
2017-04-05 04:42:26 +00:00
|
|
|
it('can set avatar', setAvatar);
|
|
|
|
it('can get avatar', checkAvatar);
|
|
|
|
|
2017-06-02 21:25:09 +00:00
|
|
|
it('can add public key', addPublicKey);
|
2015-11-25 08:28:22 +00:00
|
|
|
|
2017-06-02 21:25:09 +00:00
|
|
|
it('can create repo', createRepo);
|
2015-11-25 08:28:22 +00:00
|
|
|
|
2017-06-02 21:25:09 +00:00
|
|
|
it('displays correct clone url', checkCloneUrl);
|
2015-11-25 08:28:22 +00:00
|
|
|
|
2017-08-07 18:16:29 +00:00
|
|
|
it('can clone the url', cloneRepo);
|
2015-11-25 08:28:22 +00:00
|
|
|
|
2017-08-07 18:16:29 +00:00
|
|
|
it('can add and push a file', pushFile);
|
2017-04-05 04:42:26 +00:00
|
|
|
it('can edit file', editFile);
|
|
|
|
|
2018-08-02 17:15:05 +00:00
|
|
|
it('can add custom file', addCustomFile);
|
|
|
|
it('can check custom file', checkCustomFile);
|
|
|
|
|
2015-12-01 02:09:13 +00:00
|
|
|
it('can restart app', function (done) {
|
2018-03-26 10:36:09 +00:00
|
|
|
execSync('cloudron restart --wait --app ' + app.id);
|
2015-12-01 02:09:13 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2019-08-20 00:29:26 +00:00
|
|
|
xit('can login', login.bind(null, username, password)); // no need to relogin since session persists
|
2017-10-14 18:37:34 +00:00
|
|
|
it('displays correct clone url', checkCloneUrl);
|
2017-08-07 18:16:29 +00:00
|
|
|
it('can clone the url', cloneRepo);
|
|
|
|
it('file exists in repo', fileExists);
|
2015-12-01 02:09:13 +00:00
|
|
|
|
2015-11-24 21:59:52 +00:00
|
|
|
it('backup app', function () {
|
2016-08-26 10:59:27 +00:00
|
|
|
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
2015-11-24 21:59:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('restore app', function () {
|
|
|
|
execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
|
|
|
|
2019-06-05 00:23:35 +00:00
|
|
|
it('can login', login.bind(null, username, password));
|
2017-04-05 04:42:26 +00:00
|
|
|
it('can get avatar', checkAvatar);
|
2017-08-07 18:16:29 +00:00
|
|
|
it('can clone the url', cloneRepo);
|
2017-06-02 21:25:09 +00:00
|
|
|
it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); });
|
2015-11-25 08:28:22 +00:00
|
|
|
|
2018-09-03 15:44:23 +00:00
|
|
|
it('move to different location', function (done) {
|
2017-11-29 20:21:25 +00:00
|
|
|
//browser.manage().deleteAllCookies(); // commented because of error "'Network.deleteCookie' wasn't found"
|
2018-09-03 15:44:23 +00:00
|
|
|
// ensure we don't hit NXDOMAIN in the mean time
|
|
|
|
browser.get('about:blank').then(function () {
|
|
|
|
execSync('cloudron configure --wait --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
var inspect = JSON.parse(execSync('cloudron inspect'));
|
|
|
|
app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0];
|
|
|
|
expect(app).to.be.an('object');
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2015-12-01 02:13:47 +00:00
|
|
|
});
|
|
|
|
|
2019-06-05 00:23:35 +00:00
|
|
|
it('can login', login.bind(null, username, password));
|
2017-04-05 04:42:26 +00:00
|
|
|
it('can get avatar', checkAvatar);
|
2017-06-02 21:25:09 +00:00
|
|
|
it('displays correct clone url', checkCloneUrl);
|
2017-08-07 18:16:29 +00:00
|
|
|
it('can clone the url', cloneRepo);
|
2017-06-02 21:25:09 +00:00
|
|
|
it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); });
|
2015-12-01 02:13:47 +00:00
|
|
|
|
2018-09-03 15:44:23 +00:00
|
|
|
it('uninstall app', function (done) {
|
|
|
|
// ensure we don't hit NXDOMAIN in the mean time
|
|
|
|
browser.get('about:blank').then(function () {
|
|
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
done();
|
|
|
|
});
|
2015-11-24 21:59:52 +00:00
|
|
|
});
|
2016-04-11 21:58:06 +00:00
|
|
|
|
|
|
|
// check if the _first_ login via email succeeds
|
2016-07-09 21:35:46 +00:00
|
|
|
it('can login via email', function (done) {
|
2018-11-02 07:53:38 +00:00
|
|
|
execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
2016-04-11 21:58:06 +00:00
|
|
|
var inspect = JSON.parse(execSync('cloudron inspect'));
|
|
|
|
|
|
|
|
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
|
|
|
expect(app).to.be.an('object');
|
|
|
|
|
2019-06-05 00:23:35 +00:00
|
|
|
login(email, password, function (error) {
|
2017-06-02 21:25:09 +00:00
|
|
|
if (error) return done(error);
|
2018-09-03 15:44:23 +00:00
|
|
|
|
|
|
|
// ensure we don't hit NXDOMAIN in the mean time
|
|
|
|
browser.get('about:blank').then(function () {
|
|
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
done();
|
|
|
|
});
|
2016-04-13 05:00:21 +00:00
|
|
|
});
|
2016-04-11 21:58:06 +00:00
|
|
|
});
|
2017-08-07 18:16:29 +00:00
|
|
|
|
2019-06-05 00:23:35 +00:00
|
|
|
// No SSO
|
|
|
|
it('install app (no sso)', function () {
|
2019-07-31 16:15:17 +00:00
|
|
|
execSync(`cloudron install --new --wait --no-sso --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
2019-06-05 00:23:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can get app information', function () {
|
|
|
|
var inspect = JSON.parse(execSync('cloudron inspect'));
|
|
|
|
|
|
|
|
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
|
|
|
|
|
|
|
expect(app).to.be.an('object');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can admin login (no sso)', adminLogin);
|
|
|
|
it('can logout', logout);
|
|
|
|
|
|
|
|
it('uninstall app (no sso)', function () {
|
|
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
|
|
|
|
2017-08-07 18:16:29 +00:00
|
|
|
// test update
|
|
|
|
it('can install app', function () {
|
2018-11-02 07:53:38 +00:00
|
|
|
execSync(`cloudron install --new --wait --appstore-id ${app.manifest.id} --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
2017-08-07 18:16:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('can get app information', getAppInfo);
|
2019-06-05 00:23:35 +00:00
|
|
|
it('can login', login.bind(null, username, password));
|
2017-08-07 18:16:29 +00:00
|
|
|
it('can set avatar', setAvatar);
|
|
|
|
it('can get avatar', checkAvatar);
|
|
|
|
it('can add public key', addPublicKey);
|
|
|
|
it('can create repo', createRepo);
|
|
|
|
it('can clone the url', cloneRepo);
|
|
|
|
it('can add and push a file', pushFile);
|
|
|
|
|
|
|
|
it('can update', function () {
|
|
|
|
execSync('cloudron install --wait --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
|
|
|
|
2019-06-05 00:23:35 +00:00
|
|
|
xit('can admin login', adminLogin);
|
|
|
|
xit('can send mail', sendMail);
|
|
|
|
xit('can logout', logout);
|
|
|
|
|
|
|
|
it('can login', login.bind(null, username, password));
|
2017-08-07 18:16:29 +00:00
|
|
|
it('can get avatar', checkAvatar);
|
|
|
|
it('can clone the url', cloneRepo);
|
|
|
|
it('file exists in cloned repo', fileExists);
|
|
|
|
|
2018-09-03 15:44:23 +00:00
|
|
|
it('uninstall app', function (done) {
|
|
|
|
// ensure we don't hit NXDOMAIN in the mean time
|
|
|
|
browser.get('about:blank').then(function () {
|
|
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
done();
|
|
|
|
});
|
2017-08-07 18:16:29 +00:00
|
|
|
});
|
2015-11-24 21:59:52 +00:00
|
|
|
});
|