Skip to content

Commit

Permalink
[Fixes #8691] Geonode 3.3.x build is broken (#8692)
Browse files Browse the repository at this point in the history
* [Fixes #8691] Fix UserViewSet permissions_classes

* [Fixes #8691] Fix content type
  • Loading branch information
mattiagiupponi authored Jan 26, 2022
1 parent c2f28c6 commit 5680456
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions geonode/base/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,23 @@ def test_register_users(self):
user_data = {
'username': 'new_user',
}
self.client.login(username='admin', password="admin")
response = self.client.post(url, data=user_data, format='json')
self.assertEqual(response.status_code, 201)
# default contributor group_perm is returned in perms
self.assertIn('add_resource', response.data['user']['perms'])

def test_register_users_anonymous(self):
"""
Ensure users are created with default groups.
"""
url = reverse('users-list')
user_data = {
'username': 'new_user',
}
response = self.client.post(url, data=user_data, format='json')
self.assertEqual(response.status_code, 403)

def test_base_resources(self):
"""
Ensure we can access the Resource Base list.
Expand Down
4 changes: 2 additions & 2 deletions geonode/base/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
from guardian.shortcuts import get_objects_for_user

from .permissions import (
IsSelfOrAdmin,
IsOwnerOrAdmin,
IsOwnerOrReadOnly,
IsSelfOrAdminOrReadOnly,
ResourceBasePermissionsFilter
)
from .serializers import (
Expand Down Expand Up @@ -81,7 +81,7 @@ class UserViewSet(DynamicModelViewSet):
API endpoint that allows users to be viewed or edited.
"""
authentication_classes = [SessionAuthentication, BasicAuthentication, OAuth2Authentication]
permission_classes = [IsSelfOrAdmin, ]
permission_classes = [IsSelfOrAdminOrReadOnly, ]
queryset = get_user_model().objects.all()
serializer_class = UserSerializer
pagination_class = GeoNodeApiPagination
Expand Down
2 changes: 1 addition & 1 deletion geonode/security/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ def test_layer_permissions(self):
response = requests.get(url, auth=HTTPBasicAuth(username='norman', password='norman'))
self.assertTrue(response.status_code, 404)
self.assertEqual(
response.headers.get('Content-Type'),
response.headers.get('Content-Type').replace(' ', ''),
'text/html;charset=utf-8'
)

Expand Down

0 comments on commit 5680456

Please sign in to comment.