@@ -45,6 +45,10 @@ class MockFirebaseAppCheck extends Mock implements FirebaseAppCheck {
4545 @override
4646 Future <String ?> getToken ([bool ? forceRefresh = false ]) async =>
4747 super .noSuchMethod (Invocation .method (#getToken, [forceRefresh]));
48+
49+ @override
50+ Future <String > getLimitedUseToken () async =>
51+ super .noSuchMethod (Invocation .method (#getLimitedUseToken, [])) ?? '' ;
4852}
4953
5054// Mock Firebase Auth
@@ -72,7 +76,7 @@ class MockApiClient extends Mock implements ApiClient {
7276void main () {
7377 group ('BaseModel' , () {
7478 test ('firebaseTokens returns a function that generates headers' , () async {
75- final tokenFunction = BaseModel .firebaseTokens (null , null , null );
79+ final tokenFunction = BaseModel .firebaseTokens (null , null , null , false );
7680 final headers = await tokenFunction ();
7781 expect (headers['x-goog-api-client' ], contains ('gl-dart' ));
7882 expect (headers['x-goog-api-client' ], contains ('fire' ));
@@ -83,7 +87,8 @@ void main() {
8387 final mockAppCheck = MockFirebaseAppCheck ();
8488 when (mockAppCheck.getToken ())
8589 .thenAnswer ((_) async => 'test-app-check-token' );
86- final tokenFunction = BaseModel .firebaseTokens (mockAppCheck, null , null );
90+ final tokenFunction =
91+ BaseModel .firebaseTokens (mockAppCheck, null , null , false );
8792 final headers = await tokenFunction ();
8893 expect (headers['X-Firebase-AppCheck' ], 'test-app-check-token' );
8994 expect (headers['x-goog-api-client' ], contains ('gl-dart' ));
@@ -96,7 +101,8 @@ void main() {
96101 final mockUser = MockUser ();
97102 when (mockUser.getIdToken ()).thenAnswer ((_) async => 'test-id-token' );
98103 when (mockAuth.currentUser).thenReturn (mockUser);
99- final tokenFunction = BaseModel .firebaseTokens (null , mockAuth, null );
104+ final tokenFunction =
105+ BaseModel .firebaseTokens (null , mockAuth, null , false );
100106 final headers = await tokenFunction ();
101107 expect (headers['Authorization' ], 'Firebase test-id-token' );
102108 expect (headers['x-goog-api-client' ], contains ('gl-dart' ));
@@ -109,7 +115,8 @@ void main() {
109115 () async {
110116 final mockApp = MockFirebaseApp ();
111117
112- final tokenFunction = BaseModel .firebaseTokens (null , null , mockApp);
118+ final tokenFunction =
119+ BaseModel .firebaseTokens (null , null , mockApp, false );
113120 final headers = await tokenFunction ();
114121 expect (headers['X-Firebase-AppId' ], 'test-app-id' );
115122 expect (headers['x-goog-api-client' ], contains ('gl-dart' ));
@@ -128,7 +135,7 @@ void main() {
128135 final mockApp = MockFirebaseApp ();
129136
130137 final tokenFunction =
131- BaseModel .firebaseTokens (mockAppCheck, mockAuth, mockApp);
138+ BaseModel .firebaseTokens (mockAppCheck, mockAuth, mockApp, false );
132139 final headers = await tokenFunction ();
133140 expect (headers['X-Firebase-AppCheck' ], 'test-app-check-token' );
134141 expect (headers['Authorization' ], 'Firebase test-id-token' );
@@ -137,5 +144,20 @@ void main() {
137144 expect (headers['x-goog-api-client' ], contains ('fire' ));
138145 expect (headers.length, 4 );
139146 });
147+
148+ test ('firebaseTokens includes limited use App Check token if specified' ,
149+ () async {
150+ final mockAppCheck = MockFirebaseAppCheck ();
151+ when (mockAppCheck.getLimitedUseToken ())
152+ .thenAnswer ((_) async => 'test-limited-use-app-check-token' );
153+ final tokenFunction =
154+ BaseModel .firebaseTokens (mockAppCheck, null , null , true );
155+ final headers = await tokenFunction ();
156+ expect (
157+ headers['X-Firebase-AppCheck' ], 'test-limited-use-app-check-token' );
158+ expect (headers['x-goog-api-client' ], contains ('gl-dart' ));
159+ expect (headers['x-goog-api-client' ], contains ('fire' ));
160+ expect (headers.length, 2 );
161+ });
140162 });
141163}
0 commit comments