make users-test work
This commit is contained in:
+24
-25
@@ -15,7 +15,7 @@ const BoxError = require('../boxerror.js'),
|
||||
_ = require('underscore');
|
||||
|
||||
describe('User', function () {
|
||||
const { domainSetup, cleanup, admin, user, auditSource } = common;
|
||||
const { domainSetup, cleanup, admin, user, auditSource, checkMails, clearMailQueue } = common;
|
||||
|
||||
async function cleanupUsers() {
|
||||
for (const u of await users.getAll()) {
|
||||
@@ -171,8 +171,8 @@ describe('User', function () {
|
||||
it('can get by resetToken', async function () {
|
||||
user.resetToken = new Array(64).fill('X').join('');
|
||||
await users.update(user, { resetToken: user.resetToken }, auditSource);
|
||||
const user = await users.getByResetToken(user.resetToken);
|
||||
checkUser(user, user);
|
||||
const result = await users.getByResetToken(user.resetToken);
|
||||
checkUser(result, user);
|
||||
});
|
||||
|
||||
it('can getAll', async function () {
|
||||
@@ -213,22 +213,22 @@ describe('User', function () {
|
||||
expect(error.reason).to.equal(BoxError.BAD_FIELD);
|
||||
});
|
||||
|
||||
xit('cannot update the user with already existing email', async function () {
|
||||
it('cannot update the user with already existing email', async function () {
|
||||
const result = await users.add(user.email, user, auditSource);
|
||||
user.id = result;
|
||||
|
||||
const [error] = await safe(users.update(admin, { email: user.email }), auditSource);
|
||||
const [error] = await safe(users.update(admin, { email: user.email }, auditSource));
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
expect(error.message).to.equal('email already exists');
|
||||
});
|
||||
|
||||
xit('can update the user with already existing username', async function () {
|
||||
const [error] = await safe(users.update(admin, { username: user.username }), auditSource);
|
||||
it('can update the user with already existing username', async function () {
|
||||
const [error] = await safe(users.update(admin, { username: user.username }, auditSource));
|
||||
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
|
||||
expect(error.message).to.equal('username already exists');
|
||||
});
|
||||
|
||||
xit('can update the user', async function () {
|
||||
it('can update the user', async function () {
|
||||
await users.update(admin, { email: 'some@thing.com', displayName: 'Heiter' }, auditSource);
|
||||
const user = await users.get(admin.id);
|
||||
expect(user.email).to.equal('some@thing.com');
|
||||
@@ -488,13 +488,13 @@ describe('User', function () {
|
||||
expect(error.reason).to.equal(BoxError.INVALID_CREDENTIALS);
|
||||
});
|
||||
|
||||
xit('actually changed the password (login with new password)', async function () {
|
||||
it('actually changed the password (login with new password)', async function () {
|
||||
await users.verify(admin.id, 'ThisIsNew1Password', users.AP_WEBADMIN);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sendPasswordResetByIdentifier', function () {
|
||||
before(cleanupUsers);
|
||||
before(createOwner);
|
||||
|
||||
it('fails due to unkown email', async function () {
|
||||
const [error] = await safe(users.sendPasswordResetByIdentifier('unknown@mail.com', auditSource));
|
||||
@@ -507,13 +507,15 @@ describe('User', function () {
|
||||
});
|
||||
|
||||
it('succeeds with email', async function () {
|
||||
await users.sendPasswordResetByIdentifier(admin.email);
|
||||
// checkMails(1, done);
|
||||
await clearMailQueue();
|
||||
await users.sendPasswordResetByIdentifier(admin.email, auditSource);
|
||||
await checkMails(1);
|
||||
});
|
||||
|
||||
it('succeeds with username', async function () {
|
||||
await users.sendPasswordResetByIdentifier(admin.username);
|
||||
// checkMails(1, done);
|
||||
await clearMailQueue();
|
||||
await users.sendPasswordResetByIdentifier(admin.username, auditSource);
|
||||
await checkMails(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -525,19 +527,16 @@ describe('User', function () {
|
||||
expect(error.reason).to.be(BoxError.CONFLICT);
|
||||
});
|
||||
|
||||
it('can create token', function (done) {
|
||||
users.createInvite(userObject, function (error, resetToken) {
|
||||
expect(error).to.be(null);
|
||||
expect(resetToken).to.be.ok();
|
||||
done();
|
||||
});
|
||||
it('can create token', async function () {
|
||||
const { resetToken, inviteLink } = await users.createInvite(admin, auditSource);
|
||||
expect(resetToken).to.be.ok();
|
||||
expect(inviteLink).to.be.ok();
|
||||
});
|
||||
|
||||
it('send invite', function (done) {
|
||||
users.sendInvite(userObject, { }, function (error) {
|
||||
expect(error).to.be(null);
|
||||
checkMails(1, done);
|
||||
});
|
||||
it('send invite', async function () {
|
||||
await clearMailQueue();
|
||||
await users.sendInvite(admin, {});
|
||||
await checkMails(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user