Merge pull request #1301 from strongloop/feature/disable-include-access-tokens

Upgrade test fixtures to 2.x project layouts
This commit is contained in:
Raymond Feng 2015-04-20 11:43:19 -07:00
commit ca004adfc6
45 changed files with 495 additions and 389 deletions

View File

@ -79,7 +79,7 @@
"karma-mocha": "^0.1.10",
"karma-phantomjs-launcher": "^0.1.4",
"karma-script-launcher": "^0.1.0",
"loopback-boot": "^1.1.0",
"loopback-boot": "^2.7.0",
"loopback-datasource-juggler": "^2.19.1",
"loopback-testing": "^1.1.0",
"mocha": "^2.1.0",

View File

@ -4,7 +4,7 @@ var loopback = require('../');
var lt = require('loopback-testing');
var path = require('path');
var ACCESS_CONTROL_APP = path.join(__dirname, 'fixtures', 'access-control');
var app = require(path.join(ACCESS_CONTROL_APP, 'app.js'));
var app = require(path.join(ACCESS_CONTROL_APP, 'server/server.js'));
var assert = require('assert');
var USER = {email: 'test@test.test', password: 'test'};
var CURRENT_USER = {email: 'current@test.test', password: 'test'};

View File

@ -1,6 +1,8 @@
var loopback = require('../');
var extend = require('util')._extend;
var Token = loopback.AccessToken.extend('MyToken');
var ds = loopback.createDataSource({connector: loopback.Memory});
Token.attachTo(ds);
var ACL = loopback.ACL;
describe('loopback.token(options)', function() {

View File

@ -1,4 +0,0 @@
{
"port": 3000,
"host": "0.0.0.0"
}

View File

@ -0,0 +1,19 @@
{
"name": "accessToken",
"base": "AccessToken",
"baseUrl": "access-tokens",
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
},
{
"permission": "ALLOW",
"principalType": "ROLE",
"principalId": "$everyone",
"property": "create"
}
]
}

View File

@ -0,0 +1,42 @@
{
"name": "account",
"relations": {
"transactions": {
"model": "transaction",
"type": "hasMany"
},
"user": {
"model": "user",
"type": "belongsTo",
"foreignKey": "userId"
}
},
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
},
{
"accessType": "*",
"permission": "ALLOW",
"principalType": "ROLE",
"principalId": "$owner"
},
{
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$owner",
"property": "deleteById"
},
{
"accessType": "*",
"permission": "DENY",
"property": "find",
"principalType": "ROLE",
"principalId": "$dummy"
}
],
"properties": {}
}

View File

@ -0,0 +1,12 @@
{
"name": "alert",
"acls": [
{
"accessType": "WRITE",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
}
],
"properties": {}
}

View File

@ -0,0 +1,28 @@
{
"name": "bank",
"relations": {
"users": {
"model": "user",
"type": "hasMany"
},
"accounts": {
"model": "account",
"type": "hasMany"
}
},
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
},
{
"accessType": "READ",
"permission": "ALLOW",
"principalType": "ROLE",
"principalId": "$everyone"
}
],
"properties": {}
}

View File

@ -0,0 +1,12 @@
{
"name": "email",
"base": "Email",
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
}
]
}

View File

@ -0,0 +1,12 @@
{
"name": "transaction",
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
}
],
"properties": {}
}

View File

@ -0,0 +1,23 @@
{
"name": "user",
"base": "User",
"relations": {
"accessTokens": {
"model": "accessToken",
"type": "hasMany",
"foreignKey": "userId"
},
"transactions": {
"model": "transaction",
"type": "hasMany"
}
},
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
}
]
}

View File

