@@ -18,7 +18,7 @@ defmodule Unlock.Plugs.TokenAuthTest do
1818 setup_token_auth_enabled ( true )
1919 end
2020
21- test "valid token passed: request is logged " do
21+ test "valid token passed: request goes through " do
2222 slug = "valid-token-logged-#{ Ecto.UUID . generate ( ) } "
2323 % DB.Token { id: token_id } = token = insert_token ( )
2424
@@ -40,10 +40,6 @@ defmodule Unlock.Plugs.TokenAuthTest do
4040
4141 assert resp . resp_body == "somebody-to-love"
4242 assert % DB.Token { id: ^ token_id } = resp . assigns [ :token ]
43-
44- assert [
45- % DB.ProxyRequest { proxy_id: ^ slug , token_id: ^ token_id }
46- ] = DB.ProxyRequest |> DB.Repo . all ( )
4743 end
4844
4945 test "no token passed" do
@@ -67,17 +63,13 @@ defmodule Unlock.Plugs.TokenAuthTest do
6763
6864 assert resp . resp_body == "somebody-to-love"
6965 assert is_nil ( resp . assigns [ :token ] )
70-
71- assert [ ] = DB.ProxyRequest |> DB.Repo . all ( )
7266 end
7367
7468 test "invalid token passed" do
7569 resp = proxy_conn ( ) |> get ( "/resource/slug?token=invalid" )
7670
7771 assert resp . status == 401
7872 assert resp . resp_body == ~s| {"error":"You must set a valid token in the query parameters"}|
79-
80- assert DB.ProxyRequest |> DB.Repo . all ( ) == [ ]
8173 end
8274 end
8375
@@ -86,30 +78,6 @@ defmodule Unlock.Plugs.TokenAuthTest do
8678 setup_token_auth_enabled ( false )
8779 end
8880
89- test "valid token passed: no requests logged" do
90- slug = "valid-token-not-logged-#{ Ecto.UUID . generate ( ) } "
91- token = insert_token ( )
92-
93- setup_proxy_config ( % {
94- slug => % Unlock.Config.Item.Generic.HTTP {
95- identifier: slug ,
96- target_url: target_url = "http://localhost/some-remote-resource" ,
97- ttl: 30
98- }
99- } )
100-
101- Unlock.HTTP.Client.Mock
102- |> expect ( :get! , fn url , _headers = [ ] , _options = [ ] ->
103- assert url == target_url
104- % Unlock.HTTP.Response { body: "somebody-to-love" , status: 200 , headers: [ ] }
105- end )
106-
107- resp = proxy_conn ( ) |> get ( "/resource/#{ slug } ?token=#{ token . secret } " )
108- assert resp . resp_body == "somebody-to-love"
109-
110- assert [ ] = DB.ProxyRequest |> DB.Repo . all ( )
111- end
112-
11381 test "invalid token passes through without authentication" do
11482 slug = "invalid-token-passthrough-#{ Ecto.UUID . generate ( ) } "
11583
@@ -132,8 +100,6 @@ defmodule Unlock.Plugs.TokenAuthTest do
132100 assert resp . status == 200
133101 assert resp . resp_body == "somebody-to-love"
134102 assert is_nil ( resp . assigns [ :token ] )
135-
136- assert [ ] = DB.ProxyRequest |> DB.Repo . all ( )
137103 end
138104 end
139105
0 commit comments