def test_delete_user_when_firebase_raises_an_error(self): delete_swap = self.swap_to_always_raise( firebase_admin.auth, 'delete_user', error=firebase_exceptions.InternalError('could not connect')) with delete_swap, self.capture_logging() as logs: firebase_auth_services.delete_external_auth_associations( self.USER_ID) self.assertFalse( firebase_auth_services .verify_external_auth_associations_are_deleted(self.USER_ID)) self.assert_matches_regexps(logs, ['could not connect'])
def test_delete_association_when_it_is_present(self): firebase_admin.auth.create_user(uid='aid') firebase_auth_services.associate_auth_id_with_user_id( auth_domain.AuthIdUserIdPair('aid', 'uid')) self.assertFalse( firebase_auth_services .verify_external_auth_associations_are_deleted('uid')) firebase_auth_services.delete_external_auth_associations('uid') self.assertTrue( firebase_auth_services .verify_external_auth_associations_are_deleted('uid'))
def test_delete_user_without_firebase_initialization_returns_false(self): init_swap = self.swap_to_always_raise( firebase_admin, 'initialize_app', error=firebase_exceptions.UnknownError('could not init')) with init_swap, self.capture_logging() as logs: firebase_auth_services.delete_external_auth_associations( self.USER_ID) self.assertFalse( firebase_auth_services .verify_external_auth_associations_are_deleted(self.USER_ID)) self.assert_matches_regexps(logs, ['could not init'])
def delete_external_auth_associations(self): """Runs delete_external_auth_associations on the test user.""" firebase_auth_services.delete_external_auth_associations(self.user_id)
def test_delete_association_when_it_is_missing_does_not_raise(self): # Should not raise. firebase_auth_services.delete_external_auth_associations( 'does_not_exist')