66from django_sql_dashboard .models import Dashboard
77
88
9- def test_anonymous_users_denied (client ):
9+ def test_anonymous_user_redirected_to_login (client ):
1010 response = client .get ("/dashboard/?sql=select+1" )
1111 assert response .status_code == 302
1212 assert response .url == "/accounts/login/?next=/dashboard/%3Fsql%3Dselect%2B1"
1313
1414
15- def test_user_without_permission_gets_403 (client , dashboard_db ):
16- user = User .objects .create (username = "noperm" , is_active = True , is_staff = True )
17- client .force_login (user )
18- response = client .get ("/dashboard/" )
19- assert response .status_code == 403
20-
21-
2215def test_superusers_allowed (admin_client , dashboard_db ):
2316 response = admin_client .get ("/dashboard/" )
2417 assert response .status_code == 200
@@ -38,9 +31,9 @@ def test_must_have_execute_sql_permission(
3831 staff_with_permission .user_permissions .add (execute_sql_permission )
3932 assert staff_with_permission .has_perm ("django_sql_dashboard.execute_sql" )
4033 client .force_login (not_staff )
41- assert client .get ("/dashboard/" ).status_code == 302
34+ assert client .get ("/dashboard/" ).status_code == 403
4235 client .force_login (staff_no_permisssion )
43- assert client .get ("/dashboard/" ).status_code == 302
36+ assert client .get ("/dashboard/" ).status_code == 403
4437 client .force_login (staff_with_permission )
4538 assert client .get ("/dashboard/" ).status_code == 200
4639
0 commit comments