Ejemplo n.º 1
0
    def test_set_extra_data(self):
        """Testing UserApplicationCreationForm cannot assign extra_data"""
        user = User.objects.get(username='******')
        form = UserApplicationCreationForm(
            user,
            data={
                'authorization_grant_type': Application.GRANT_IMPLICIT,
                'client_type': Application.CLIENT_PUBLIC,
                'name': 'test',
                'redirect_uris': 'http://example.com',
                'extra_data': 1,
            },
        )

        self.assertTrue(form.is_valid())
        application = form.save()
        self.assertEqual(application.extra_data, {})
Ejemplo n.º 2
0
    def test_set_extra_data(self):
        """Testing UserApplicationCreationForm cannot assign extra_data"""
        user = User.objects.get(username='******')
        form = UserApplicationCreationForm(
            user,
            data={
                'authorization_grant_type': Application.GRANT_IMPLICIT,
                'client_type': Application.CLIENT_PUBLIC,
                'name': 'test',
                'redirect_uris': 'http://example.com',
                'extra_data': 1,
            },
        )

        self.assertTrue(form.is_valid())
        application = form.save()
        self.assertEqual(application.extra_data, {})
Ejemplo n.º 3
0
    def test_assign_local_site_inacessible(self):
        """Testing UserApplicationCreationForm with an inaccessible Local Site
        """
        local_site = LocalSite.objects.create(name='inacessible')
        user = User.objects.get(username='******')

        form = UserApplicationCreationForm(
            user,
            data={
                'authorization_grant_type': Application.GRANT_IMPLICIT,
                'client_type': Application.CLIENT_PUBLIC,
                'name': 'test',
                'redirect_uris': 'http://example.com',
                'local_site': local_site.pk
            },
        )

        self.assertFalse(form.is_valid())
Ejemplo n.º 4
0
    def test_assign_local_site(self):
        """Testing UserApplicationCreationForm cannot assign Local Site"""
        user = User.objects.get(username='******')

        form = UserApplicationCreationForm(
            user,
            data={
                'authorization_grant_type': Application.GRANT_IMPLICIT,
                'client_type': Application.CLIENT_PUBLIC,
                'name': 'test',
                'redirect_uris': 'http://example.com',
                'local_site': 'local-site-1',
            },
        )

        self.assertTrue(form.is_valid())
        application = form.save()
        self.assertEqual(application.local_site, None)
Ejemplo n.º 5
0
    def test_assign_local_site_inacessible(self):
        """Testing UserApplicationCreationForm with an inaccessible Local Site
        """
        local_site = LocalSite.objects.create(name='inacessible')
        user = User.objects.get(username='******')

        form = UserApplicationCreationForm(
            user,
            data={
                'authorization_grant_type': Application.GRANT_IMPLICIT,
                'client_type': Application.CLIENT_PUBLIC,
                'name': 'test',
                'redirect_uris': 'http://example.com',
                'local_site': local_site.pk
            },
        )

        self.assertFalse(form.is_valid())
Ejemplo n.º 6
0
    def test_set_client_secret(self):
        """Testing UserApplicationCreationForm cannot assign client_secret
        """
        user = User.objects.get(username='******')
        form = UserApplicationCreationForm(
            user,
            data={
                'authorization_grant_type': Application.GRANT_IMPLICIT,
                'client_secret': 'bar',
                'client_type': Application.CLIENT_PUBLIC,
                'name': 'test',
                'redirect_uris': 'http://example.com',
            },
        )

        self.assertTrue(form.is_valid())
        application = form.save()
        self.assertNotEqual(application.client_secret, 'bar')
        self.assertNotEqual(len(application.client_secret), 0)
Ejemplo n.º 7
0
    def test_assign_local_site(self):
        """Testing UserApplicationCreationForm with Local Site"""
        user = User.objects.get(username='******')
        local_site = LocalSite.objects.get(name=self.local_site_name)

        form = UserApplicationCreationForm(
            user,
            data={
                'authorization_grant_type': Application.GRANT_IMPLICIT,
                'client_type': Application.CLIENT_PUBLIC,
                'name': 'test',
                'redirect_uris': 'http://example.com',
                'local_site': local_site.pk
            },
        )

        self.assertTrue(form.is_valid())
        application = form.save()
        self.assertEqual(application.local_site, local_site)
Ejemplo n.º 8
0
    def test_set_client_secret(self):
        """Testing UserApplicationCreationForm cannot assign client_secret
        """
        user = User.objects.get(username='******')
        form = UserApplicationCreationForm(
            user,
            data={
                'authorization_grant_type': Application.GRANT_IMPLICIT,
                'client_secret': 'bar',
                'client_type': Application.CLIENT_PUBLIC,
                'name': 'test',
                'redirect_uris': 'http://example.com',
            },
        )

        self.assertTrue(form.is_valid())
        application = form.save()
        self.assertNotEqual(application.client_secret, 'bar')
        self.assertNotEqual(len(application.client_secret), 0)