|
14 | 14 | ) |
15 | 15 |
|
16 | 16 | import pytest |
| 17 | +from social_core.utils import setting_name |
17 | 18 |
|
18 | 19 | from galaxy.authnz.cilogon import CILogonOpenIdConnect |
19 | 20 | from galaxy.authnz.keycloak import KeycloakOpenIdConnect |
| 21 | +from galaxy.authnz.psa_authnz import ( |
| 22 | + associate_by_email_if_logged_in, |
| 23 | + check_user_creation_confirmation, |
| 24 | +) |
20 | 25 |
|
21 | 26 |
|
22 | 27 | class MockStrategy: |
@@ -506,11 +511,6 @@ def test_callback_user_not_created_when_does_not_exist(self): |
506 | 511 | they should be redirected to a confirmation page instead of having their |
507 | 512 | account created immediately. |
508 | 513 | """ |
509 | | - from galaxy.authnz.psa_authnz import ( |
510 | | - check_user_creation_confirmation, |
511 | | - setting_name, |
512 | | - ) |
513 | | - |
514 | 514 | # Setup strategy with require_create_confirmation enabled |
515 | 515 | strategy = MockStrategy( |
516 | 516 | { |
@@ -680,11 +680,6 @@ class TestFixedDelegatedAuth: |
680 | 680 |
|
681 | 681 | def test_fixed_delegated_auth_auto_associates_existing_user(self): |
682 | 682 | """Test that fixed_delegated_auth automatically associates with existing user.""" |
683 | | - from galaxy.authnz.psa_authnz import ( |
684 | | - associate_by_email_if_logged_in, |
685 | | - setting_name, |
686 | | - ) |
687 | | - |
688 | 683 | strategy = MockStrategy( |
689 | 684 | { |
690 | 685 | "FIXED_DELEGATED_AUTH": True, |
@@ -724,11 +719,6 @@ def test_fixed_delegated_auth_auto_associates_existing_user(self): |
724 | 719 |
|
725 | 720 | def test_fixed_delegated_auth_continues_when_no_user(self): |
726 | 721 | """Test that fixed_delegated_auth continues to user creation when no user exists.""" |
727 | | - from galaxy.authnz.psa_authnz import ( |
728 | | - associate_by_email_if_logged_in, |
729 | | - setting_name, |
730 | | - ) |
731 | | - |
732 | 722 | strategy = MockStrategy( |
733 | 723 | { |
734 | 724 | "FIXED_DELEGATED_AUTH": True, |
@@ -764,11 +754,6 @@ def test_fixed_delegated_auth_continues_when_no_user(self): |
764 | 754 |
|
765 | 755 | def test_without_fixed_delegated_auth_prompts_for_login(self): |
766 | 756 | """Test that without fixed_delegated_auth, users are prompted to log in.""" |
767 | | - from galaxy.authnz.psa_authnz import ( |
768 | | - associate_by_email_if_logged_in, |
769 | | - setting_name, |
770 | | - ) |
771 | | - |
772 | 757 | strategy = MockStrategy( |
773 | 758 | { |
774 | 759 | "FIXED_DELEGATED_AUTH": False, |
@@ -809,61 +794,5 @@ def test_without_fixed_delegated_auth_prompts_for_login(self): |
809 | 794 | assert "connect_external_email=" in result |
810 | 795 |
|
811 | 796 |
|
812 | | -class TestRedirectURL: |
813 | | - """Test the set_redirect_url pipeline step.""" |
814 | | - |
815 | | - def test_fixed_delegated_auth_redirects_to_root(self): |
816 | | - """Test that fixed_delegated_auth redirects to root URL.""" |
817 | | - from galaxy.authnz.psa_authnz import ( |
818 | | - set_redirect_url, |
819 | | - setting_name, |
820 | | - ) |
821 | | - |
822 | | - strategy = MockStrategy( |
823 | | - { |
824 | | - "FIXED_DELEGATED_AUTH": True, |
825 | | - setting_name("LOGIN_REDIRECT_URL"): "http://localhost:8080/", |
826 | | - } |
827 | | - ) |
828 | | - |
829 | | - backend = Mock() |
830 | | - |
831 | | - set_redirect_url( |
832 | | - strategy=strategy, |
833 | | - backend=backend, |
834 | | - details={}, |
835 | | - user=Mock(), |
836 | | - ) |
837 | | - |
838 | | - # Should set redirect to root URL |
839 | | - assert strategy.session.get("next") == "http://localhost:8080/" |
840 | | - |
841 | | - def test_without_fixed_delegated_auth_redirects_to_external_ids(self): |
842 | | - """Test that without fixed_delegated_auth, redirect goes to user/external_ids.""" |
843 | | - from galaxy.authnz.psa_authnz import ( |
844 | | - set_redirect_url, |
845 | | - setting_name, |
846 | | - ) |
847 | | - |
848 | | - strategy = MockStrategy( |
849 | | - { |
850 | | - "FIXED_DELEGATED_AUTH": False, |
851 | | - setting_name("LOGIN_REDIRECT_URL"): "http://localhost:8080/", |
852 | | - } |
853 | | - ) |
854 | | - |
855 | | - backend = Mock() |
856 | | - |
857 | | - set_redirect_url( |
858 | | - strategy=strategy, |
859 | | - backend=backend, |
860 | | - details={}, |
861 | | - user=Mock(), |
862 | | - ) |
863 | | - |
864 | | - # Should set redirect to user/external_ids |
865 | | - assert strategy.session.get("next") == "http://localhost:8080/user/external_ids" |
866 | | - |
867 | | - |
868 | 797 | if __name__ == "__main__": |
869 | 798 | pytest.main([__file__, "-v"]) |
0 commit comments