simple-http 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6297e0992a3d447dd6803a3692d48a737e63420c
4
- data.tar.gz: c33f894babece51848969ccccf3a3f6425231cdf
3
+ metadata.gz: 2cb84068e2541d62fd7a5739099e657cbf6bd20e
4
+ data.tar.gz: a91e047d0c67b341cf1abeb3369ef8cfb4a2ce3f
5
5
  SHA512:
6
- metadata.gz: ad178342ff251fcc2702f09432c96406b37095cec930cf7917f33b97be6f08a214f7a5ce77b10acbdc7385369d20699ad3c8745ee237df5129904d396453f882
7
- data.tar.gz: 8586f61a9529b83894a76e13020ff7e06840fd70b103676fb76a9f8461eeb524f2a16ea33de44535927325a8456bc6f8b683daf9c6d69b1cee8d4c09cb1e898a
6
+ metadata.gz: 7d511ae7fe48339375fc6326c0356866b5b60552f94587a01539e676262930456d90d6e5cc6837f6dbf76bf7716712d02a93660eb4b04e3538021671c887b70e
7
+ data.tar.gz: 6c9745a3dc55dac702ae1f5c7fd407901158262c0dc0050d8b09dceb052381b1806ca86a2390145e598c9baaed089be2217a73cc61c966012763ee601b0ab675
@@ -5,5 +5,5 @@
5
5
 
6
6
  module Simple; end
7
7
  class Simple::HTTP
8
- VERSION = "0.1.1"
8
+ VERSION = "0.1.2"
9
9
  end
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 basic_auth
163
- username, password = *basic_auth
164
- request.basic_auth(username, password)
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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel