Skip to content

Commit 57c32b9

Browse files
authored
Add a command to run totp integration tests. (#6998)
1 parent 44f34e3 commit 57c32b9

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

packages/auth/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ host of npm scripts to run these tests. The most important commands are:
1717
| `yarn test:<platform>:unit:debug` | Runs \<platform> unit tests, auto-watching for file system changes |
1818
| `yarn test:<platform>:integration` | Runs only integration tests against the live environment |
1919
| `yarn test:<platform>:integration:local` | Runs all headless \<platform> integration tests against the emulator (more below) |
20+
| `yarn test:browser:integration:prodbackend` | Runs TOTP MFA integration tests against the backend (more below) |
2021

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

50+
### Integration testing with the production backend
51+
52+
Currently, MFA TOTP tests only run against the production backend (since they are not supported on the emulator yet).
53+
Running against the backend also makes it a more reliable end-to-end test.
54+
55+
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:
56+
57+
'[email protected]', 'password'
58+
59+
You also need to verify this email address, in order to use MFA. This can be done with a curl command like this:
60+
61+
```
62+
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 '{
63+
"email": "[email protected]",
64+
"requestType": "VERIFY_EMAIL",
65+
"returnOobLink": true,
66+
}'
67+
```
68+
4969
### Selenium Webdriver tests
5070

5171
These tests assume that you have both Firefox and Chrome installed on your

packages/auth/karma.conf.js

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ function getTestFiles(argv) {
3737
if (argv.unit) {
3838
return ['src/**/*.test.ts', 'test/helpers/**/*.test.ts'];
3939
} else if (argv.integration) {
40+
if (argv.prodbackend) {
41+
return ['test/integration/flows/totp.test.ts'];
42+
}
4043
return argv.local
4144
? ['test/integration/flows/*.test.ts']
4245
: ['test/integration/flows/*!(local).test.ts'];

packages/auth/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@
7676
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts && ls scripts/*.js | xargs -I % sh -c 'terser % -o %'",
7777
"dev": "rollup -c -w",
7878
"test": "run-p lint test:all",
79-
"test:all": "run-p test:browser:unit test:node:unit test:integration",
79+
"test:all": "run-p test:browser:unit test:node:unit test:integration test:browser:integration:prodbackend",
8080
"test:integration": "firebase emulators:exec --project emulatedproject --only auth \"run-s test:browser:integration:local test:node:integration:local test:webdriver\"",
8181
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all",
8282
"test:integration:local": "run-s test:node:integration:local test:browser:integration:local test:webdriver",
8383
"test:browser": "karma start --single-run --local",
8484
"test:browser:unit": "karma start --single-run --unit",
8585
"test:browser:integration": "karma start --single-run --integration",
8686
"test:browser:integration:local": "karma start --single-run --integration --local",
87+
"test:browser:integration:prodbackend": "karma start --single-run --integration --prodbackend",
8788
"test:browser:debug": "karma start --auto-watch",
8889
"test:browser:unit:debug": "karma start --auto-watch --unit",
8990
"test:cordova": "karma start --single-run --cordova",

0 commit comments

Comments
 (0)