-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ajax): admin changing user password with basic authentication
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict'; | ||
|
||
var PouchDB = require('pouchdb-memory'); | ||
var Authentication = require('../lib'); | ||
PouchDB.plugin(Authentication); | ||
|
||
var utils = require('./test-utils'); | ||
var chai = require('chai'); | ||
chai.should(); | ||
|
||
describe('issue-109', function () { | ||
|
||
var dbName = 'http://localhost:5984/testdb'; | ||
|
||
var db; | ||
|
||
beforeEach(function () { | ||
db = new PouchDB(dbName); | ||
return utils.ensureUsersDatabaseExists(db).then(function () { | ||
return db.signUpAdmin('anna', 'secret'); | ||
}).then(function () { | ||
return db.signUp('spiderman', 'will-forget'); | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
return db.logIn('anna', 'secret').then(function () { | ||
return db.deleteUser('spiderman'); | ||
}).then(function () { | ||
return db.deleteAdmin('anna'); | ||
}).then(function () { | ||
return db.logOut(); | ||
}).then(function () { | ||
return db.destroy(); | ||
}); | ||
}); | ||
|
||
it('Test admin change user password with cookie authentication', function () { | ||
return db.logIn('anna', 'secret').then(function () { | ||
return db.changePassword('spiderman', 'will-remember'); | ||
}).then(function (res) { | ||
res.ok.should.equal(true); | ||
}).then(function () { | ||
return db.logIn('spiderman', 'will-remember'); | ||
}).then(function (res) { | ||
res.ok.should.equal(true); | ||
}).then(function () { | ||
return db.logOut(); | ||
}); | ||
}); | ||
|
||
it('Test admin change user password with basic authentication', function () { | ||
var dbNameWithAuth = dbName.replace('http://', 'http://anna:secret@'); | ||
var dbWithBasicAuth = new PouchDB(dbNameWithAuth, {skip_setup: true}); | ||
return dbWithBasicAuth.changePassword('spiderman', 'will-remember').then(function (res) { | ||
res.ok.should.equal(true); | ||
}).then(function () { | ||
return db.logIn('spiderman', 'will-remember'); | ||
}).then(function (res) { | ||
res.ok.should.equal(true); | ||
}).then(function () { | ||
return db.logOut(); | ||
}); | ||
}); | ||
}); |