Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Backoffice login test: not_logged redirection #10

Open
Nosk14 opened this issue Oct 10, 2017 · 2 comments
Open

Backoffice login test: not_logged redirection #10

Nosk14 opened this issue Oct 10, 2017 · 2 comments
Assignees

Comments

@Nosk14
Copy link
Contributor

Nosk14 commented Oct 10, 2017

I have launched the login tests of the backoffice and I have seen there is a problem with the not_logged test.

def test_not_logged(self):
response = self.client.get(reverse('backoffice_home'))
self.assertRedirects(response, reverse('backoffice_login'))

The test shows the following error:
Response redirected to '/backoffice/login/?next=/backoffice/home/', expected '/backoffice/login/'

It seems it compares the GET params with the URL. So , should we split the URL returned for redirection in case of ignore the GET params in it? Should we include them in the test to be compared?

@pablo-grande
Copy link
Contributor

It is strange because I'm using the redirection given by the test, maybe the assertRedirects is not the best choice.
Does the '/backoffice/login/?next=/backoffice/home/' url counts as a redirection?
Do you think I should forge the url as something like:

reverse('backoffice_login') + '?next=' + reverse('backoffice_home')

@Nosk14
Copy link
Contributor Author

Nosk14 commented Oct 11, 2017

When you try to access to home page without being authenticaed, it redirects you to the login page with the param next that it is used to redirect you again when you log in successfully to the page you tried to access.

I think it's correct that the redirection url is '/backoffice/login/?next=/backoffice/home/' because 'next=/backoffice/home/' is a GET parameter needed for redirect again.

I like your solution. On this way, we test the redirection to login page when you are not loged in and the intention of the login page to move you to home again ( assuming you came from home )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants