Ejemplo n.º 1
0
 def test_community_app(self):
     app = APIAppFactory.create(is_mozilla_app=False)
     request = RequestFactory()
     request.GET = {'app_key': app.key, 'app_name': app.name}
     authentication = AppAuthentication()
     authentication.is_authenticated(request)
     eq_(request.GET.get('restricted'), True)
Ejemplo n.º 2
0
 class Meta:
     authentication = AppAuthentication()
     authorization = ReadOnlyAuthorization()
     cache_control = {'max-age': 0}
     list_allowed_methods = ['get']
     detail_allowed_methods = ['get']
     paginator_class = Paginator
     serializer = Serializer(formats=['json', 'jsonp'])
     fields = ['id', 'name', 'number_of_members']
     ordering = ['id', 'name', 'number_of_members']
     default_order = ['id']
Ejemplo n.º 3
0
 class Meta:
     queryset = UserProfile.objects.all()
     authentication = AppAuthentication()
     authorization = ReadOnlyAuthorization()
     serializer = Serializer(formats=['json', 'jsonp'])
     paginator_class = Paginator
     cache_control = {'max-age': 0}
     list_allowed_methods = ['get']
     detail_allowed_methods = ['get']
     resource_name = 'users'
     restrict_fields = False
     restricted_fields = ['email', 'is_vouched']
     fields = ['id', 'full_name', 'is_vouched', 'vouched_by',
               'date_vouched', 'groups', 'skills',
               'bio', 'photo', 'ircname', 'country', 'region', 'city',
               'date_mozillian', 'timezone', 'email', 'allows_mozilla_sites',
               'allows_community_sites']
Ejemplo n.º 4
0
 def test_invalid_app_name_and_key(self):
     request = RequestFactory()
     request.GET = {'app_key': 'invalid', 'app_name': 'invalid'}
     authentication = AppAuthentication()
     eq_(authentication.is_authenticated(request), False)
Ejemplo n.º 5
0
 def test_invalid_app_key(self):
     app = APIAppFactory.create()
     request = RequestFactory()
     request.GET = {'app_key': 'invalid', 'app_name': app.name}
     authentication = AppAuthentication()
     eq_(authentication.is_authenticated(request), False)
Ejemplo n.º 6
0
 def test_empty_app_name(self):
     app = APIAppFactory.create()
     request = RequestFactory()
     request.GET = {'app_key': app.key}
     authentication = AppAuthentication()
     eq_(authentication.is_authenticated(request), False)
Ejemplo n.º 7
0
 def test_valid_app(self):
     app = APIAppFactory.create()
     request = RequestFactory()
     request.GET = {'app_key': app.key, 'app_name': app.name}
     authentication = AppAuthentication()
     ok_(authentication.is_authenticated(request))