Skip to content

Commit 35bda2c

Browse files
avolkovisam-gc
authored andcommitted
Fix some tests
1 parent d3996d8 commit 35bda2c

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

packages-exp/auth-exp/src/api/authentication/custom_token.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ use(chaiAsPromised);
3232

3333
describe('api/authentication/signInWithCustomToken', () => {
3434
const request = {
35-
token: 'my-token'
35+
token: 'my-token',
36+
returnSecureToken: true
3637
};
3738

3839
let auth: TestAuth;

packages-exp/auth-exp/src/core/auth/auth_impl.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,11 @@ export class AuthImpl implements Auth, _FirebaseService {
118118
});
119119

120120
// After initialization completes, throw any error caused by redirect flow
121-
this._initializationPromise.then(() => {
121+
return this._initializationPromise.then(() => {
122122
if (this.redirectInitializerError) {
123123
throw this.redirectInitializerError;
124124
}
125125
});
126-
127-
return this._initializationPromise;
128126
}
129127

130128
/**

packages-exp/auth-exp/src/core/auth/firebase_internal.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe('src/core/auth/firebase_internal', () => {
5656
const user = testUser(auth, 'uid');
5757
await auth._updateCurrentUser(user);
5858
user.stsTokenManager.accessToken = 'access-token';
59+
user.stsTokenManager.refreshToken = 'refresh-token';
5960
user.stsTokenManager.expirationTime = Date.now() + 1000 * 60 * 60 * 24;
6061
expect(await authInternal.getToken()).to.eql({
6162
accessToken: 'access-token'

packages-exp/auth-exp/src/core/auth/initialize.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ describe('src/core/auth/initialize', () => {
106106
): void {
107107
cb(true);
108108
}
109+
async _completeRedirectFn(
110+
_auth: externs.Auth,
111+
_resolver: externs.PopupRedirectResolver,
112+
_bypassAuthState: boolean
113+
): Promise<externs.UserCredential | null> {
114+
return null;
115+
}
109116
}
110117

111118
const fakePopupRedirectResolver: externs.PopupRedirectResolver = FakePopupRedirectResolver;

packages-exp/auth-exp/src/core/user/token_manager.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,24 @@ export class StsTokenManager {
5454
}
5555

5656
async getToken(auth: Auth, forceRefresh = false): Promise<string | null> {
57-
if (!forceRefresh && this.accessToken && !this.isExpired) {
58-
return this.accessToken;
59-
}
60-
6157
assert(
62-
this.accessToken && !this.refreshToken,
58+
!this.accessToken || this.refreshToken,
6359
AuthErrorCode.TOKEN_EXPIRED,
6460
{
6561
appName: auth.name
6662
}
67-
); /* */
63+
);
64+
65+
if (!forceRefresh && this.accessToken && !this.isExpired) {
66+
return this.accessToken;
67+
}
68+
69+
if (this.refreshToken) {
70+
await this.refresh(auth, this.refreshToken!);
71+
return this.accessToken;
72+
}
6873

69-
await this.refresh(auth, this.refreshToken!);
70-
return this.accessToken;
74+
return null;
7175
}
7276

7377
clearRefreshToken(): void {

0 commit comments

Comments
 (0)