예제 #1
0
    def test_improperly_configured(self):
        """
        Test access to resource without any required scopes defined
        """
        self.client.login(username='******', password='******')
        authorization_code = self.get_authorization_code(scopes='read')
        access_token = self.get_access_token(authorization_code)

        headers = {
            'HTTP_AUTHORIZATION': 'Bearer %s' % access_token,
        }
        request = self.factory.get('/fake', **headers)

        view = ResourceNoScopesView.as_view()

        self.assertRaises(ImproperlyConfigured, view, request)
예제 #2
0
    def test_improperly_configured(self):
        """
        Test access to resource without any required scopes defined
        """
        self.client.login(username='******', password='******')
        authorization_code = self.get_authorization_code(scopes='read')
        access_token = self.get_access_token(authorization_code)

        headers = {
            'HTTP_AUTHORIZATION': 'Bearer %s' % access_token,
        }
        request = self.factory.get('/fake', **headers)

        view = ResourceNoScopesView.as_view()

        self.assertRaises(ImproperlyConfigured, view, request)
예제 #3
0
from django.conf.urls import include, url

from oauth_api.tests.views import (ResourceView, ResourceReadScopesView,
                                   ResourceWriteScopesView, ResourceReadWriteScopesView,
                                   ResourceMixedScopesView, ResourceNoScopesView)


urlpatterns = [
    url(r'^oauth/', include('oauth_api.urls', namespace='oauth_api')),
    url(r'^resource-required/', ResourceView.as_view(), name='resource-view'),
    url(r'^resource-read/', ResourceReadScopesView.as_view(), name='resource-read-view'),
    url(r'^resource-write/', ResourceWriteScopesView.as_view(), name='resource-write-view'),
    url(r'^resource-readwrite/', ResourceReadWriteScopesView.as_view(), name='resource-readwrite-view'),
    url(r'^resource-mixed/', ResourceMixedScopesView.as_view(), name='resource-mixed-view'),
    url(r'^resource-noscopes/', ResourceNoScopesView.as_view(), name='resource-noscopes-view'),
]
예제 #4
0
from django.conf.urls import include, url

from oauth_api.tests.views import (ResourceView, ResourceReadScopesView,
                                   ResourceWriteScopesView,
                                   ResourceReadWriteScopesView,
                                   ResourceMixedScopesView,
                                   ResourceNoScopesView)

urlpatterns = [
    url(r'^oauth/',
        include(('oauth_api.urls', 'oauth_api'), namespace='oauth_api')),
    url(r'^resource-required/', ResourceView.as_view(), name='resource-view'),
    url(r'^resource-read/',
        ResourceReadScopesView.as_view(),
        name='resource-read-view'),
    url(r'^resource-write/',
        ResourceWriteScopesView.as_view(),
        name='resource-write-view'),
    url(r'^resource-readwrite/',
        ResourceReadWriteScopesView.as_view(),
        name='resource-readwrite-view'),
    url(r'^resource-mixed/',
        ResourceMixedScopesView.as_view(),
        name='resource-mixed-view'),
    url(r'^resource-noscopes/',
        ResourceNoScopesView.as_view(),
        name='resource-noscopes-view'),
]
예제 #5
0
from django.conf.urls import patterns, include, url

from oauth_api.tests.views import (
    ResourceView,
    ResourceReadScopesView,
    ResourceWriteScopesView,
    ResourceReadWriteScopesView,
    ResourceMixedScopesView,
    ResourceNoScopesView,
)


urlpatterns = patterns(
    "",
    url(r"^oauth/", include("oauth_api.urls", namespace="oauth_api")),
    url(r"^resource-required/", ResourceView.as_view(), name="resource-view"),
    url(r"^resource-read/", ResourceReadScopesView.as_view(), name="resource-read-view"),
    url(r"^resource-write/", ResourceWriteScopesView.as_view(), name="resource-write-view"),
    url(r"^resource-readwrite/", ResourceReadWriteScopesView.as_view(), name="resource-readwrite-view"),
    url(r"^resource-mixed/", ResourceMixedScopesView.as_view(), name="resource-mixed-view"),
    url(r"^resource-noscopes/", ResourceNoScopesView.as_view(), name="resource-noscopes-view"),
)
예제 #6
0
from django.urls import include, path

from oauth_api.tests.views import (ResourceView, ResourceReadScopesView,
                                   ResourceWriteScopesView, ResourceReadWriteScopesView,
                                   ResourceMixedScopesView, ResourceNoScopesView)


urlpatterns = [
    path('oauth/', include(('oauth_api.urls', 'oauth_api'), namespace='oauth_api')),
    path('resource-required/', ResourceView.as_view(), name='resource-view'),
    path('resource-read/', ResourceReadScopesView.as_view(), name='resource-read-view'),
    path('resource-write/', ResourceWriteScopesView.as_view(), name='resource-write-view'),
    path('resource-readwrite/', ResourceReadWriteScopesView.as_view(), name='resource-readwrite-view'),
    path('resource-mixed/', ResourceMixedScopesView.as_view(), name='resource-mixed-view'),
    path('resource-noscopes/', ResourceNoScopesView.as_view(), name='resource-noscopes-view'),
]