コード例 #1
0
ファイル: tests.py プロジェクト: pnovotnak/stormpath-django
    def test_authentication_pulls_user_into_local_db(self):
        self.assertEqual(0, UserModel.objects.count())
        acc = self.app.accounts.create({
            'email': '*****@*****.**',
            'given_name': 'John',
            'surname': 'Doe',
            'password': '******',
        })

        b = StormpathBackend()
        b.authenticate(acc.email, 'TestPassword123!')
        self.assertEqual(1, UserModel.objects.count())
コード例 #2
0
    def test_authentication_pulls_user_into_local_db(self):
        self.assertEqual(0, UserModel.objects.count())
        acc = self.app.accounts.create({
            'email': '*****@*****.**',
            'given_name': 'John',
            'surname': 'Doe',
            'password': '******',
        })

        b = StormpathBackend()
        b.authenticate(acc.email, 'TestPassword123!')
        self.assertEqual(1, UserModel.objects.count())
コード例 #3
0
    def test_updating_a_users_password(self):
        user = self.create_django_user(email='*****@*****.**',
                                       first_name='John',
                                       last_name='Doe',
                                       password='******')
        a = self.app.accounts.get(user.href)
        self.assertEqual(user.href, a.href)

        user.set_password('123!TestPassword')
        self.assertTrue(hasattr(user, 'raw_password'))

        user.save()

        b = StormpathBackend()

        self.assertFalse(hasattr(user, 'raw_password'))
        self.assertFalse(user.has_usable_password())
        self.assertTrue(b.authenticate(a.email, '123!TestPassword'))
        self.assertFalse(b.authenticate(a.email, 'TestPassword123!'))
コード例 #4
0
ファイル: tests.py プロジェクト: pnovotnak/stormpath-django
    def test_updating_a_users_password(self):
        user = self.create_django_user(
            email='*****@*****.**',
            first_name='John',
            last_name='Doe',
            password='******',
        )

        a = self.app.accounts.get(user.href)
        self.assertEqual(user.href, a.href)

        user.set_password('123!TestPassword')
        self.assertTrue(hasattr(user, 'raw_password'))

        user.save()

        b = StormpathBackend()

        self.assertFalse(hasattr(user, 'raw_password'))
        self.assertFalse(user.has_usable_password())
        self.assertTrue(b.authenticate(a.email, '123!TestPassword'))
        self.assertFalse(b.authenticate(a.email, 'TestPassword123!'))
コード例 #5
0
ファイル: tests.py プロジェクト: pnovotnak/stormpath-django
    def test_groups_get_pulled_in_on_authentication(self):
        self.assertEqual(0, UserModel.objects.count())
        self.assertEqual(0, Group.objects.count())
        acc = self.app.accounts.create({
            'email': '*****@*****.**',
            'given_name': 'John',
            'surname': 'Doe',
            'password': '******',
        })

        g1 = self.app.groups.create({'name': 'testGroup'})
        g2 = self.app.groups.create({'name': 'testGroup2'})  # noqa

        acc.add_group(g1)
        acc.save()

        b = StormpathBackend()
        user = b.authenticate(acc.email, 'TestPassword123!!!')

        self.assertEqual(1, UserModel.objects.count())
        self.assertEqual(2, Group.objects.count())
        self.assertEqual(1, user.groups.filter(name=g1.name).count())
コード例 #6
0
    def test_groups_get_pulled_in_on_authentication(self):
        self.assertEqual(0, UserModel.objects.count())
        self.assertEqual(0, Group.objects.count())
        acc = self.app.accounts.create({
            'email': '*****@*****.**',
            'given_name': 'John',
            'surname': 'Doe',
            'password': '******',
        })

        g1 = self.app.groups.create({'name': 'testGroup'})
        g2 = self.app.groups.create({'name': 'testGroup2'})  # noqa

        acc.add_group(g1)
        acc.save()

        b = StormpathBackend()
        user = b.authenticate(acc.email, 'TestPassword123!!!')

        self.assertEqual(1, UserModel.objects.count())
        self.assertEqual(2, Group.objects.count())
        self.assertEqual(1, user.groups.filter(name=g1.name).count())
コード例 #7
0
    def test_auth_doesnt_work_for_bogus_user(self):
        b = StormpathBackend()

        u = b.authenticate('*****@*****.**', 'TestPassword123!')
        self.assertIsNone(u)
        self.assertEqual(0, UserModel.objects.count())
コード例 #8
0
ファイル: test_user.py プロジェクト: NobleSF/OpenEntry
    def test_auth_doesnt_work_for_bogus_user(self):
        b = StormpathBackend()

        u = b.authenticate('*****@*****.**', 'TestPassword123!')
        self.assertIsNone(u)
        self.assertEqual(0, UserModel.objects.count())