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 23, 2017
1 parent cb8991d commit a80b456
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions test/test.issue.109.js
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();
});
});
});

0 comments on commit a80b456

Please sign in to comment.