@ -1,171 +0,0 @@
{
"email": {
"options": {
"base": "Email",
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
}
]
},
"dataSource": "mail",
"public": false
},
"user": {
"options": {
"base": "User",
"relations": {
"accessTokens": {
"model": "accessToken",
"type": "hasMany",
"foreignKey": "userId"
},
"transactions": {
"model": "transaction",
"type": "hasMany"
}
},
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
}
]
},
"dataSource": "db",
"public": true
},
"accessToken": {
"options": {
"base": "AccessToken",
"baseUrl": "access-tokens",
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
},
{
"permission": "ALLOW",
"principalType": "ROLE",
"principalId": "$everyone",
"property": "create"
}
]
},
"dataSource": "db",
"public": true
},
"bank": {
"options": {
"relations": {
"users": {
"model": "user",
"type": "hasMany"
},
"accounts": {
"model": "account",
"type": "hasMany"
}
},
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
},
{
"accessType": "READ",
"permission": "ALLOW",
"principalType": "ROLE",
"principalId": "$everyone"
}
]
},
"properties": {},
"public": true,
"dataSource": "db"
},
"account": {
"options": {
"relations": {
"transactions": {
"model": "transaction",
"type": "hasMany"
},
"user": {
"model": "user",
"type": "belongsTo",
"foreignKey": "userId"
}
},
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
},
{
"accessType": "*",
"permission": "ALLOW",
"principalType": "ROLE",
"principalId": "$owner"
},
{
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$owner",
"property": "deleteById"
},
{
"accessType": "*",
"permission": "DENY",
"property": "find",
"principalType": "ROLE",
"principalId": "$dummy"
}
]
},
"properties": {},
"public": true,
"dataSource": "db"
},
"transaction": {
"options": {
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
}
]
},
"properties": {},
"public": true,
"dataSource": "db"
},
"alert": {
"options": {
"acls": [
{
"accessType": "WRITE",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
}
]
},
"properties": {},
"public": true,
"dataSource": "db"
}
}

View File

@ -0,0 +1,5 @@
{
"port": 3000,
"host": "0.0.0.0",
"legacyExplorer": false
}

View File

@ -1,10 +1,8 @@
{
"db": {
"defaultForType": "db",
"connector": "memory"
},
"mail": {
"defaultForType": "mail",
"connector": "mail"
}
}

View File

@ -0,0 +1,48 @@
{
"_meta": {
"sources": [
"../common/models",
"./models"
]
},
"ACL": {
"dataSource": "db",
"public": false
},
"RoleMapping": {
"dataSource": "db",
"public": false
},
"Role": {
"dataSource": "db",
"public": false
},
"email": {
"dataSource": "mail",
"public": false
},
"user": {
"dataSource": "db",
"public": true
},
"accessToken": {
"dataSource": "db",
"public": true
},
"bank": {
"public": true,
"dataSource": "db"
},
"account": {
"public": true,
"dataSource": "db"
},
"transaction": {
"public": true,
"dataSource": "db"
},
"alert": {
"public": true,
"dataSource": "db"
}
}

View File

@ -1,12 +1,10 @@
var loopback = require('../../../');
var loopback = require('../../../..');
var boot = require('loopback-boot');
var path = require('path');
var app = module.exports = loopback();
boot(app, __dirname);
var apiPath = '/api';
app.use(loopback.cookieParser('secret'));
app.use(loopback.token({model: app.models.accessToken}));
app.use(apiPath, loopback.rest());

View File

