From 1e9d3efee901e1c3c20e64cda46cd0ae5de75124 Mon Sep 17 00:00:00 2001 From: Bryan Kendall Date: Thu, 26 Oct 2023 10:19:04 -0700 Subject: [PATCH 1/2] corrects regex for domain matching authorized domains --- src/hosting/api.ts | 4 ++-- src/test/hosting/api.spec.ts | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/hosting/api.ts b/src/hosting/api.ts index 552a4ad1927..4b921ff59aa 100644 --- a/src/hosting/api.ts +++ b/src/hosting/api.ts @@ -633,8 +633,8 @@ export async function getCleanDomains(project: string, site: string): Promise { expect(res).to.deep.equal(EXPECTED_DOMAINS_RESPONSE); expect(nock.isDone()).to.be.true; }); + + it("should not remove sites that are similarly named", async () => { + // mock listChannels response + nock(hostingApiOrigin) + .get(`/v1beta1/projects/${PROJECT_ID}/sites/${SITE}/channels`) + .query(() => true) + .reply(200, { + channels: [ + { url: "https://my-site--ch1-4iyrl1uo.web.app" }, + { url: "https://my-site--ch2-ygd8582v.web.app" }, + ], + }); + // mock getAuthDomains response + nock(identityOrigin) + .get(`/admin/v2/projects/${PROJECT_ID}/config`) + .reply(200, { + authorizedDomains: [ + "localhost", + "randomurl.com", + "my-site--ch1-4iyrl1uo.web.app", + "my-site--expiredchannel-difhyc76.web.app", + "backendof-my-site--some-abcd1234.web.app", + ], + }); + + const res = await hostingApi.getCleanDomains(PROJECT_ID, SITE); + + expect(res).to.deep.equal([ + "localhost", + "randomurl.com", + "my-site--ch1-4iyrl1uo.web.app", + "backendof-my-site--some-abcd1234.web.app", + ]); + expect(nock.isDone()).to.be.true; + }); }); describe("getSiteDomains", () => { From fc03add5d8a5e00830950465dbb53bdbf77e15e5 Mon Sep 17 00:00:00 2001 From: Bryan Kendall Date: Thu, 26 Oct 2023 10:29:39 -0700 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f117bab5f4..9761853151d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ - Enable [preferRest](https://firebase.google.com/docs/reference/admin/node/firebase-admin.firestore.firestoresettings.md#firestoresettingspreferrest) option by default for Firestore functions. (#6147) - Fixed a bug where re-deploying 2nd Gen Firestore function failed after updating secrets. (#6456) +- Fixed a bug where similarly-named Hosting channels would cause issues when updating authorized domains. (#6356)