Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Auth Emulator deleteTenant not working with Node Admin. #3817

Merged
merged 3 commits into from Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -0,0 +1 @@
- Fix Auth Emulator deleteTenant not working with Node Admin (#3817).
8 changes: 8 additions & 0 deletions src/emulator/auth/server.ts
Expand Up @@ -124,6 +124,14 @@ export async function createApp(
// This is similar to production behavior. Safe since all APIs are cookieless.
app.use(cors({ origin: true }));

// Workaround for clients (e.g. Node.js Admin SDK) that send request bodies
// with HTTP DELETE requests. Such requests are tolerated by production, but
// exegesis will reject them without the following hack.
app.delete("*", (req, _, next) => {
delete req.headers["content-type"];
next();
});

app.get("/", (req, res) => {
return res.json({
authEmulator: {
Expand Down
15 changes: 15 additions & 0 deletions src/test/emulators/auth/tenant.spec.ts
Expand Up @@ -106,6 +106,21 @@ describeAuthEmulator("tenant management", ({ authApi }) => {
expectStatusCode(200, res);
});
});

it("should delete tenants if request body is passed", async () => {
const projectId = "project-id";
const tenant = await registerTenant(authApi(), projectId, {});

await authApi()
.delete(
`/identitytoolkit.googleapis.com/v2/projects/${projectId}/tenants/${tenant.tenantId}`
)
.set("Authorization", "Bearer owner")
.send({})
.then((res) => {
expectStatusCode(200, res);
});
});
});

describe("listTenants", () => {
Expand Down