Skip to content

Commit caac5bc

Browse files
committed
review feedback
1 parent 59d93aa commit caac5bc

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

src/auth/auth-api-request.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -980,17 +980,17 @@ export abstract class AbstractAuthRequestHandler {
980980
'providerToLink.uid of properties argument must be a non-empty string.');
981981
}
982982
} else if (typeof properties.providersToDelete !== 'undefined') {
983-
if (!validator.isNonEmptyArray(properties.providersToDelete)) {
983+
if (!validator.isArray(properties.providersToDelete)) {
984984
throw new FirebaseAuthError(
985985
AuthClientErrorCode.INVALID_ARGUMENT,
986-
'providersToDelete of properties argument must be a non-empty array of strings.');
986+
'providersToDelete of properties argument must be an array of strings.');
987987
}
988988

989989
properties.providersToDelete.forEach((providerId) => {
990990
if (!validator.isNonEmptyString(providerId)) {
991991
throw new FirebaseAuthError(
992992
AuthClientErrorCode.INVALID_ARGUMENT,
993-
'providersToDelete of properties argument must be a non-empty array of strings.');
993+
'providersToDelete of properties argument must be an array of strings.');
994994
}
995995
});
996996
}

src/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,12 @@ declare namespace admin.auth {
724724
photoURL?: string | null;
725725

726726
/**
727-
* Links this user to the specified federated provider.
727+
* Links this user to the specified provider.
728728
*/
729729
providerToLink?: UserProvider;
730730

731731
/**
732-
* Unlinks this user from the specified federated providers.
732+
* Unlinks this user from the specified providers.
733733
*/
734734
providersToDelete?: string[];
735735
}

test/integration/auth.spec.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,17 +366,17 @@ describe('admin.auth', () => {
366366
});
367367

368368
it('can link/unlink with a federated provider', async () => {
369-
const federatedUid = 'google_uid_' + generateRandomString(10);
369+
const googleFederatedUid = 'google_uid_' + generateRandomString(10);
370370
let userRecord = await admin.auth().updateUser(updateUser.uid, {
371371
providerToLink: {
372372
providerId: 'google.com',
373-
uid: federatedUid,
373+
uid: googleFederatedUid,
374374
},
375375
});
376376

377377
let providerUids = userRecord.providerData.map((userInfo) => userInfo.uid);
378378
let providerIds = userRecord.providerData.map((userInfo) => userInfo.providerId);
379-
expect(providerUids).to.deep.include(federatedUid);
379+
expect(providerUids).to.deep.include(googleFederatedUid);
380380
expect(providerIds).to.deep.include('google.com');
381381

382382
userRecord = await admin.auth().updateUser(updateUser.uid, {
@@ -385,7 +385,7 @@ describe('admin.auth', () => {
385385

386386
providerUids = userRecord.providerData.map((userInfo) => userInfo.uid);
387387
providerIds = userRecord.providerData.map((userInfo) => userInfo.providerId);
388-
expect(providerUids).to.not.deep.include(federatedUid);
388+
expect(providerUids).to.not.deep.include(googleFederatedUid);
389389
expect(providerIds).to.not.deep.include('google.com');
390390
});
391391

@@ -423,6 +423,19 @@ describe('admin.auth', () => {
423423
expect(providerUids).to.not.deep.include.members([googleFederatedUid, facebookFederatedUid, '+15555550001']);
424424
expect(providerIds).to.not.deep.include.members(['google.com', 'facebook.com', 'phone']);
425425
});
426+
427+
it('noops successfully when given an empty providersToDelete list', async () => {
428+
const userRecord = await createTestUser('NoopWithEmptyProvidersToDeleteUser');
429+
try {
430+
const updatedUserRecord = await admin.auth().updateUser(userRecord.uid, {
431+
providersToDelete: [],
432+
});
433+
434+
expect(updatedUserRecord).to.deep.equal(userRecord);
435+
} finally {
436+
safeDelete(userRecord.uid);
437+
}
438+
});
426439
});
427440

428441
it('getUser() fails when called with a non-existing UID', () => {

test/unit/auth/auth.spec.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,14 +1456,6 @@ AUTH_CONFIGS.forEach((testConfig) => {
14561456
});
14571457
});
14581458

1459-
it('should be rejected given an empty providersToDelete list', () => {
1460-
expect(() => {
1461-
auth.updateUser(uid, {
1462-
providersToDelete: [],
1463-
});
1464-
}).to.throw(FirebaseAuthError).with.property('code', 'auth/argument-error');
1465-
});
1466-
14671459
INVALID_PROVIDER_IDS.forEach((invalidProviderId) => {
14681460
it('should be rejected given a deleteProvider list with an invalid provider ID '
14691461
+ JSON.stringify(invalidProviderId), () => {

0 commit comments

Comments
 (0)