@@ -41,6 +41,18 @@ function getRandomToken() {
4141 return tokenUUIDs [ 0 ] ;
4242}
4343
44+ function isAppCheckCloudQuotaError ( error ) {
45+ const message = error ?. message || String ( error ) ;
46+ return / Q u o t a e x c e e d e d | T o o m a n y s e r v e r r e q u e s t s | R E S O U R C E _ E X H A U S T E D / i. test ( message ) ;
47+ }
48+
49+ function skipIfAppCheckCloudQuotaError ( error , testContext ) {
50+ if ( isAppCheckCloudQuotaError ( error ) ) {
51+ testContext . skip ( ) ;
52+ }
53+ throw error ;
54+ }
55+
4456function decodeJWT ( token ) {
4557 // Split the token into its parts
4658 const parts = token . split ( '.' ) ;
@@ -86,7 +98,8 @@ describe('appCheck()', function () {
8698 let appCheckInstance ;
8799
88100 beforeEach ( async function ( ) {
89- const { initializeAppCheck, ReactNativeFirebaseAppCheckProvider } = appCheckModular ;
101+ const { initializeAppCheck, ReactNativeFirebaseAppCheckProvider, CustomProvider } =
102+ appCheckModular ;
90103
91104 let provider ;
92105
@@ -107,7 +120,7 @@ describe('appCheck()', function () {
107120 } ,
108121 } ) ;
109122 } else {
110- provider = new ReactNativeFirebaseAppCheckProvider ( {
123+ provider = new CustomProvider ( {
111124 getToken ( ) {
112125 return FirebaseHelpers . fetchAppCheckToken ( ) ;
113126 } ,
@@ -173,9 +186,7 @@ describe('appCheck()', function () {
173186 }
174187 ( token === token2 ) . should . be . false ( ) ;
175188 } catch ( e ) {
176- // we will silently pass rate limiting errors
177- e . message . should . containEql ( 'Quota exceeded' ) ;
178- this . skip ( ) ;
189+ skipIfAppCheckCloudQuotaError ( e , this ) ;
179190 }
180191 } ) ;
181192
@@ -241,15 +252,16 @@ describe('appCheck()', function () {
241252 ) ;
242253 }
243254 } catch ( e ) {
244- // we will silently pass rate limiting errors
245- e . message . should . containEql ( 'Quota exceeded' ) ;
246- this . skip ( ) ;
255+ skipIfAppCheckCloudQuotaError ( e , this ) ;
247256 }
248257 } ) ;
249258 } ) ;
250259
251260 describe ( 'getLimitedUseToken()' , function ( ) {
252261 it ( 'limited use token fetch attempt with configured debug token should work' , async function ( ) {
262+ if ( Platform . other ) {
263+ this . skip ( ) ;
264+ }
253265 const { initializeAppCheck, getLimitedUseToken, ReactNativeFirebaseAppCheckProvider } =
254266 appCheckModular ;
255267
@@ -285,9 +297,7 @@ describe('appCheck()', function () {
285297 ) ;
286298 }
287299 } catch ( e ) {
288- // we will silently pass rate limiting errors
289- e . message . should . containEql ( 'Quota exceeded' ) ;
290- this . skip ( ) ;
300+ skipIfAppCheckCloudQuotaError ( e , this ) ;
291301 }
292302 } ) ;
293303 } ) ;
0 commit comments