-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth-guard): Adding in modular auth guards (#3001)
* Adding modular auth guards * Flushing out some basic tests * Refactored how `isSupported` is handled * Firestore wasn't passing the injector, need tests for this too * Fixed the version check on firebase-tools * Fixed firebase-tools project creation * Cleaned up some of the error messaging
- Loading branch information
1 parent
5d6d8bf
commit 3ae6ce5
Showing
38 changed files
with
836 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { FirebaseApp, provideFirebaseApp, getApp, initializeApp, deleteApp } from '@angular/fire/app'; | ||
import { Analytics, provideAnalytics, getAnalytics, isSupported } from '@angular/fire/analytics'; | ||
import { COMMON_CONFIG } from '../test-config'; | ||
import { rando } from '../utils'; | ||
|
||
describe('Analytics', () => { | ||
let app: FirebaseApp; | ||
let analytics: Analytics; | ||
let providedAnalytics: Analytics; | ||
let appName: string; | ||
|
||
beforeAll(done => { | ||
// The APP_INITIALIZER that is making isSupported() sync for DI may not | ||
// be done evaulating by the time we inject from the TestBed. We can | ||
// ensure correct behavior by waiting for the (global) isSuppported() promise | ||
// to resolve. | ||
isSupported().then(() => done()); | ||
}); | ||
|
||
describe('single injection', () => { | ||
|
||
beforeEach(() => { | ||
appName = rando(); | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)), | ||
provideAnalytics(() => { | ||
providedAnalytics = getAnalytics(getApp(appName)); | ||
return providedAnalytics; | ||
}), | ||
], | ||
}); | ||
app = TestBed.inject(FirebaseApp); | ||
analytics = TestBed.inject(Analytics); | ||
}); | ||
|
||
afterEach(() => { | ||
deleteApp(app).catch(() => undefined); | ||
}); | ||
|
||
it('should be injectable', () => { | ||
expect(providedAnalytics).toBeTruthy(); | ||
expect(analytics).toEqual(providedAnalytics); | ||
expect(analytics.app).toEqual(app); | ||
}); | ||
|
||
}); | ||
|
||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { ɵisAnalyticsSupportedFactory } from '@angular/fire'; | ||
|
||
export const isSupported = ɵisAnalyticsSupportedFactory.async; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { FirebaseApp, provideFirebaseApp, getApp, initializeApp, deleteApp } from '@angular/fire/app'; | ||
import { Auth, provideAuth, getAuth, connectAuthEmulator } from '@angular/fire/auth'; | ||
import { COMMON_CONFIG } from '../test-config'; | ||
import { rando } from '../utils'; | ||
|
||
describe('Auth', () => { | ||
let app: FirebaseApp; | ||
let auth: Auth; | ||
let providedAuth: Auth; | ||
let appName: string; | ||
|
||
describe('single injection', () => { | ||
|
||
beforeEach(() => { | ||
appName = rando(); | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)), | ||
provideAuth(() => { | ||
providedAuth = getAuth(getApp(appName)); | ||
connectAuthEmulator(providedAuth, 'http://localhost:9099'); | ||
return providedAuth; | ||
}), | ||
], | ||
}); | ||
app = TestBed.inject(FirebaseApp); | ||
auth = TestBed.inject(Auth); | ||
}); | ||
|
||
afterEach(() => { | ||
deleteApp(app).catch(() => undefined); | ||
}); | ||
|
||
it('should be injectable', () => { | ||
expect(auth).toBeTruthy(); | ||
expect(auth).toEqual(providedAuth); | ||
expect(auth.app).toEqual(app); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { FirebaseApp, provideFirebaseApp, initializeApp, deleteApp } from '@angular/fire/app'; | ||
import { COMMON_CONFIG } from '../test-config'; | ||
import { rando } from '../utils'; | ||
|
||
describe('FirebaseApp', () => { | ||
let app: FirebaseApp; | ||
let providedApp: FirebaseApp; | ||
let appName: string; | ||
|
||
describe('single injection', () => { | ||
|
||
beforeEach(() => { | ||
appName = rando(); | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
provideFirebaseApp(() => { | ||
providedApp = initializeApp(COMMON_CONFIG, appName); | ||
return providedApp; | ||
}) | ||
], | ||
}); | ||
app = TestBed.inject(FirebaseApp); | ||
}); | ||
|
||
afterEach(() => { | ||
deleteApp(app).catch(() => undefined); | ||
}); | ||
|
||
it('should be injectable', () => { | ||
expect(app).toBeTruthy(); | ||
expect(app).toEqual(providedApp); | ||
}); | ||
|
||
}); | ||
|
||
}); |
Oops, something went wrong.