You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I log in through the test client, the following requests should be authenticated.
Actual Behavior
Whenever I try to use the client login in Django tests, it gets ignored and I get a redirect to the login page.
After a few test I noticed that it logs me in correctly, but kicks me out when I use it (see below).
Steps to Reproduce the Problem
Here is a stripped down version of my code that still reproduces this.
fromdjango.authimportget_userfromdjango.testimportTestCasefromdjango.urlsimportreverseclassMapListViewTest(TestCase):
@classmethoddefsetUpTestData(cls):
# Create a usercls.user=get_user_model().objects.create(username="testuser")
cls.user.set_password("password")
cls.user.save()
defsetUp(self):
self.client.login(
username=self.user.get_username(), password=self.user.password
)
deftest_map_list_view_renders(self):
"""Test that the MapListView renders successfully and includes a list of maps."""logger.info(get_user(self.client)) # <-- <django.contrib.auth.models.AnonymousUser object at 0x7377d5589540>self.client.login(
username=self.user.get_username(), password=self.user.password
)
logger.info(get_user(self.client)) # <-- <Profile: testuser>response=self.client.get(reverse("map_list"), follow=True)
logger.info(get_user(self.client)) # <-- <django.contrib.auth.models.AnonymousUser object at 0x7377d5589540>self.assertEqual(response.status_code, 200) # <-- OKself.assertTemplateUsed(response, "my_maps/map_list.html") # <-- lands on 'account/login.html'
I don't know if this is of any relevance, but the redirection changes the address from http://localhost/... to http://testserver/....
Also, this works correctly on vanilla django with the built-in user model.
Specifications
GeoNode version: 4.3.x
Installation type (vanilla, geonode-project): geonode-project
Installation method (manual, docker): docker
Platform: Ubuntu
Additional details:
The text was updated successfully, but these errors were encountered:
Expected Behavior
When I log in through the test client, the following requests should be authenticated.
Actual Behavior
Whenever I try to use the client login in Django tests, it gets ignored and I get a redirect to the login page.
After a few test I noticed that it logs me in correctly, but kicks me out when I use it (see below).
Steps to Reproduce the Problem
Here is a stripped down version of my code that still reproduces this.
I don't know if this is of any relevance, but the redirection changes the address from
http://localhost/...
tohttp://testserver/...
.Also, this works correctly on vanilla django with the built-in user model.
Specifications
The text was updated successfully, but these errors were encountered: