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) 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", () => {