Ejemplo n.º 1
0
    def test_associate_multi_without_collisions(self):
        firebase_auth_services.associate_multi_auth_ids_with_user_ids(
            [auth_domain.AuthIdUserIdPair('aid1', 'uid1'),
             auth_domain.AuthIdUserIdPair('aid2', 'uid2'),
             auth_domain.AuthIdUserIdPair('aid3', 'uid3')])

        self.assertEqual(
            [firebase_auth_services.get_user_id_from_auth_id('aid1'),
             firebase_auth_services.get_user_id_from_auth_id('aid2'),
             firebase_auth_services.get_user_id_from_auth_id('aid3')],
            ['uid1', 'uid2', 'uid3'])
    def test_associate_without_collision(self):
        firebase_auth_services.associate_auth_id_with_user_id(
            auth_domain.AuthIdUserIdPair('aid', 'uid'))

        self.assertEqual(
            firebase_auth_services.get_user_id_from_auth_id('aid'), 'uid')
        self.assertEqual(
            firebase_auth_services.get_auth_id_from_user_id('uid'), 'aid')
    def test_get_association_that_is_present(self):
        firebase_auth_services.associate_auth_id_with_user_id(
            auth_domain.AuthIdUserIdPair('aid', 'uid'))

        self.assertEqual(
            firebase_auth_services.get_user_id_from_auth_id('aid'), 'uid')
        self.assertEqual(
            firebase_auth_services.get_auth_id_from_user_id('uid'), 'aid')
    def assert_auth_mapping_does_not_exist(self, auth_assoc):
        """Asserts that the given auth association does not exist.

        Args:
            auth_assoc: AuthIdUserIdPair. The association to check.
        """
        auth_id, user_id = auth_assoc
        self.assertIsNone(
            firebase_auth_services.get_auth_id_from_user_id(user_id))
        self.assertIsNone(
            firebase_auth_services.get_user_id_from_auth_id(auth_id))
    def assert_auth_mapping_exists(self, auth_assoc):
        """Asserts that the given auth association exists.

        Args:
            auth_assoc: AuthIdUserIdPair. The association to check.
        """
        auth_id, user_id = auth_assoc
        self.assertEqual(
            firebase_auth_services.get_auth_id_from_user_id(user_id), auth_id)
        self.assertEqual(
            firebase_auth_services.get_user_id_from_auth_id(auth_id), user_id)
Ejemplo n.º 6
0
    def assert_firebase_assoc_does_not_exist(self, firebase_auth_id, user_id):
        """Asserts that the given user's Firebase association doesn't exist.

        Args:
            firebase_auth_id: str. The Firebase account ID of the user.
            user_id: str. The Oppia ID of the user.
        """
        self.assertIsNone(
            firebase_auth_services.get_auth_id_from_user_id(user_id))
        self.assertIsNone(
            firebase_auth_services.get_user_id_from_auth_id(firebase_auth_id))
Ejemplo n.º 7
0
    def assert_firebase_assoc_exists(self, firebase_auth_id, user_id):
        """Asserts that the given user's Firebase association exists.

        Args:
            user_id: str. The Oppia ID of the user.
            firebase_auth_id: str. The Firebase account ID of the user.
        """
        self.assertEqual(
            firebase_auth_services.get_auth_id_from_user_id(user_id),
            firebase_auth_id)
        self.assertEqual(
            firebase_auth_services.get_user_id_from_auth_id(firebase_auth_id),
            user_id)
 def test_get_association_that_is_missing(self):
     self.assertIsNone(
         firebase_auth_services.get_user_id_from_auth_id('does_not_exist'))
     self.assertIsNone(
         firebase_auth_services.get_auth_id_from_user_id('does_not_exist'))
Ejemplo n.º 9
0
 def test_get_association_that_does_not_exist(self):
     self.assertIsNone(
         auth_services.get_user_id_from_auth_id('does_not_exist'))
Ejemplo n.º 10
0
    def test_get_association_that_exists(self):
        self.put_association(auth_domain.AuthIdUserIdPair('sub', 'uid'))

        self.assertEqual(auth_services.get_user_id_from_auth_id('sub'), 'uid')