From e05c7f116adfec21ed2a7455dfeeaa54226e85a7 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 12 Apr 2016 21:01:52 -0700 Subject: [PATCH] get email from profile api --- README.md | 2 +- test/test.js | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 171d214..e05d6c5 100644 --- a/README.md +++ b/README.md @@ -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= EMAIL= PASSWORD= mocha --bail test.js +USERNAME= PASSWORD= mocha --bail test.js ``` diff --git a/test/test.js b/test/test.js index 07118ef..f93af1a 100755 --- a/test/test.js +++ b/test/test.js @@ -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' }); });