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)
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'), ]
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'), ]
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"), )
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'), ]