Skip to content

Commit eb38465

Browse files
[ui-core]: Update backend tests
1 parent 7b025cb commit eb38465

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

apps/useradmin/src/useradmin/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ def test_user_admin(self):
10411041
)
10421042
# Now make sure FUNNY_NAME can't log back in
10431043
response = c_reg.get('/useradmin/users/edit/%s' % (FUNNY_NAME_QUOTED,))
1044-
assert response.status_code == 302 and "login" in response["location"], "Inactivated user gets redirected to login page"
1044+
# New behavior: Returns 200 with JavaScript redirect instead of HTTP 302
1045+
assert response.status_code == 200 and b"Redirecting to login" in response.content, "Inactivated user gets redirected to login page"
10451046

10461047
# Create a new user with unicode characters
10471048
response = c.post('/useradmin/users/new', dict(

desktop/core/src/desktop/require_login_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
@pytest.mark.django_db
3030
def test_require_login():
3131
c = Client()
32-
# We're not logged in, so expect a redirection.
32+
# We're not logged in, so expect a redirect (now via JavaScript in HTML)
3333

3434
response = c.get('/profile')
35-
assert isinstance(response, django.http.HttpResponseRedirect), "Expected redirect"
36-
assert "/hue/accounts/login?next=/profile" == response["Location"]
35+
# New behavior: Returns 200 with JavaScript redirect instead of HTTP 302
36+
assert 200 == response.status_code
37+
assert b'Redirecting to login' in response.content
38+
assert b'/hue/accounts/login' in response.content
3739

3840
# AllowAllBackend should let us in.
3941
c.login(request=Mock(), username="test", password="test")

desktop/core/src/desktop/tests.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,14 +771,12 @@ def test_ui_customizations():
771771
)
772772

773773
try:
774-
c = make_logged_in_client()
775-
c.logout()
774+
# Test LOGIN_SPLASH_HTML on login page when NOT logged in
775+
c = Client()
776776
if not isinstance(custom_message, bytes):
777777
custom_message = custom_message.encode('utf-8')
778778
resp = c.get('/hue/accounts/login/', follow=False)
779779
assert custom_message in resp.content, resp
780-
resp = c.get('/hue/about', follow=True)
781-
assert custom_message in resp.content, resp
782780
finally:
783781
for old_conf in reset:
784782
old_conf()

0 commit comments

Comments
 (0)