|
@@ -33,6 +33,7 @@ describe('Application life cycle test', function () {
|
|
|
var app;
|
|
|
var username = process.env.USERNAME;
|
|
|
var password = process.env.PASSWORD;
|
|
|
+ var email, token;
|
|
|
|
|
|
before(function (done) {
|
|
|
if (!process.env.USERNAME) return done(new Error('USERNAME env var not set'));
|
|
@@ -56,6 +57,29 @@ describe('Application life cycle test', function () {
|
|
|
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
});
|
|
|
|
|
|
+ it('can login', function (done) {
|
|
|
+ var inspect = JSON.parse(execSync('cloudron inspect'));
|
|
|
+
|
|
|
+ superagent.post('https://' + inspect.apiEndpoint + '/api/v1/developer/login').send({
|
|
|
+ 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));
|
|
|
+
|
|
|
+ token = result.body.token;
|
|
|
+
|
|
|
+ superagent.get('https://' + inspect.apiEndpoint + '/api/v1/profile')
|
|
|
+ .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();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
it('install app', function () {
|
|
|
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
});
|
|
@@ -203,4 +227,22 @@ describe('Application life cycle test', function () {
|
|
|
it('uninstall app', function () {
|
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
});
|
|
|
+
|
|
|
+ // check if the _first_ login via email succeeds
|
|
|
+ it('can login via email', function () {
|
|
|
+ execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
+ var inspect = JSON.parse(execSync('cloudron inspect'));
|
|
|
+
|
|
|
+ app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
|
|
+ expect(app).to.be.an('object');
|
|
|
+
|
|
|
+ browser.get('https://' + app.fqdn + '/wp-login.php');
|
|
|
+ browser.findElement(by.id('user_login')).sendKeys(username);
|
|
|
+ browser.findElement(by.id('user_pass')).sendKeys(password);
|
|
|
+ browser.findElement(by.tagName('form')).submit();
|
|
|
+ browser.wait(until.elementLocated(by.xpath('//h1[text()="Dashboard"]')), 4000).then(function () {
|
|
|
+ execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
+ done();
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|