dev-resources.site
for different kinds of informations.
AssertionError: 403
Published at
11/28/2024
Categories
drf
django
Author
hyun_hyun
Main Article
Author
9 person written this
hyun_hyun
open
The error messages.
apple@GH-MacBook-Pro hyunphoto-cbv % docker compose run --rm app sh -c "python manage.py test"
[+] Creating 1/0
✔ Container hyunphoto-cbv-db-1 Running 0.0s
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
..............FFFWaiting for database...
Database unavailable, wating 1 second ...
Database unavailable, wating 1 second ...
Database unavailable, wating 1 second ...
Database unavailable, wating 1 second ...
Database unavailable, wating 1 second ...
Database available!
.Waiting for database...
Database available!
.
======================================================================
FAIL: test_signup_user_exist_error (user.tests.test_user_api.PublicUserApiTests)
Test signup a user is fail, email already exists.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/app/user/tests/test_user_api.py", line 47, in test_signup_user_exist_error
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
AssertionError: 403 != 400
======================================================================
FAIL: test_signup_user_password_short_error (user.tests.test_user_api.PublicUserApiTests)
Test signup a user is fail, password is too short.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/app/user/tests/test_user_api.py", line 58, in test_signup_user_password_short_error
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)
AssertionError: 403 != 400
======================================================================
FAIL: test_signup_user_success (user.tests.test_user_api.PublicUserApiTests)
Test creating/signup a user is successful.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/app/user/tests/test_user_api.py", line 32, in test_signup_user_success
self.assertEqual(res.status_code, status.HTTP_201_CREATED)
AssertionError: 403 != 201
----------------------------------------------------------------------
Ran 19 tests in 8.604s
FAILED (failures=3)
Destroying test database for alias 'default'...
The causes can be
- views.py
- serializers.py
- something else
It was my views.py code.
class CreateUserView(generics.ListCreateAPIView):
serializer_class = UserSerializer
I couldn't believe this situation. Because it worked very well yesterday. I don't know why it doesn't work but I have to figure out.
I have suspicion to permission.
I modified views.py and
class CreateUserView(generics.CreateAPIView):
serializer_class = UserSerializer
permission_classes = [AllowAny]
It fixed.
----------------------------------------------------------------------
Ran 19 tests in 8.788s
OK
Destroying test database for alias 'default'...
I just... still have a question... Why it worked yesterday...?
drf Article's
30 articles in total
Djoser+SimpleJWT
read article
AssertionError: 403
currently reading
extra_kwargs arguments
read article
To Django or to DjangoREST?
read article
Django API | queryset & object, filter() & get()
read article
I just tried to compare values between model and serializer
read article
Customize Schema with @extend_schema_view
read article
Seperate serializers
read article
Leveraging Headers for Dynamic Localization in Django
read article
Django REST Framework warning: `UnorderedObjectListWarning`
read article
DRF create @property decorator in view and use property in serializer
read article
why Serializers used for? easy to understand
read article
Async API Calls Unleashed: Exploring Django 4 and Django Rest Framework
read article
# Comprehensive Security for Class-Based Views in Django Rest Framework
read article
HATEOAS Principle - Generating Full Paths for Objects in Django Rest Framework.
read article
Instance version control in DRF with Django Reversion
read article
Django News #171 - DjangoCon US 2023 Preview
read article
How to create thumbnails programmatically in Django
read article
Automatically Add Logged In User Under 'created_by' and 'updated_by' to Model in Django Rest Framework
read article
how to fix raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
read article
CSRF verification failed. Request aborted. in django rest framework
read article
CSRF verification failed. Request aborted. in django rest framework
read article
How to fix "Must supply api_key"
read article
Updating A Many-To-Many Relationship In Django
read article
Excluding Fields in Django Rest Framework Serializers
read article
JWT Authentication with Django REST Framework - What? Why? How?
read article
How to implement Auto Expiring Token in Django Rest Framework
read article
Building web applications with Django, Django REST Framework and Nuxt
read article
How to use Postman to authenticate to Django Rest Framework
read article
Setting Up Django Rest Framework
read article
Featured ones: