def test_repr(self): self.assertEqual( repr(auth_domain.AuthClaims('sub', '*****@*****.**')), 'AuthClaims(auth_id=%r, email=%r)' % ('sub', '*****@*****.**')) self.assertEqual( repr(auth_domain.AuthClaims('tub', None)), 'AuthClaims(auth_id=%r, email=None)' % ('tub',))
def test_hash(self): a = auth_domain.AuthClaims('a', '*****@*****.**') b = auth_domain.AuthClaims('b', '*****@*****.**') # Should be able to create a set of AuthClaims. auth_set = set([a, b]) self.assertIn(auth_domain.AuthClaims('a', '*****@*****.**'), auth_set) self.assertNotIn(auth_domain.AuthClaims('c', '*****@*****.**'), auth_set)
def _create_auth_claims(firebase_claims): """Returns a new AuthClaims domain object from Firebase claims. Args: firebase_claims: dict(str: *). The raw claims returned by the Firebase SDK. Returns: AuthClaims. Oppia's representation of auth claims. """ auth_id = firebase_claims.get('sub') email = firebase_claims.get('email') role_is_super_admin = ( firebase_claims.get('role') == feconf.FIREBASE_ROLE_SUPER_ADMIN) return auth_domain.AuthClaims(auth_id, email, role_is_super_admin=role_is_super_admin)
def test_attributes(self): auth = auth_domain.AuthClaims('sub', '*****@*****.**') self.assertEqual(auth.auth_id, 'sub') self.assertEqual(auth.email, '*****@*****.**')