simple-http 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple/http/version.rb +1 -1
- data/lib/simple/http.rb +4 -3
- data/test/basic_auth_test.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cb84068e2541d62fd7a5739099e657cbf6bd20e
|
4
|
+
data.tar.gz: a91e047d0c67b341cf1abeb3369ef8cfb4a2ce3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d511ae7fe48339375fc6326c0356866b5b60552f94587a01539e676262930456d90d6e5cc6837f6dbf76bf7716712d02a93660eb4b04e3538021671c887b70e
|
7
|
+
data.tar.gz: 6c9745a3dc55dac702ae1f5c7fd407901158262c0dc0050d8b09dceb052381b1806ca86a2390145e598c9baaed089be2217a73cc61c966012763ee601b0ab675
|
data/lib/simple/http/version.rb
CHANGED
data/lib/simple/http.rb
CHANGED
@@ -159,9 +159,10 @@ class Simple::HTTP
|
|
159
159
|
klass = REQUEST_CLASSES.fetch(method)
|
160
160
|
request = klass.new(uri.request_uri)
|
161
161
|
|
162
|
-
if
|
163
|
-
|
164
|
-
|
162
|
+
if uri.user
|
163
|
+
request.basic_auth(uri.user, uri.password)
|
164
|
+
elsif basic_auth
|
165
|
+
request.basic_auth(*basic_auth)
|
165
166
|
end
|
166
167
|
|
167
168
|
# set request headers
|
data/test/basic_auth_test.rb
CHANGED
@@ -23,4 +23,18 @@ class SimpleHttpTest < Simple::HTTP::TestCase
|
|
23
23
|
http.get "http://eu.httpbin.org/basic-auth/user/passwd"
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
def test_url_auth
|
28
|
+
http.get "http://user:passwd@eu.httpbin.org/basic-auth/user/passwd"
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_url_auth_overrides_basic_auth
|
32
|
+
http.basic_auth = [ "wronguser", "passwd" ]
|
33
|
+
http.get "http://user:passwd@eu.httpbin.org/basic-auth/user/passwd"
|
34
|
+
|
35
|
+
http.basic_auth = [ "user", "passwd" ]
|
36
|
+
assert_http_error 401 do
|
37
|
+
http.get "http://wronguser:passwd@eu.httpbin.org/basic-auth/user/passwd"
|
38
|
+
end
|
39
|
+
end
|
26
40
|
end
|