Skip to content

Commit eba9084

Browse files
Fix apptesting enablement (#8905)
* Fix an issue with apptesting enablement Co-authored-by: Joe Hanley <[email protected]>
1 parent f6c9ed1 commit eba9084

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
- Fixed ext:export command so that it correctly returns system params in the .env file (#8881)
22
- Fixed an issue where the MCP server could not successfully use Application Default Credentials. (#8896)
3+
- Fixed an issue where the incorrect API was enabled for `apptesting` commands.

src/apptesting/ensureProjectConfigured.spec.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,29 @@ describe("ensureProjectConfigured", () => {
4141

4242
await apptesting.ensureProjectConfigured(projectId);
4343

44-
expect(ensureApiEnabledStub).to.be.calledThrice;
45-
expect(ensureApiEnabledStub).to.be.calledWith(projectId, sinon.match.any, "storage", false);
46-
expect(ensureApiEnabledStub).to.be.calledWith(projectId, sinon.match.any, "run", false);
44+
expect(ensureApiEnabledStub).to.be.callCount(4);
4745
expect(ensureApiEnabledStub).to.be.calledWith(
4846
projectId,
49-
sinon.match.any,
50-
"artifactregistry",
47+
"https://firebaseapptesting.googleapis.com",
48+
"Firebase App Testing",
49+
false,
50+
);
51+
expect(ensureApiEnabledStub).to.be.calledWith(
52+
projectId,
53+
"https://run.googleapis.com",
54+
"Cloud Run",
55+
false,
56+
);
57+
expect(ensureApiEnabledStub).to.be.calledWith(
58+
projectId,
59+
"https://storage.googleapis.com",
60+
"Cloud Storage",
61+
false,
62+
);
63+
expect(ensureApiEnabledStub).to.be.calledWith(
64+
projectId,
65+
"https://artifactregistry.googleapis.com",
66+
"Artifact Registry",
5167
false,
5268
);
5369
});

src/apptesting/ensureProjectConfigured.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { addServiceAccountToRoles, serviceAccountHasRoles } from "../gcp/resourceManager";
22
import { ensure } from "../ensureApiEnabled";
3-
import { appTestingOrigin } from "../api";
3+
import { appTestingOrigin, artifactRegistryDomain, cloudRunApiOrigin, storageOrigin } from "../api";
44
import { logBullet, logWarning } from "../utils";
55
import { FirebaseError, getErrStatus } from "../error";
66
import * as iam from "../gcp/iam";
@@ -10,9 +10,10 @@ const TEST_RUNNER_ROLE = "roles/firebaseapptesting.testRunner";
1010
const TEST_RUNNER_SERVICE_ACCOUNT_NAME = "firebaseapptesting-test-runner";
1111

1212
export async function ensureProjectConfigured(projectId: string) {
13-
await ensure(projectId, appTestingOrigin(), "storage", false);
14-
await ensure(projectId, appTestingOrigin(), "run", false);
15-
await ensure(projectId, appTestingOrigin(), "artifactregistry", false);
13+
await ensure(projectId, appTestingOrigin(), "Firebase App Testing", false);
14+
await ensure(projectId, cloudRunApiOrigin(), "Cloud Run", false);
15+
await ensure(projectId, storageOrigin(), "Cloud Storage", false);
16+
await ensure(projectId, artifactRegistryDomain(), "Artifact Registry", false);
1617
const serviceAccount = runnerServiceAccount(projectId);
1718

1819
const serviceAccountExistsAndIsRunner = await serviceAccountHasRoles(

0 commit comments

Comments
 (0)