@ -1,4 +1,4 @@
var loopback = require('../../../');
var loopback = require('../../../../index');
var PersistedModel = loopback.PersistedModel;
exports.TestModel = PersistedModel.extend('TestModel', {}, {

View File

@ -1,11 +1,8 @@
var loopback = require('../../../');
var path = require('path');
var loopback = require('../../../../index');
var app = module.exports = loopback();
var models = require('./models');
var TestModel = models.TestModel;
// var explorer = require('loopback-explorer');
app.use(loopback.cookieParser({secret: app.get('cookieSecret')}));
var apiPath = '/api';
app.use(apiPath, loopback.rest());
@ -13,8 +10,6 @@ TestModel.attachTo(loopback.memory());
app.model(TestModel);
app.model(TestModel.getChangeModel());
// app.use('/explorer', explorer(app, {basePath: apiPath}));
app.use(loopback.static(path.join(__dirname, 'public')));
// app.use(loopback.static(path.join(__dirname, 'public')));
app.use(loopback.urlNotFound());
app.use(loopback.errorHandler());

View File

@ -1,4 +0,0 @@
{
"port": 3000,
"host": "127.0.0.1"
}

View File

@ -0,0 +1,3 @@
module.exports = function(Bar) {
process.loadedBarJS = true;
};

View File

@ -0,0 +1,4 @@
{
"name": "bar",
"properties": {}
}

View File

@ -0,0 +1,4 @@
{
"name": "foo",
"properties": {}
}

View File

@ -1,5 +0,0 @@
{
"foo": {
"dataSource": "db"
}
}

View File

@ -1 +0,0 @@
process.loadedBarJS = true;

View File

@ -0,0 +1,5 @@
{
"port": 3000,
"host": "127.0.0.1",
"legacyExplorer": false
}

View File

@ -0,0 +1,31 @@
{
"_meta": {
"sources": [
"../common/models",
"./models"
]
},
"User": {
"dataSource": "db",
"public": false
},
"AccessToken": {
"dataSource": "db",
"public": false
},
"ACL": {
"dataSource": "db",
"public": false
},
"RoleMapping": {
"dataSource": "db",
"public": false
},
"Role": {
"dataSource": "db",
"public": false
},
"foo": {
"dataSource": "db"
}
}

View File

@ -0,0 +1,4 @@
{
"name": "accessToken",
"base": "AccessToken"
}

View File

@ -0,0 +1,20 @@
{
"name": "appointment",
"properties": {
"date": "date"
},
"options": {
"relations": {
"physician": {
"model": "physician",
"type": "belongsTo",
"foreignKey": "physicianId"
},
"patient": {
"model": "patient",
"type": "belongsTo",
"foreignKey": "patientId"
}
}
}
}

View File

@ -0,0 +1,16 @@
{
"name": "customer",
"base": "PersistedModel",
"properties": {
"name": {
"type": "string",
"required": true
}
},
"relations": {
"profile": {
"type": "hasOne",
"model": "profile"
}
}
}

View File

@ -0,0 +1,12 @@
{
"name": "email",
"base": "Email",
"acls": [
{
"accessType": "*",
"permission": "DENY",
"principalType": "ROLE",
"principalId": "$everyone"
}
]
}

View File

@ -0,0 +1,16 @@
{
"name": "patient",
"properties": {
"name": "string"
},
"options": {
"relations": {
"physicians": {
"model": "physician",
"type": "hasMany",
"through": "appointment",
"foreignKey": "physicianId"
}
}
}
}

View File

@ -0,0 +1,14 @@
{
"name": "physician",
"properties": {
"name": "string"
},
"relations": {
"patients": {
"model": "patient",
"type": "hasMany",
"through": "appointment",
"foreignKey": "patientId"
}
}
}

View File

@ -0,0 +1,9 @@
{
"name": "profile",
"base": "PersistedModel",
"properties": {
"points": {
"type": "number"
}
}
}

View File

@ -0,0 +1,17 @@
{
"name": "store",
"properties": {},
"scopes": {
"superStores": {
"where": {
"size": "super"
}
}
},
"relations": {
"widgets": {
"model": "widget",
"type": "hasMany"
}
}
}

View File

@ -0,0 +1,11 @@
{
"name": "user",
"base": "User",
"relations": {
"accessTokens": {
"model": "accessToken",
"type": "hasMany",
"foreignKey": "userId"
}
}
}

View File

@ -0,0 +1,10 @@
{
"name": "widget",
"properties": {},
"relations": {
"store": {
"model": "store",
"type": "belongsTo"
}
}
}

View File

@ -1,145 +0,0 @@
{
"email": {
"dataSource": "mail",
"public": false,
"options": {
"base": "Email"
}
},
"user": {
"dataSource": "db",
"public": true,
"options": {
"base": "User",
"relations": {
"accessTokens": {
"model": "accessToken",
"type": "hasMany",
"foreignKey": "userId"
}
}
}
},
"accessToken": {
"dataSource": "db",
"public": true,
"options": {
"base": "AccessToken"
}
},
"widget": {
"properties": {},
"public": true,
"dataSource": "db",
"options": {
"relations": {
"store": {
"model": "store",
"type": "belongsTo"
}
}
}
},
"store": {
"properties": {},
"public": true,
"dataSource": "db",
"options": {
"scopes": {
"superStores": {
"where": {
"size": "super"
}
}
},
"relations": {
"widgets": {
"model": "widget",
"type": "hasMany"
}
}
}
},
"physician": {
"dataSource": "db",
"public": true,
"properties": {
"name": "string"
},
"options": {
"relations": {
"patients": {
"model": "patient",
"type": "hasMany",
"through": "appointment",
"foreignKey": "patientId"
}
}
}
},
"patient": {
"dataSource": "db",
"public": true,
"properties": {
"name": "string"
},
"options": {
"relations": {
"physicians": {
"model": "physician",
"type": "hasMany",
"through": "appointment",
"foreignKey": "physicianId"
}
}
}
},
"appointment": {
"dataSource": "db",
"public": true,
"properties": {
"date": "date"
},
"options": {
"relations": {
"physician": {
"model": "physician",
"type": "belongsTo",
"foreignKey": "physicianId"
},
"patient": {
"model": "patient",
"type": "belongsTo",
"foreignKey": "patientId"
}
}
}
},
"customer": {
"base": "PersistedModel",
"dataSource": "db",
"public": true,
"properties": {
"name": {
"type": "string",
"required": true
}
},
"relations": {
"profile": {
"type": "hasOne",
"model": "profile"
}
}
},
"profile": {
"base": "PersistedModel",
"dataSource": "db",
"public": true,
"properties": {
"points": {
"type": "number"
}
}
}
}

View File

@ -10,5 +10,6 @@
"urlencoded": {
"limit": "8kb"
}
}
},
"legacyExplorer": false
}

