Skip to content

Commit 4a3d095

Browse files
expose mfa for inline tests
1 parent ca24ebd commit 4a3d095

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

__tests__/cli.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ describe('CLI', () => {
9292
expect(await cli.exitCode).toBe(0);
9393
});
9494

95+
it('generate mfa totp token', async () => {
96+
const cli = new CLIMock(true)
97+
.stdin(
98+
`step('gen mfa totp', async () => {
99+
const token = mfa.totp('FLIIOLP3IR3W');
100+
expect(token.length).toBe(6);
101+
})`
102+
)
103+
.args(['--inline', '--params', JSON.stringify(serverParams)])
104+
.run();
105+
expect(await cli.exitCode).toBe(0);
106+
});
107+
95108
it('exit with 1 on syntax errors', async () => {
96109
const cli = new CLIMock()
97110
.stdin(`step('syntax error', async () => {}})`)

src/loader.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { CliArgs } from './common_types';
2929
import { step, journey } from './core';
3030
import { log } from './core/logger';
3131
import { expect } from './core/expect';
32+
import * as mfa from "./core/mfa";
3233
import {
3334
isDepInstalled,
3435
isDirectory,
@@ -91,6 +92,7 @@ const loadInlineScript = source => {
9192
'params',
9293
'expect',
9394
'request',
95+
'mfa',
9496
source
9597
);
9698
journey('inline', ({ page, context, browser, params, request }) => {
@@ -102,6 +104,7 @@ const loadInlineScript = source => {
102104
params,
103105
expect,
104106
request,
107+
mfa,
105108
]);
106109
});
107110
};

0 commit comments

Comments
 (0)