|
@@ -47,6 +47,9 @@ class UserManagementClient(APIClient):
|
|
'password': password,
|
|
'password': password,
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ def logout(self, token):
|
|
|
|
+ return self.post(reverse('v1:logout'), HTTP_AUTHORIZATION=f'Token {token}')
|
|
|
|
+
|
|
def reset_password(self, email):
|
|
def reset_password(self, email):
|
|
return self.post(reverse('v1:account-reset-password'), {
|
|
return self.post(reverse('v1:account-reset-password'), {
|
|
'email': email,
|
|
'email': email,
|
|
@@ -98,6 +101,9 @@ class UserManagementTestCase(DesecTestCase, PublicSuffixMockMixin):
|
|
token = response.data.get('token')
|
|
token = response.data.get('token')
|
|
return token, response
|
|
return token, response
|
|
|
|
|
|
|
|
+ def logout(self, token):
|
|
|
|
+ return self.client.logout(token)
|
|
|
|
+
|
|
def reset_password(self, email):
|
|
def reset_password(self, email):
|
|
return self.client.reset_password(email)
|
|
return self.client.reset_password(email)
|
|
|
|
|
|
@@ -214,6 +220,9 @@ class UserManagementTestCase(DesecTestCase, PublicSuffixMockMixin):
|
|
status_code=status.HTTP_200_OK
|
|
status_code=status.HTTP_200_OK
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+ def assertLogoutSuccessResponse(self, response):
|
|
|
|
+ return self.assertStatus(response, status.HTTP_204_NO_CONTENT)
|
|
|
|
+
|
|
def assertRegistrationFailurePasswordRequiredResponse(self, response):
|
|
def assertRegistrationFailurePasswordRequiredResponse(self, response):
|
|
self.assertContains(
|
|
self.assertContains(
|
|
response=response,
|
|
response=response,
|
|
@@ -418,6 +427,11 @@ class UserManagementTestCase(DesecTestCase, PublicSuffixMockMixin):
|
|
self.assertLoginSuccessResponse(response)
|
|
self.assertLoginSuccessResponse(response)
|
|
return token
|
|
return token
|
|
|
|
|
|
|
|
+ def _test_logout(self):
|
|
|
|
+ response = self.logout(self.token)
|
|
|
|
+ self.assertLogoutSuccessResponse(response)
|
|
|
|
+ return response
|
|
|
|
+
|
|
def _test_reset_password(self, email, new_password=None, **kwargs):
|
|
def _test_reset_password(self, email, new_password=None, **kwargs):
|
|
new_password = new_password or self.random_password()
|
|
new_password = new_password or self.random_password()
|
|
self.assertResetPasswordSuccessResponse(self.reset_password(email))
|
|
self.assertResetPasswordSuccessResponse(self.reset_password(email))
|
|
@@ -455,6 +469,7 @@ class UserLifeCycleTestCase(UserManagementTestCase):
|
|
mail.outbox = []
|
|
mail.outbox = []
|
|
self.token = self._test_login()
|
|
self.token = self._test_login()
|
|
email = self._test_change_email()
|
|
email = self._test_change_email()
|
|
|
|
+ self._test_logout()
|
|
self._test_delete_account(email, self.password)
|
|
self._test_delete_account(email, self.password)
|
|
|
|
|
|
|
|
|