Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2021
Kelas D
PT Gizi Sehat - Dietela
Dietela Backend
Commits
a4708230
Commit
a4708230
authored
Apr 19, 2021
by
Kefas Satrio Bangkit Solidedantyo
Browse files
Merge branch 'PBI-5-login' into 'staging'
Pbi 5 login See merge request
!36
parents
9549a1f0
76f57efb
Pipeline
#70852
passed with stages
in 6 minutes and 53 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
authentication/tests.py
View file @
a4708230
...
...
@@ -176,3 +176,44 @@ class UserModelTests(APITestCase):
response
=
self
.
client
.
post
(
'/auth/link-user-and-diet-profile/'
,
data
,
format
=
'json'
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
).
get
(
'message'
),
'Diet profile is not found.'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
def
test_post_login_user_succeed
(
self
):
data
=
{
'email'
:
'email@email.com'
,
'password'
:
'abc'
,
}
response
=
self
.
client
.
post
(
'/auth/login/'
,
data
,
format
=
'json'
)
json_response
=
json
.
loads
(
response
.
content
)
self
.
assertIn
(
'access_token'
,
json_response
)
self
.
assertIn
(
'refresh_token'
,
json_response
)
self
.
assertIn
(
'user'
,
json_response
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
def
test_post_login_user_failed_because_non_existing_email
(
self
):
data
=
{
'email'
:
'email123123123@email.com'
,
'password'
:
'abc'
,
}
response
=
self
.
client
.
post
(
'/auth/login/'
,
data
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
def
test_post_login_user_failed_because_invalid_email_format
(
self
):
data
=
{
'email'
:
'email123123123@email'
,
'password'
:
'abc'
,
}
response
=
self
.
client
.
post
(
'/auth/login/'
,
data
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
def
test_post_login_user_failed_because_invalid_password
(
self
):
data
=
{
'email'
:
'email@email.com'
,
'password'
:
'abc1234'
,
}
response
=
self
.
client
.
post
(
'/auth/login/'
,
data
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
authentication/urls.py
View file @
a4708230
...
...
@@ -8,6 +8,7 @@ router.register('auth/link-user-and-diet-profile', LinkUserAndDietProfileViewSet
urlpatterns
=
[
path
(
'auth/registration/'
,
include
(
'dj_rest_auth.registration.urls'
)),
path
(
'auth/'
,
include
(
'dj_rest_auth.urls'
)),
]
urlpatterns
+=
router
.
urls
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment