@@ -75,6 +75,8 @@ def _merge_jwt_claims(defaults, overrides):
7575 return defaults
7676
7777def verify_custom_token (custom_token , expected_claims , tenant_id = None ):
78+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
79+ pytest .skip ("Not supported with auth emulator" )
7880 assert isinstance (custom_token , bytes )
7981 token = google .oauth2 .id_token .verify_token (
8082 custom_token ,
@@ -230,10 +232,14 @@ def test_invalid_params(self, auth_app, values):
230232 auth .create_custom_token (user , claims , app = auth_app )
231233
232234 def test_noncert_credential (self , user_mgt_app ):
235+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
236+ pytest .skip ("Not supported with auth emulator" )
233237 with pytest .raises (ValueError ):
234238 auth .create_custom_token (MOCK_UID , app = user_mgt_app )
235239
236240 def test_sign_with_iam (self ):
241+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
242+ pytest .skip ("Not supported with auth emulator" )
237243 options = {'serviceAccountId' : 'test-service-account' , 'projectId' : 'mock-project-id' }
238244 app = firebase_admin .initialize_app (
239245 testutils .MockCredential (), name = 'iam-signer-app' , options = options )
@@ -248,6 +254,8 @@ def test_sign_with_iam(self):
248254 firebase_admin .delete_app (app )
249255
250256 def test_sign_with_iam_error (self ):
257+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
258+ pytest .skip ("Not supported with auth emulator" )
251259 options = {'serviceAccountId' : 'test-service-account' , 'projectId' : 'mock-project-id' }
252260 app = firebase_admin .initialize_app (
253261 testutils .MockCredential (), name = 'iam-signer-app' , options = options )
@@ -264,6 +272,8 @@ def test_sign_with_iam_error(self):
264272 firebase_admin .delete_app (app )
265273
266274 def test_sign_with_discovered_service_account (self ):
275+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
276+ pytest .skip ("Not supported with auth emulator" )
267277 request = testutils .MockRequest (200 , 'discovered-service-account' )
268278 options = {'projectId' : 'mock-project-id' }
269279 app = firebase_admin .initialize_app (testutils .MockCredential (), name = 'iam-signer-app' ,
@@ -287,6 +297,8 @@ def test_sign_with_discovered_service_account(self):
287297 firebase_admin .delete_app (app )
288298
289299 def test_sign_with_discovery_failure (self ):
300+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
301+ pytest .skip ("Not supported with auth emulator" )
290302 request = testutils .MockFailedRequest (Exception ('test error' ))
291303 options = {'projectId' : 'mock-project-id' }
292304 app = firebase_admin .initialize_app (testutils .MockCredential (), name = 'iam-signer-app' ,
@@ -431,6 +443,8 @@ def test_valid_token_check_revoked(self, user_mgt_app, id_token):
431443
432444 @pytest .mark .parametrize ('id_token' , valid_tokens .values (), ids = list (valid_tokens ))
433445 def test_revoked_token_check_revoked (self , user_mgt_app , revoked_tokens , id_token ):
446+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
447+ pytest .skip ("Not supported with auth emulator" )
434448 _overwrite_cert_request (user_mgt_app , MOCK_REQUEST )
435449 _instrument_user_manager (user_mgt_app , 200 , revoked_tokens )
436450 with pytest .raises (auth .RevokedIdTokenError ) as excinfo :
@@ -460,13 +474,18 @@ def test_invalid_arg(self, user_mgt_app, id_token):
460474
461475 @pytest .mark .parametrize ('id_token' , invalid_tokens .values (), ids = list (invalid_tokens ))
462476 def test_invalid_token (self , user_mgt_app , id_token ):
477+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
478+ pytest .skip ("Not supported with auth emulator" )
463479 _overwrite_cert_request (user_mgt_app , MOCK_REQUEST )
464480 with pytest .raises (auth .InvalidIdTokenError ) as excinfo :
465481 auth .verify_id_token (id_token , app = user_mgt_app )
466482 assert isinstance (excinfo .value , exceptions .InvalidArgumentError )
467483 assert excinfo .value .http_response is None
468484
469485 def test_expired_token (self , user_mgt_app ):
486+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
487+ pytest .skip ("Not supported with auth emulator" )
488+ _overwrite_cert_request (user_mgt_app , MOCK_REQUEST )
470489 _overwrite_cert_request (user_mgt_app , MOCK_REQUEST )
471490 id_token = self .invalid_tokens ['ExpiredToken' ]
472491 with pytest .raises (auth .ExpiredIdTokenError ) as excinfo :
@@ -505,6 +524,8 @@ def test_custom_token(self, auth_app):
505524 assert str (excinfo .value ) == message
506525
507526 def test_certificate_request_failure (self , user_mgt_app ):
527+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
528+ pytest .skip ("Not supported with auth emulator" )
508529 _overwrite_cert_request (user_mgt_app , testutils .MockRequest (404 , 'not found' ))
509530 with pytest .raises (auth .CertificateFetchError ) as excinfo :
510531 auth .verify_id_token (TEST_ID_TOKEN , app = user_mgt_app )
@@ -580,13 +601,17 @@ def test_invalid_args(self, user_mgt_app, cookie):
580601
581602 @pytest .mark .parametrize ('cookie' , invalid_cookies .values (), ids = list (invalid_cookies ))
582603 def test_invalid_cookie (self , user_mgt_app , cookie ):
604+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
605+ pytest .skip ("Not supported with auth emulator" )
583606 _overwrite_cert_request (user_mgt_app , MOCK_REQUEST )
584607 with pytest .raises (auth .InvalidSessionCookieError ) as excinfo :
585608 auth .verify_session_cookie (cookie , app = user_mgt_app )
586609 assert isinstance (excinfo .value , exceptions .InvalidArgumentError )
587610 assert excinfo .value .http_response is None
588611
589612 def test_expired_cookie (self , user_mgt_app ):
613+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
614+ pytest .skip ("Not supported with auth emulator" )
590615 _overwrite_cert_request (user_mgt_app , MOCK_REQUEST )
591616 cookie = self .invalid_cookies ['ExpiredCookie' ]
592617 with pytest .raises (auth .ExpiredSessionCookieError ) as excinfo :
@@ -620,6 +645,8 @@ def test_custom_token(self, auth_app):
620645 auth .verify_session_cookie (custom_token , app = auth_app )
621646
622647 def test_certificate_request_failure (self , user_mgt_app ):
648+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
649+ pytest .skip ("Not supported with auth emulator" )
623650 _overwrite_cert_request (user_mgt_app , testutils .MockRequest (404 , 'not found' ))
624651 with pytest .raises (auth .CertificateFetchError ) as excinfo :
625652 auth .verify_session_cookie (TEST_SESSION_COOKIE , app = user_mgt_app )
@@ -632,6 +659,8 @@ def test_certificate_request_failure(self, user_mgt_app):
632659class TestCertificateCaching :
633660
634661 def test_certificate_caching (self , user_mgt_app , httpserver ):
662+ if os .getenv (EMULATOR_HOST_ENV_VAR ):
663+ pytest .skip ("Not supported with auth emulator" )
635664 httpserver .serve_content (MOCK_PUBLIC_CERTS , 200 , headers = {'Cache-Control' : 'max-age=3600' })
636665 verifier = _token_gen .TokenVerifier (user_mgt_app )
637666 verifier .cookie_verifier .cert_url = httpserver .url
0 commit comments