Skip to content

Commit

Permalink
expose mfa for inline tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshanmugam committed Sep 17, 2024
1 parent ca24ebd commit 6ec81a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions __tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ describe('CLI', () => {
expect(await cli.exitCode).toBe(0);
});

it('generate mfa totp token', async () => {
const cli = new CLIMock(true)
.stdin(
`step('gen mfa totp', async () => {
const token = mfa.totp('JBSWY3DPEHPK3PXP');
expect(token.length).toBe(6);
})`
)
.args(['--inline', '--params', JSON.stringify(serverParams)])
.run();
expect(await cli.exitCode).toBe(0);
});

it('exit with 1 on syntax errors', async () => {
const cli = new CLIMock()
.stdin(`step('syntax error', async () => {}})`)
Expand Down
3 changes: 3 additions & 0 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { CliArgs } from './common_types';
import { step, journey } from './core';
import { log } from './core/logger';
import { expect } from './core/expect';
import * as mfa from "./core/mfa";
import {
isDepInstalled,
isDirectory,
Expand Down Expand Up @@ -91,6 +92,7 @@ const loadInlineScript = source => {
'params',
'expect',
'request',
'mfa',
source
);
journey('inline', ({ page, context, browser, params, request }) => {
Expand All @@ -102,6 +104,7 @@ const loadInlineScript = source => {
params,
expect,
request,
mfa,
]);
});
};
Expand Down

0 comments on commit 6ec81a0

Please sign in to comment.