Skip to content

Commit

Permalink
fix(auth, useUserAccessGroup): document auth/keychain-error, add test…
Browse files Browse the repository at this point in the history
… coverage

The update to firebase-ios-sdk v7.8.0 which fixed an underlying useUserAccessGroup issue
exposed an error in the E2E test that covers our wrapper for the method when it started
returning an error in a legitimately incorrect usage.

This patches up the test case and documents the error that may be thrown

Fixes #5007
  • Loading branch information
mikehardy committed Mar 12, 2021
1 parent 7026d22 commit 3e4d0fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/auth/e2e/auth.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,11 @@ describe('auth()', function () {
});

describe('useUserAccessGroup()', function () {
it('should return "null" on successful keychain implementation', async function () {
const successfulKeychain = await firebase.auth().useUserAccessGroup('mysecretkeychain');
// Android simply does Promise.resolve, that is sufficient for this test multi-platform
it('should return "null" when accessing a group that exists', async function () {
const successfulKeychain = await firebase
.auth()
.useUserAccessGroup('YYX2P3XVJ7.com.invertase.testing'); // iOS signing team is YYX2P3XVJ7

should.not.exist(successfulKeychain);

Expand All @@ -1055,5 +1058,17 @@ describe('auth()', function () {

should.not.exist(resetKeychain);
});

it('should throw when requesting an inaccessible group', async function () {
// Android will never throw, so this test is iOS only
if (device.getPlatform() === 'ios') {
try {
await firebase.auth().useUserAccessGroup('there.is.no.way.this.group.exists');
throw new Error('Should have thrown an error for inaccessible group');
} catch (e) {
e.message.should.containEql('auth/keychain-error');
}
}
});
});
});
1 change: 1 addition & 0 deletions packages/auth/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,7 @@ export namespace FirebaseAuthTypes {
*
* @platform ios
*
* @error auth/keychain-error Thrown if you attempt to access an inaccessible keychain
* @param userAccessGroup A string of the keychain id i.e. "TEAMID.com.example.group1"
*/
useUserAccessGroup(userAccessGroup: string): Promise<null>;
Expand Down

0 comments on commit 3e4d0fd

Please sign in to comment.