Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for disabled user updating email
  • Loading branch information
ssbushi committed Feb 17, 2021
commit a29a6a6d9623eea084bec87f58520414383d7629
19 changes: 18 additions & 1 deletion src/test/emulators/auth/setAccountInfo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describeAuthEmulator("accounts:update", ({ authApi, getClock }) => {
expect(res.body.error.message).equals("EMAIL_NOT_FOUND");
});

// An oob is sent to the oldEmail
// An oob is sent to oldEmail
const oobs = await inspectOobs(authApi());
expect(oobs).to.have.length(1);
expect(oobs[0].email).to.equal(oldEmail);
Expand Down Expand Up @@ -339,6 +339,23 @@ describeAuthEmulator("accounts:update", ({ authApi, getClock }) => {
expect(info.initialEmail).to.be.undefined;
});

it("should not update email if user is disabled", async () => {
const user = { email: "bob@example.com", password: "notasecret" };
const newEmail = "alice@example.com";
const { localId, idToken } = await registerUser(authApi(), user);
await updateAccountByLocalId(authApi(), localId, { disableUser: true });

// Try to update the email once.
await authApi()
.post("/identitytoolkit.googleapis.com/v1/accounts:update")
.query({ key: "fake-api-key" })
.send({ idToken, email: newEmail })
.then((res) => {
expectStatusCode(400, res);
expect(res.body.error).to.have.property("message").equals("USER_DISABLED");
});
});

it("should update phoneNumber if specified", async () => {
const phoneNumber = TEST_PHONE_NUMBER;
const { localId, idToken } = await signInWithPhoneNumber(authApi(), phoneNumber);
Expand Down