merge developer.js into clients.js
This commit is contained in:
@@ -4,7 +4,7 @@ exports = module.exports = {
|
||||
login: login
|
||||
};
|
||||
|
||||
var developer = require('../developer.js'),
|
||||
var clients = require('../clients.js'),
|
||||
passport = require('passport'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
@@ -24,10 +24,10 @@ function login(req, res, next) {
|
||||
if (!verified) return next(new HttpError(401, 'Invalid totpToken'));
|
||||
}
|
||||
|
||||
developer.issueDeveloperToken(user, ip, function (error, result) {
|
||||
clients.issueDeveloperToken(user, ip, function (error, result) {
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200, { token: result.token, expiresAt: result.expiresAt }));
|
||||
next(new HttpSuccess(200, result));
|
||||
});
|
||||
})(req, res, next);
|
||||
}
|
||||
|
||||
@@ -134,8 +134,8 @@ describe('Developer API', function () {
|
||||
.send({ username: USERNAME, password: PASSWORD })
|
||||
.end(function (error, result) {
|
||||
expect(result.statusCode).to.equal(200);
|
||||
expect(new Date(result.body.expiresAt).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.token).to.be.a('string');
|
||||
expect(new Date(result.body.expires).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.accessToken).to.be.a('string');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -145,8 +145,8 @@ describe('Developer API', function () {
|
||||
.send({ username: USERNAME.toUpperCase(), password: PASSWORD })
|
||||
.end(function (error, result) {
|
||||
expect(result.statusCode).to.equal(200);
|
||||
expect(new Date(result.body.expiresAt).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.token).to.be.a('string');
|
||||
expect(new Date(result.body.expires).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.accessToken).to.be.a('string');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -156,8 +156,8 @@ describe('Developer API', function () {
|
||||
.send({ username: EMAIL, password: PASSWORD })
|
||||
.end(function (error, result) {
|
||||
expect(result.statusCode).to.equal(200);
|
||||
expect(new Date(result.body.expiresAt).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.token).to.be.a('string');
|
||||
expect(new Date(result.body.expires).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.accessToken).to.be.a('string');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -167,8 +167,8 @@ describe('Developer API', function () {
|
||||
.send({ username: EMAIL.toUpperCase(), password: PASSWORD })
|
||||
.end(function (error, result) {
|
||||
expect(result.statusCode).to.equal(200);
|
||||
expect(new Date(result.body.expiresAt).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.token).to.be.a('string');
|
||||
expect(new Date(result.body.expires).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.accessToken).to.be.a('string');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -187,7 +187,7 @@ describe('Developer API', function () {
|
||||
},
|
||||
function (callback) {
|
||||
superagent.post(`${SERVER_URL}/api/v1/developer/login`).send({ username: USERNAME, password: PASSWORD }).end(function (error, result) {
|
||||
accessToken = result.body.token;
|
||||
accessToken = result.body.accessToken;
|
||||
callback(error);
|
||||
});
|
||||
},
|
||||
@@ -245,7 +245,7 @@ describe('Developer API', function () {
|
||||
expect(error).to.be(null);
|
||||
expect(result.statusCode).to.equal(200);
|
||||
expect(result.body).to.be.an(Object);
|
||||
expect(result.body.token).to.be.a('string');
|
||||
expect(result.body.accessToken).to.be.a('string');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -264,16 +264,16 @@ describe('Developer API', function () {
|
||||
.end(function (error, result) {
|
||||
expect(result).to.be.ok();
|
||||
|
||||
token_normal = result.body.token;
|
||||
token_normal = result.body.accessToken;
|
||||
|
||||
superagent.post(SERVER_URL + '/api/v1/developer/login')
|
||||
.send({ username: USERNAME, password: PASSWORD })
|
||||
.end(function (error, result) {
|
||||
expect(result.statusCode).to.equal(200);
|
||||
expect(new Date(result.body.expiresAt).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.token).to.be.a('string');
|
||||
expect(new Date(result.body.expires).toString()).to.not.be('Invalid Date');
|
||||
expect(result.body.accessToken).to.be.a('string');
|
||||
|
||||
token_sdk = result.body.token;
|
||||
token_sdk = result.body.accessToken;
|
||||
|
||||
callback();
|
||||
});
|
||||
@@ -286,7 +286,7 @@ describe('Developer API', function () {
|
||||
|
||||
it('fails with non sdk token', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/user/profile/password').query({ access_token: token_normal }).send({ newPassword: 'Some?$123' }).end(function (error, result) {
|
||||
expect(result.statusCode).to.equal(400);
|
||||
expect(result.statusCode).to.equal(401);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -596,7 +596,7 @@ describe('OAuth2', function () {
|
||||
setup,
|
||||
function (callback) {
|
||||
superagent.post(`${SERVER_URL}/api/v1/developer/login`).send({ username: USER_0.username, password: USER_0.password }).end(function (error, result) {
|
||||
accessToken = result.body.token;
|
||||
accessToken = result.body.accessToken;
|
||||
callback(error);
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user