Leon4gr45 commited on
Commit
e2b6aab
·
verified ·
1 Parent(s): afcce48

Delete test/plausible_web/plugs/sso_team_access_test.exs with huggingface_hub

Browse files
test/plausible_web/plugs/sso_team_access_test.exs DELETED
@@ -1,143 +0,0 @@
1
- defmodule Plausible.Plugs.SSOTeamAccessTest do
2
- use PlausibleWeb.ConnCase, async: true
3
-
4
- on_ee do
5
- alias Plausible.Auth
6
- alias Plausible.Plugs.SSOTeamAccess
7
- alias PlausibleWeb.AuthPlug
8
-
9
- describe "no user" do
10
- test "passes through when there's no user" do
11
- conn = SSOTeamAccess.call(build_conn(), [])
12
- refute conn.halted
13
- end
14
- end
15
-
16
- describe "no team" do
17
- setup [:create_user, :log_in]
18
-
19
- test "passes through when there's no team", %{conn: conn} do
20
- conn =
21
- conn
22
- |> Plug.Conn.fetch_query_params()
23
- |> AuthPlug.call([])
24
- |> SSOTeamAccess.call([])
25
-
26
- refute conn.halted
27
- end
28
- end
29
-
30
- describe "non-SSO team" do
31
- setup [:create_user, :create_team, :log_in, :setup_team]
32
-
33
- test "passes through for non-SSO team", %{conn: conn} do
34
- conn =
35
- conn
36
- |> Plug.Conn.fetch_query_params()
37
- |> AuthPlug.call([])
38
- |> SSOTeamAccess.call([])
39
-
40
- refute conn.halted
41
- end
42
- end
43
-
44
- describe "SSO team with provisioned user" do
45
- setup [
46
- :create_user,
47
- :create_site,
48
- :create_team,
49
- :setup_sso,
50
- :provision_sso_user,
51
- :log_in,
52
- :setup_team
53
- ]
54
-
55
- test "passes for SSO team without force SSO", %{conn: conn} do
56
- conn =
57
- conn
58
- |> Plug.Conn.fetch_query_params()
59
- |> AuthPlug.call([])
60
- |> SSOTeamAccess.call([])
61
-
62
- refute conn.halted
63
- end
64
-
65
- test "passes for SSO team with force SSO", %{conn: conn, team: team, user: user} do
66
- {:ok, user, _} = Auth.TOTP.initiate(user)
67
- {:ok, _user, _} = Auth.TOTP.enable(user, :skip_verify)
68
- {:ok, _team} = Auth.SSO.set_force_sso(team, :all_but_owners)
69
-
70
- conn =
71
- conn
72
- |> Plug.Conn.fetch_query_params()
73
- |> AuthPlug.call([])
74
- |> SSOTeamAccess.call([])
75
-
76
- refute conn.halted
77
- end
78
- end
79
-
80
- describe "SSO team with non-provisioned user" do
81
- setup [:create_user, :create_site, :create_team, :setup_sso, :log_in, :setup_team]
82
-
83
- test "passes for SSO team without force SSO", %{conn: conn} do
84
- conn =
85
- conn
86
- |> Plug.Conn.fetch_query_params()
87
- |> AuthPlug.call([])
88
- |> SSOTeamAccess.call([])
89
-
90
- refute conn.halted
91
- end
92
-
93
- test "redirects to notice for SSO team with force SSO", %{
94
- conn: conn,
95
- team: team,
96
- user: user,
97
- sso_integration: integration
98
- } do
99
- {:ok, user, _} = Auth.TOTP.initiate(user)
100
- {:ok, _user, _} = Auth.TOTP.enable(user, :skip_verify)
101
- identity = new_identity("Woozy Wooster", "woozy@example.com", integration)
102
- Auth.SSO.provision_user(identity)
103
- {:ok, _team} = Auth.SSO.set_force_sso(team, :all_but_owners)
104
-
105
- conn =
106
- conn
107
- |> Plug.Conn.fetch_query_params()
108
- |> AuthPlug.call([])
109
- |> SSOTeamAccess.call([])
110
-
111
- assert conn.halted
112
- assert redirected_to(conn, 302) == Routes.sso_path(conn, :provision_notice)
113
- end
114
-
115
- test "redirects to issue notice for SSO team with force SSO and user in invalid state", %{
116
- conn: conn,
117
- team: team,
118
- user: user,
119
- sso_integration: integration
120
- } do
121
- another_team = new_site().team |> Plausible.Teams.complete_setup()
122
- add_member(another_team, user: user, role: :viewer)
123
-
124
- {:ok, user, _} = Auth.TOTP.initiate(user)
125
- {:ok, _user, _} = Auth.TOTP.enable(user, :skip_verify)
126
- identity = new_identity("Woozy Wooster", "woozy@example.com", integration)
127
- Auth.SSO.provision_user(identity)
128
- {:ok, _team} = Auth.SSO.set_force_sso(team, :all_but_owners)
129
-
130
- conn =
131
- conn
132
- |> Plug.Conn.fetch_query_params()
133
- |> AuthPlug.call([])
134
- |> SSOTeamAccess.call([])
135
-
136
- assert conn.halted
137
-
138
- assert redirected_to(conn, 302) ==
139
- Routes.sso_path(conn, :provision_issue, issue: "multiple_memberships")
140
- end
141
- end
142
- end
143
- end