Skip to content

Commit 1804817

Browse files
committed
fix: stub requireAuth in spec and enable auth on App Check Client for CI runner
1 parent 6dd0076 commit 1804817

3 files changed

Lines changed: 45 additions & 1 deletion

File tree

PULL_REQUEST_DESCRIPTION.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
### Description
2+
3+
Refactors and standardizes the Firebase CLI App Check debug token workflow under the unified `appcheck:debugtoken` namespace, aligning directly with the backend REST API (`projects.apps.debugTokens`).
4+
5+
Key changes:
6+
- Unified command registration in `src/commands/index.ts` under `client.appcheck.debugtoken`.
7+
- Refactored `appcheck:debugtoken` interactive wizard to discover project/app context dynamically, prompt for display names, and register tokens directly with the App Check backend.
8+
- Added `appcheck:debugtoken:create` for headless/non-interactive script execution and CI/CD automation pipelines.
9+
- Implemented `appcheck:debugtoken:list` to render registered tokens in tabular format (`Display Name`, `Resource Name`, `Update Time`) with full backend pagination.
10+
- Implemented `appcheck:debugtoken:delete` to permanently revoke tokens by ID or resource path, supporting interactive confirmation and `--force` flag overrides.
11+
- Cleaned up obsolete unlinked handlers (`appcheck-debugtokens-get` and `appcheck-debugtokens-update`).
12+
13+
### Scenarios Tested
14+
15+
- **Interactive Wizard (`appcheck:debugtoken`)**: Tested running with no arguments to verify automatic app detection and interactive choice selection.
16+
- **Explicit Arguments (`appcheck:debugtoken <appId> <debugToken>`)**: Tested supplying `appId` and `debugToken` positional arguments to confirm prompt skipping.
17+
- **Display Name Collisions**: Verified interactive confirmation prompt asking whether to overwrite when a token with the same display name already exists.
18+
- **Headless Creation (`appcheck:debugtoken:create`)**: Verified execution with `--non-interactive` flag using fallback defaults without blocking prompts.
19+
- **Token Listing (`appcheck:debugtoken:list`)**: Verified table rendering of returned tokens and multi-page pagination handling.
20+
- **Token Revocation (`appcheck:debugtoken:delete`)**: Tested interactive deletion confirmation as well as non-interactive `--force` deletion.
21+
- **Build & Test Suite**: Ran `npm run build` and `npx mocha src/appcheck/index.spec.ts` & `src/commands/appcheck-debug.spec.ts` (12/12 unit tests passing).
22+
23+
### Sample Commands
24+
25+
```bash
26+
# Interactive wizard: Register a token copied from SDK logs
27+
firebase appcheck:debugtoken 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e e3d9b1a0-cf48-4389-8d19-482a177ffec8
28+
29+
# Interactive wizard: Auto-detect project & prompt for app selection
30+
firebase appcheck:debugtoken
31+
32+
# Non-interactive creation for CI/CD pipelines
33+
firebase appcheck:debugtoken:create 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e e3d9b1a0-cf48-4389-8d19-482a177ffec8 --display-name "CI Runner Token" --non-interactive
34+
35+
# List registered tokens for an app
36+
firebase appcheck:debugtoken:list 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e
37+
38+
# Delete / revoke a token by ID
39+
firebase appcheck:debugtoken:delete 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e 7890-abcd --force
40+
```

src/appcheck/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface ListDebugTokensResponse {
1515

1616
const API_VERSION = "v1";
1717

18-
const client = new Client({ urlPrefix: appCheckOrigin(), apiVersion: API_VERSION });
18+
const client = new Client({ urlPrefix: appCheckOrigin(), auth: true, apiVersion: API_VERSION });
1919

2020
/**
2121
* Creates a new DebugToken for the specified app.

src/commands/appcheck-debug.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { command as debugCmd } from "./appcheck-debug";
66
import { command as createCmd } from "./appcheck-debugtokens-create";
77
import { command as listCmd } from "./appcheck-debugtokens-list";
88
import { command as deleteCmd } from "./appcheck-debugtokens-delete";
9+
import * as requireAuthModule from "../requireAuth";
910
import { appCheckOrigin } from "../api";
1011
import { DebugToken } from "../appcheck";
1112

@@ -26,9 +27,12 @@ describe("appcheck:debugtoken commands", () => {
2627
};
2728

2829
let sandbox: sinon.SinonSandbox;
30+
let requireAuthStub: sinon.SinonStub;
2931

3032
beforeEach(() => {
3133
sandbox = sinon.createSandbox();
34+
requireAuthStub = sandbox.stub(requireAuthModule, "requireAuth");
35+
requireAuthStub.resolves("a@b.com");
3236
});
3337

3438
afterEach(() => {

0 commit comments

Comments
 (0)