2017-01-24 08:00:22 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2018-03-20 16:23:55 +00:00
|
|
|
require('chromedriver');
|
|
|
|
|
2017-01-24 08:00:22 +00:00
|
|
|
var execSync = require('child_process').execSync,
|
|
|
|
expect = require('expect.js'),
|
|
|
|
path = require('path'),
|
|
|
|
webdriver = require('selenium-webdriver');
|
|
|
|
|
2019-05-28 17:48:15 +00:00
|
|
|
var by = require('selenium-webdriver').By,
|
|
|
|
until = require('selenium-webdriver').until,
|
|
|
|
Key = require('selenium-webdriver').Key,
|
|
|
|
Builder = require('selenium-webdriver').Builder;
|
2017-01-24 08:00:22 +00:00
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
var bucket = 'cloudrontestbucket';
|
2017-01-24 08:00:22 +00:00
|
|
|
|
|
|
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
|
|
|
|
|
|
describe('Application life cycle test', function () {
|
|
|
|
this.timeout(0);
|
|
|
|
|
2019-05-28 17:48:15 +00:00
|
|
|
var server, browser = new Builder().forBrowser('chrome').build();
|
2017-01-24 08:00:22 +00:00
|
|
|
|
|
|
|
before(function (done) {
|
|
|
|
var seleniumJar= require('selenium-server-standalone-jar');
|
|
|
|
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
|
|
|
server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
|
|
|
server.start();
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function (done) {
|
|
|
|
browser.quit();
|
|
|
|
server.stop();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2017-06-14 20:45:46 +00:00
|
|
|
var LOCATION = 'test';
|
2017-01-24 08:00:22 +00:00
|
|
|
var TEST_TIMEOUT = 10000;
|
|
|
|
var app;
|
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
function pageLoaded() {
|
|
|
|
return browser.wait(until.elementLocated(by.className('page-load pl-0 pl-1')), TEST_TIMEOUT);
|
2017-01-24 08:00:22 +00:00
|
|
|
}
|
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
function visible(selector) {
|
2017-01-24 08:00:22 +00:00
|
|
|
return browser.wait(until.elementLocated(selector), TEST_TIMEOUT).then(function () {
|
2017-09-20 21:30:46 +00:00
|
|
|
return browser.wait(until.elementIsVisible(browser.findElement(selector)), TEST_TIMEOUT);
|
2017-01-24 08:00:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-16 23:36:41 +00:00
|
|
|
function login(accessKey, secretKey, callback) {
|
2017-01-24 08:00:22 +00:00
|
|
|
browser.manage().deleteAllCookies();
|
2017-09-20 21:30:46 +00:00
|
|
|
browser.get('https://' + app.fqdn).then(function () {
|
|
|
|
return visible(by.id('accessKey'));
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.id('accessKey')).sendKeys(accessKey);
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.id('secretKey')).sendKeys(secretKey);
|
|
|
|
}).then(function () {
|
2018-02-11 00:48:38 +00:00
|
|
|
// return browser.findElement(by.className('lw-btn')).click();
|
|
|
|
return browser.findElement(by.tagName('form')).submit();
|
2017-09-20 21:30:46 +00:00
|
|
|
}).then(function () {
|
|
|
|
return browser.wait(until.elementLocated(by.id('top-right-menu')), TEST_TIMEOUT);
|
|
|
|
}).then(function () {
|
|
|
|
callback();
|
2017-01-24 08:00:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function logout(callback) {
|
|
|
|
browser.get('https://' + app.fqdn);
|
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
pageLoaded().then(function () {
|
|
|
|
return visible(by.id('top-right-menu'));
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.id('top-right-menu')).click();
|
|
|
|
}).then(function () {
|
|
|
|
return visible(by.xpath('//*[text()="Sign Out "]'));
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//*[text()="Sign Out "]')).click();
|
|
|
|
}).then(function () {
|
|
|
|
return browser.wait(until.elementLocated(by.id('accessKey')), TEST_TIMEOUT);
|
|
|
|
}).then(function () {
|
|
|
|
callback();
|
2017-01-24 08:00:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function addBucket(callback) {
|
|
|
|
browser.get('https://' + app.fqdn);
|
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
pageLoaded().then(function () {
|
2019-08-20 17:16:14 +00:00
|
|
|
return visible(by.className('fa-plus'));
|
2017-09-20 21:30:46 +00:00
|
|
|
}).then(function () {
|
2019-08-20 17:16:14 +00:00
|
|
|
return browser.findElement(by.className('fa-plus')).click();
|
2017-09-20 21:30:46 +00:00
|
|
|
}).then(function () {
|
2019-09-01 15:45:49 +00:00
|
|
|
const c = 'fa-hdd';
|
2019-08-20 17:16:14 +00:00
|
|
|
return visible(by.className(c));
|
2017-09-20 21:30:46 +00:00
|
|
|
}).then(function () {
|
2019-09-01 15:45:49 +00:00
|
|
|
const c = 'fa-hdd';
|
2019-08-20 17:16:14 +00:00
|
|
|
return browser.findElement(by.className(c)).click();
|
2017-09-20 21:30:46 +00:00
|
|
|
}).then(function () {
|
|
|
|
return visible(by.xpath('//*[@class="modal-body"]/form/div/input'));
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//*[@class="modal-body"]/form/div/input')).sendKeys(bucket);
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.xpath('//*[@class="modal-body"]/form')).submit();
|
|
|
|
}).then(function () {
|
|
|
|
return visible(by.xpath('//*[@class="main"]/a[text()="' + bucket + '"]'));
|
|
|
|
}).then(function () {
|
|
|
|
callback();
|
2017-01-24 08:00:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
function checkBucket(callback) {
|
2017-02-16 06:23:47 +00:00
|
|
|
browser.get('https://' + app.fqdn);
|
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
pageLoaded().then(function () {
|
|
|
|
return browser.findElement(by.xpath(`//a[contains(text(), ${bucket})]`));
|
|
|
|
}).then(function () {
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
}
|
2017-02-16 06:23:47 +00:00
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
function openSettings(callback) {
|
|
|
|
browser.get('https://' + app.fqdn);
|
|
|
|
|
|
|
|
pageLoaded().then(function () {
|
|
|
|
return visible(by.id('top-right-menu'));
|
|
|
|
}).then(function () {
|
|
|
|
return browser.findElement(by.id('top-right-menu')).click();
|
|
|
|
}).then(function () {
|
2018-04-02 18:51:07 +00:00
|
|
|
return visible(by.xpath('//*[contains(text(), "Change Password")]'));
|
2017-09-20 21:30:46 +00:00
|
|
|
}).then(function () {
|
2018-04-02 18:51:07 +00:00
|
|
|
return browser.findElement(by.xpath('//*[contains(text(),"Change Password")]')).click();
|
2017-09-20 21:30:46 +00:00
|
|
|
}).then(function () {
|
2018-04-02 18:51:07 +00:00
|
|
|
return browser.wait(until.elementLocated(by.xpath('//*[contains(text(), "Change Password")]')), TEST_TIMEOUT);
|
2017-09-20 21:30:46 +00:00
|
|
|
}).then(function () {
|
|
|
|
callback();
|
2017-02-16 06:23:47 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-01-24 08:00:22 +00:00
|
|
|
xit('build app', function () {
|
|
|
|
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('install app', function () {
|
2019-12-20 20:02:49 +00:00
|
|
|
execSync('cloudron install --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
2017-01-24 08:00:22 +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');
|
|
|
|
});
|
|
|
|
|
2020-01-16 23:36:41 +00:00
|
|
|
it('can login', login.bind(null, 'minioadmin', 'minioadmin'));
|
2017-09-20 21:30:46 +00:00
|
|
|
it('can add bucket', addBucket);
|
2017-02-16 06:23:47 +00:00
|
|
|
it('can open settings', openSettings);
|
2017-01-24 08:00:22 +00:00
|
|
|
it('can logout', logout);
|
|
|
|
|
2020-01-16 23:36:41 +00:00
|
|
|
it('can change credentials', function () {
|
|
|
|
execSync('cloudron exec --app ' + app.id + ' -- /app/code/minio-credentials set minioakey minioskey', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
it('can restart app', function (done) {
|
2019-12-20 20:02:49 +00:00
|
|
|
execSync('cloudron restart');
|
2017-09-20 21:30:46 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2020-01-16 23:36:41 +00:00
|
|
|
it('can login', login.bind(null, 'minioakey', 'minioskey'));
|
2017-09-20 21:30:46 +00:00
|
|
|
it('has bucket', checkBucket);
|
|
|
|
it('can logout', logout);
|
|
|
|
|
2017-01-24 08:00:22 +00:00
|
|
|
it('backup app', function () {
|
|
|
|
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('restore app', function () {
|
|
|
|
execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
|
|
|
|
2020-01-16 23:36:41 +00:00
|
|
|
it('can login', login.bind(null, 'minioakey', 'minioskey'));
|
2017-09-20 21:30:46 +00:00
|
|
|
it('has bucket', checkBucket);
|
2017-02-16 06:23:47 +00:00
|
|
|
it('can open settings', openSettings);
|
2017-01-24 08:00:22 +00:00
|
|
|
it('can logout', logout);
|
|
|
|
|
|
|
|
it('move to different location', function () {
|
|
|
|
browser.manage().deleteAllCookies();
|
2019-12-20 20:02:49 +00:00
|
|
|
execSync('cloudron configure --location ' + LOCATION + '2', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
2017-01-24 08:00:22 +00:00
|
|
|
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');
|
|
|
|
});
|
|
|
|
|
2020-01-16 23:36:41 +00:00
|
|
|
it('can login', login.bind(null, 'minioakey', 'minioskey'));
|
2017-09-20 21:30:46 +00:00
|
|
|
it('has bucket', checkBucket);
|
2017-01-24 08:00:22 +00:00
|
|
|
it('can logout', logout);
|
|
|
|
|
|
|
|
it('uninstall app', function () {
|
|
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
|
|
|
|
2017-09-20 21:30:46 +00:00
|
|
|
// test update
|
|
|
|
it('can install app', function () {
|
2019-12-20 20:02:49 +00:00
|
|
|
execSync('cloudron install --appstore-id io.minio.cloudronapp --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
2017-09-20 21:30:46 +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');
|
|
|
|
});
|
|
|
|
|
2020-01-17 00:05:59 +00:00
|
|
|
it('can login', login.bind(null, 'minioadmin', 'minioadmin'));
|
2017-09-20 21:30:46 +00:00
|
|
|
it('can add buckets', addBucket);
|
|
|
|
it('can logout', logout);
|
|
|
|
it('can update', function () {
|
2019-12-20 20:02:49 +00:00
|
|
|
execSync('cloudron update --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
2017-09-20 21:30:46 +00:00
|
|
|
});
|
2020-01-17 00:05:59 +00:00
|
|
|
it('can login', login.bind(null, 'minioadmin', 'minioadmin'));
|
2017-09-20 21:30:46 +00:00
|
|
|
it('has bucket', checkBucket);
|
|
|
|
it('can logout', logout);
|
|
|
|
it('uninstall app', function () {
|
|
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
});
|
2017-01-24 08:00:22 +00:00
|
|
|
});
|
2017-09-20 21:30:46 +00:00
|
|
|
|