forked from pouchdb-community/pouchdb-authentication
-
Notifications
You must be signed in to change notification settings - Fork 0
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
57 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,57 @@ | ||
'use strict'; | ||
|
||
var PouchDB = require('pouchdb-memory'); | ||
var Authentication = require('../lib'); | ||
PouchDB.plugin(Authentication); | ||
|
||
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 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'); | ||
}); | ||
}); | ||
|
||
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(); | ||
}); | ||
}); | ||
|
||
// Blocked by #109 | ||
it.skip('Test admin change user password with basic authentication', function () { | ||
var dbWithBasicAuth = new PouchDB(dbName.replace('http://', 'http://anna:secret@')); | ||
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(); | ||
}); | ||
}); | ||
}); |