Skip to content

Commit

Permalink
Fix TOTP Required [totp-required] issue
Browse files Browse the repository at this point in the history
* Ref: #18822
  • Loading branch information
shiqimei committed Jan 15, 2021
1 parent 8ffd0e5 commit 117da01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion tests/data/api-data.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { createHash } from 'crypto';

import supertest from 'supertest';

import { publicChannelName, privateChannelName } from './channel.js';
Expand Down Expand Up @@ -31,6 +33,8 @@ export const integration = {};
export const credentials = {
'X-Auth-Token': undefined,
'X-User-Id': undefined,
'x-2fa-code': undefined,
'x-2fa-method': 'password',
};
export const login = {
user: adminUsername,
Expand All @@ -49,14 +53,18 @@ export function log(res) {
});
}

export function getCredentials(done = function() {}) {
export function getCredentials(done = function() { }) {
request.post(api('login'))
.send(login)
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
const code = createHash('sha256')
.update(adminPassword)
.digest('hex');
credentials['X-Auth-Token'] = res.body.data.authToken;
credentials['X-User-Id'] = res.body.data.userId;
credentials['x-2fa-code'] = code;
})
.end(done);
}
3 changes: 2 additions & 1 deletion tests/end-to-end/apps/mocha-e2e.opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = {
reporter: 'spec',
ui: 'bdd',
extension: 'js,ts',
timeout: 10000,
// 1 min timout is acceptable in CI
timeout: 60000,
bail: true,
file: 'tests/end-to-end/teardown.js',
spec: [
Expand Down

0 comments on commit 117da01

Please sign in to comment.