Skip to content

Add a command to run totp integration tests as part of the CI #6998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ host of npm scripts to run these tests. The most important commands are:
| `yarn test:<platform>:unit:debug` | Runs \<platform> unit tests, auto-watching for file system changes |
| `yarn test:<platform>:integration` | Runs only integration tests against the live environment |
| `yarn test:<platform>:integration:local` | Runs all headless \<platform> integration tests against the emulator (more below) |
| `yarn test:browser:integration:prodbackend` | Runs TOTP MFA integration tests against the backend (more below) |

Where \<platform> is "browser" or "node". There are also cordova tests, but they
are not broken into such granular details. Check out `package.json` for more.
Expand Down Expand Up @@ -46,6 +47,25 @@ you would simply execute the following command:
firebase emulators:exec --project foo-bar --only auth "yarn test:integration:local"
```

### Integration testing with the production backend

Currently, MFA TOTP tests only run against the production backend (since they are not supported on the emulator yet).
Running against the backend also makes it a more reliable end-to-end test.

The TOTP tests require the following email/password combination to exist in the project, so if you are running this test against your test project, please create this user:

'[email protected]', 'password'

You also need to verify this email address, in order to use MFA. This can be done with a curl command like this:

```
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" -H "X-Goog-User-Project: ${PROJECT_ID}" -X POST https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode -d '{
"email": "[email protected]",
"requestType": "VERIFY_EMAIL",
"returnOobLink": true,
}'
```

### Selenium Webdriver tests

These tests assume that you have both Firefox and Chrome installed on your
Expand Down
3 changes: 3 additions & 0 deletions packages/auth/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ function getTestFiles(argv) {
if (argv.unit) {
return ['src/**/*.test.ts', 'test/helpers/**/*.test.ts'];
} else if (argv.integration) {
if (argv.prodbackend) {
return ['test/integration/flows/totp.test.ts'];
}
return argv.local
? ['test/integration/flows/*.test.ts']
: ['test/integration/flows/*!(local).test.ts'];
Expand Down
3 changes: 2 additions & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts && ls scripts/*.js | xargs -I % sh -c 'terser % -o %'",
"dev": "rollup -c -w",
"test": "run-p lint test:all",
"test:all": "run-p test:browser:unit test:node:unit test:integration",
"test:all": "run-p test:browser:unit test:node:unit test:integration test:browser:integration:prodbackend",
"test:integration": "firebase emulators:exec --project emulatedproject --only auth \"run-s test:browser:integration:local test:node:integration:local test:webdriver\"",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
"test:integration:local": "run-s test:node:integration:local test:browser:integration:local test:webdriver",
"test:browser": "karma start --single-run --local",
"test:browser:unit": "karma start --single-run --unit",
"test:browser:integration": "karma start --single-run --integration",
"test:browser:integration:local": "karma start --single-run --integration --local",
"test:browser:integration:prodbackend": "karma start --single-run --integration --prodbackend",
"test:browser:debug": "karma start --auto-watch",
"test:browser:unit:debug": "karma start --auto-watch --unit",
"test:cordova": "karma start --single-run --cordova",
Expand Down