get email from profile api

This commit is contained in:
Girish Ramakrishnan 2016-04-12 21:01:52 -07:00
parent 4bb22336f6
commit e05c7f116a
2 changed files with 26 additions and 3 deletions

View file

@ -31,6 +31,6 @@ The e2e tests are located in the `test/` folder and require [nodejs](http://node
cd gogs-app/test
npm install
USERNAME=<cloudron username> EMAIL=<cloudron email> PASSWORD=<cloudron password> mocha --bail test.js
USERNAME=<cloudron username> PASSWORD=<cloudron password> mocha --bail test.js
```

View file

@ -33,12 +33,11 @@ describe('Application life cycle test', function () {
var app, reponame = 'testrepo';
var username = process.env.USERNAME;
var password = process.env.PASSWORD;
var email = process.env.EMAIL;
var email, token;
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'));
if (!process.env.EMAIL) return done(new Error('EMAIL env var not set'));
var seleniumJar= require('selenium-server-standalone-jar');
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
@ -59,6 +58,30 @@ 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' });
});