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