Skip to content

Commit

Permalink
Detect Google Cloud Workstations (#5283)
Browse files Browse the repository at this point in the history
Default to --no-localhost when calling login from Cloud Workstations
  • Loading branch information
jamesdaniels committed Dec 1, 2022
1 parent 76450ef commit 6ed818b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,4 +1,5 @@
- Fix bug where disabling background triggers did nothing. (#5221)
- Fix bug in auth emulator where empty string should throw invalid email instead of missing email. (#3898)
- Fix bug in auth emulator in which createdAt was not set for signInWithIdp new users. (#5203)
- Default to --no-localhost when calling login from Google Cloud Workstations
- Support the x-goog-api-key header in auth emulator. (#5249)
26 changes: 26 additions & 0 deletions src/test/utils.spec.ts
Expand Up @@ -70,6 +70,32 @@ describe("utils", () => {
});
});

describe("isCloudEnvironment", () => {
let originalEnv: NodeJS.ProcessEnv;

beforeEach(() => {
originalEnv = { ...process.env };
});

afterEach(() => {
process.env = originalEnv;
});

it("should return false by default", () => {
expect(utils.isCloudEnvironment()).to.be.false;
});

it("should return true when in codespaces", () => {
process.env.CODESPACES = "true";
expect(utils.isCloudEnvironment()).to.be.true;
});

it("should return true when in Cloud Workstations", () => {
process.env.GOOGLE_CLOUD_WORKSTATIONS = "true";
expect(utils.isCloudEnvironment()).to.be.true;
});
});

describe("getDatabaseUrl", () => {
it("should create a url for prod", () => {
expect(utils.getDatabaseUrl("https://firebaseio.com", "fir-proj", "/")).to.equal(
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Expand Up @@ -577,7 +577,7 @@ export function datetimeString(d: Date): string {
* Indicates whether the end-user is running the CLI from a cloud-based environment.
*/
export function isCloudEnvironment() {
return !!process.env.CODESPACES;
return !!process.env.CODESPACES || !!process.env.GOOGLE_CLOUD_WORKSTATIONS;
}

/**
Expand Down

0 comments on commit 6ed818b

Please sign in to comment.