View File

@ -1,10 +1,8 @@
{
"db": {
"defaultForType": "db",
"connector": "memory"
},
"mail": {
"defaultForType": "mail",
"connector": "mail"
}
}

View File

@ -0,0 +1,60 @@
{
"_meta": {
"sources": [
"../common/models",
"./models"
]
},
"ACL": {
"dataSource": "db",
"public": false
},
"RoleMapping": {
"dataSource": "db",
"public": false
},
"Role": {
"dataSource": "db",
"public": false
},
"email": {
"dataSource": "mail",
"public": false
},
"user": {
"dataSource": "db",
"public": true
},
"accessToken": {
"dataSource": "db",
"public": true
},
"widget": {
"public": true,
"dataSource": "db"
},
"store": {
"public": true,
"dataSource": "db"
},
"physician": {
"dataSource": "db",
"public": true
},
"patient": {
"dataSource": "db",
"public": true
},
"appointment": {
"dataSource": "db",
"public": true
},
"customer": {
"dataSource": "db",
"public": true
},
"profile": {
"dataSource": "db",
"public": true
}
}

View File

@ -1,13 +1,9 @@
var loopback = require('../../../');
var loopback = require('../../../../index');
var boot = require('loopback-boot');
var path = require('path');
var app = module.exports = loopback();
boot(app, __dirname);
app.use(loopback.favicon());
app.use(loopback.cookieParser({secret: app.get('cookieSecret')}));
var apiPath = '/api';
app.use(apiPath, loopback.rest());
app.use(loopback.static(path.join(__dirname, 'public')));
app.use(loopback.urlNotFound());
app.use(loopback.errorHandler());

View File

@ -4,7 +4,7 @@ var loopback = require('../');
var lt = require('loopback-testing');
var path = require('path');
var SIMPLE_APP = path.join(__dirname, 'fixtures', 'simple-integration-app');
var app = require(path.join(SIMPLE_APP, 'app.js'));
var app = require(path.join(SIMPLE_APP, 'server/server.js'));
var assert = require('assert');
var expect = require('chai').expect;
var debug = require('debug')('loopback:test:relations.integration');

View File

