Skip to content

Use real auth object for our tests #3098

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

Merged
merged 1 commit into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages-exp/auth-exp/src/core/auth/auth_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const DEFAULT_TOKEN_API_HOST = 'securetoken.googleapis.com';
export const DEFAULT_API_HOST = 'identitytoolkit.googleapis.com';
export const DEFAULT_API_SCHEME = 'https';

class AuthImpl implements Auth {
export class AuthImpl implements Auth {
currentUser: User | null = null;
private operations = Promise.resolve();
private persistenceManager?: PersistenceUserManager;
Expand Down
24 changes: 8 additions & 16 deletions packages-exp/auth-exp/test/mock_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,30 @@
* limitations under the License.
*/

import { AuthImpl } from '../src/core/auth/auth_impl';
import { StsTokenManager } from '../src/core/user/token_manager';
import { UserImpl } from '../src/core/user/user_impl';
import { Auth } from '../src/model/auth';
import { User } from '../src/model/user';

export const TEST_HOST = 'localhost';
export const TEST_TOKEN_HOST = 'localhost/token';
export const TEST_AUTH_DOMAIN = 'localhost';
export const TEST_SCHEME = 'mock';
export const TEST_KEY = 'test-api-key';

export const mockAuth: Auth = ({
name: 'test-app',
config: {
export const mockAuth: Auth = new AuthImpl(
'test-app',
{
apiKey: TEST_KEY,
authDomain: TEST_AUTH_DOMAIN,
apiHost: TEST_HOST,
apiScheme: TEST_SCHEME,
tokenApiHost: TEST_TOKEN_HOST,
sdkClientVersion: 'testSDK/0.0.0'
},
_isInitialized: true,
currentUser: null,
async setPersistence() {},
async updateCurrentUser() {},
async signOut() {},
onAuthStateChanged() {
return () => {};
},
onIdTokenChanged() {
return () => {};
},
_notifyStateListeners() {}
} as unknown) as Auth;
[],
);

export function testUser(
uid: string,
Expand Down