Skip to content

Commit

Permalink
test(ajax): admin changing user password with basic authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitjes committed Nov 22, 2017
1 parent 7ab4d2d commit 8a6df2e
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/test.issue.109.js
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();
});
});
});

0 comments on commit 8a6df2e

Please sign in to comment.