@ -2,7 +2,7 @@ var loopback = require('../');
var lt = require('loopback-testing');
var path = require('path');
var SIMPLE_APP = path.join(__dirname, 'fixtures', 'simple-integration-app');
var app = require(path.join(SIMPLE_APP, 'app.js'));
var app = require(path.join(SIMPLE_APP, 'server/server.js'));
var assert = require('assert');
describe('remoting - integration', function() {

View File

@ -1,5 +1,7 @@
require('./support');
var loopback = require('../');
var User;
var AccessToken = loopback.AccessToken;
var AccessToken;
var MailConnector = require('../lib/connectors/mail');
var userMemory = loopback.createDataSource({
@ -16,14 +18,21 @@ describe('User', function() {
var invalidCredentials = {email: 'foo1@bar.com', password: 'invalid'};
var incompleteCredentials = {password: 'bar1'};
var defaultApp;
beforeEach(function() {
User = loopback.User.extend('user');
// FIXME: [rfeng] Remove loopback.User.app so that remote hooks don't go
// to the wrong app instance
defaultApp = loopback.User.app;
loopback.User.app = null;
User = loopback.User.extend('TestUser', {}, {http: {path: 'test-users'}});
AccessToken = loopback.AccessToken.extend('TestAccessToken');
User.email = loopback.Email.extend('email');
loopback.autoAttach();
// Update the AccessToken relation to use the subclass of User
AccessToken.belongsTo(User);
User.hasMany(AccessToken);
AccessToken.belongsTo(User, {as: 'user', foreignKey: 'userId'});
User.hasMany(AccessToken, {as: 'accessTokens', foreignKey: 'userId'});
// allow many User.afterRemote's to be called
User.setMaxListeners(0);
@ -32,7 +41,7 @@ describe('User', function() {
beforeEach(function(done) {
app.enableAuth();
app.use(loopback.token());
app.use(loopback.token({model: AccessToken}));
app.use(loopback.rest());
app.model(User);
@ -42,6 +51,7 @@ describe('User', function() {
});
afterEach(function(done) {
loopback.User.app = defaultApp;
User.destroyAll(function(err) {
User.accessToken.destroyAll(done);
});
@ -78,7 +88,7 @@ describe('User', function() {
assert(err);
assert.equal(err.name, 'ValidationError');
assert.equal(err.statusCode, 422);
assert.equal(err.details.context, 'user');
assert.equal(err.details.context, User.modelName);
assert.deepEqual(err.details.codes.email, [
'presence',
'format.null'
@ -152,7 +162,7 @@ describe('User', function() {
beforeEach(function() {
defaultHashPassword = User.hashPassword;
defaultValidatePassword = User.defaultValidatePassword;
defaultValidatePassword = User.validatePassword;
User.hashPassword = function(plain) {
return plain.toUpperCase();
@ -168,6 +178,7 @@ describe('User', function() {
afterEach(function() {
User.hashPassword = defaultHashPassword;
User.validatePassword = defaultValidatePassword;
});
it('Reports invalid password', function() {
@ -187,7 +198,7 @@ describe('User', function() {
it('Create a user over REST should remove emailVerified property', function(done) {
request(app)
.post('/users')
.post('/test-users')
.expect('Content-Type', /json/)
.expect(200)
.send(validCredentialsEmailVerifiedOverREST)
@ -299,7 +310,7 @@ describe('User', function() {
it('Login a user over REST by providing credentials', function(done) {
request(app)
.post('/users/login')
.post('/test-users/login')
.expect('Content-Type', /json/)
.expect(200)
.send(validCredentials)
@ -320,7 +331,7 @@ describe('User', function() {
it('Login a user over REST by providing invalid credentials', function(done) {
request(app)
.post('/users/login')
.post('/test-users/login')
.expect('Content-Type', /json/)
.expect(401)
.send(invalidCredentials)
@ -336,7 +347,7 @@ describe('User', function() {
it('Login a user over REST by providing incomplete credentials', function(done) {
request(app)
.post('/users/login')
.post('/test-users/login')
.expect('Content-Type', /json/)
.expect(400)
.send(incompleteCredentials)
@ -352,7 +363,7 @@ describe('User', function() {
it('Login a user over REST with the wrong Content-Type', function(done) {
request(app)
.post('/users/login')
.post('/test-users/login')
.set('Content-Type', null)
.expect('Content-Type', /json/)
.expect(400)
@ -369,7 +380,7 @@ describe('User', function() {
it('Returns current user when `include` is `USER`', function(done) {
request(app)
.post('/users/login?include=USER')
.post('/test-users/login?include=USER')
.send(validCredentials)
.expect(200)
.expect('Content-Type', /json/)
@ -387,7 +398,7 @@ describe('User', function() {
it('should handle multiple `include`', function(done) {
request(app)
.post('/users/login?include=USER&include=Post')
.post('/test-users/login?include=USER&include=Post')
.send(validCredentials)
.expect(200)
.expect('Content-Type', /json/)
@ -447,7 +458,7 @@ describe('User', function() {
it('Login a user over REST when email verification is required', function(done) {
request(app)
.post('/users/login')
.post('/test-users/login')
.expect('Content-Type', /json/)
.expect(200)
.send(validCredentialsEmailVerified)
@ -466,7 +477,7 @@ describe('User', function() {
it('Login a user over REST require complete and valid credentials for email verification error message', function(done) {
request(app)
.post('/users/login')
.post('/test-users/login')
.expect('Content-Type', /json/)
.expect(401)
.send({ email: validCredentialsEmail })
@ -485,7 +496,7 @@ describe('User', function() {
it('Login a user over REST without email verification when it is required', function(done) {
request(app)
.post('/users/login')
.post('/test-users/login')
.expect('Content-Type', /json/)
.expect(401)
.send(validCredentials)
@ -513,8 +524,8 @@ describe('User', function() {
loopback.autoAttach();
// Update the AccessToken relation to use the subclass of User
AccessToken.belongsTo(User);
User.hasMany(AccessToken);
AccessToken.belongsTo(User, {as: 'user', foreignKey: 'userId'});
User.hasMany(AccessToken, {as: 'accessTokens', foreignKey: 'userId'});
// allow many User.afterRemote's to be called
User.setMaxListeners(0);
@ -683,7 +694,7 @@ describe('User', function() {
login(logout);
function login(fn) {
request(app)
.post('/users/login')
.post('/test-users/login')
.expect('Content-Type', /json/)
.expect(200)
.send({email: 'foo@bar.com', password: 'bar'})
@ -702,7 +713,7 @@ describe('User', function() {
function logout(err, token) {
request(app)
.post('/users/logout')
.post('/test-users/logout')
.set('Authorization', token)
.expect(204)
.end(verify(token, done));
@ -792,14 +803,14 @@ describe('User', function() {
assert(result.email.response);
assert(result.token);
var msg = result.email.response.toString('utf-8');
assert(~msg.indexOf('/api/users/confirm'));
assert(~msg.indexOf('/api/test-users/confirm'));
assert(~msg.indexOf('To: bar@bat.com'));
done();
});
});
request(app)
.post('/users')
.post('/test-users')
.expect('Content-Type', /json/)
.expect(200)
.send({email: 'bar@bat.com', password: 'bar'})
@ -832,7 +843,7 @@ describe('User', function() {
});
request(app)
.post('/users')
.post('/test-users')
.expect('Content-Type', /json/)
.expect(200)
.send({email: 'bar@bat.com', password: 'bar'})
@ -878,7 +889,7 @@ describe('User', function() {
});
request(app)
.post('/users')
.post('/test-users')
.expect('Content-Type', /json/)
.expect(200)
.send({email: 'bar@bat.com', password: 'bar'})
@ -917,7 +928,7 @@ describe('User', function() {
});
request(app)
.post('/users')
.post('/test-users')
.expect('Content-Type', /json/)
.expect(200)
.send({email: 'bar@bat.com', password: 'bar'})
@ -955,7 +966,7 @@ describe('User', function() {
});
request(app)
.post('/users')
.post('/test-users')
.expect('Content-Type', /json/)
.expect(302)
.send({email: 'bar@bat.com', password: 'bar'})
@ -969,7 +980,7 @@ describe('User', function() {
it('Confirm a user verification', function(done) {
testConfirm(function(result, done) {
request(app)
.get('/users/confirm?uid=' + (result.uid) +
.get('/test-users/confirm?uid=' + (result.uid) +
'&token=' + encodeURIComponent(result.token) +
'&redirect=' + encodeURIComponent(options.redirect))
.expect(302)
@ -985,7 +996,7 @@ describe('User', function() {
it('Should report 302 when redirect url is set', function(done) {
testConfirm(function(result, done) {
request(app)
.get('/users/confirm?uid=' + (result.uid) +
.get('/test-users/confirm?uid=' + (result.uid) +
'&token=' + encodeURIComponent(result.token) +
'&redirect=http://foo.com/bar')
.expect(302)
@ -997,7 +1008,7 @@ describe('User', function() {
it('Should report 204 when redirect url is not set', function(done) {
testConfirm(function(result, done) {
request(app)
.get('/users/confirm?uid=' + (result.uid) +
.get('/test-users/confirm?uid=' + (result.uid) +
'&token=' + encodeURIComponent(result.token))
.expect(204)
.end(done);
@ -1007,7 +1018,7 @@ describe('User', function() {
it('Report error for invalid user id during verification', function(done) {
testConfirm(function(result, done) {
request(app)
.get('/users/confirm?uid=' + (result.uid + '_invalid') +
.get('/test-users/confirm?uid=' + (result.uid + '_invalid') +
'&token=' + encodeURIComponent(result.token) +
'&redirect=' + encodeURIComponent(options.redirect))
.expect(404)
@ -1026,7 +1037,7 @@ describe('User', function() {
it('Report error for invalid token during verification', function(done) {
testConfirm(function(result, done) {
request(app)
.get('/users/confirm?uid=' + result.uid +
.get('/test-users/confirm?uid=' + result.uid +
'&token=' + encodeURIComponent(result.token) + '_invalid' +
'&redirect=' + encodeURIComponent(options.redirect))
.expect(400)
@ -1081,7 +1092,7 @@ describe('User', function() {
it('Password reset over REST rejected without email address', function(done) {
request(app)
.post('/users/reset')
.post('/test-users/reset')
.expect('Content-Type', /json/)
.expect(400)
.send({ })
@ -1098,7 +1109,7 @@ describe('User', function() {
it('Password reset over REST requires email address', function(done) {
request(app)
.post('/users/reset')
.post('/test-users/reset')
.expect('Content-Type', /json/)
.expect(204)
.send({ email: email })