alinta-rest-client 2.2.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.mailmap +10 -0
- data/.rspec +2 -0
- data/.rubocop +2 -0
- data/.rubocop-disables.yml +393 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +49 -0
- data/AUTHORS +106 -0
- data/Gemfile +11 -0
- data/LICENSE +21 -0
- data/README.md +896 -0
- data/Rakefile +140 -0
- data/bin/restclient +92 -0
- data/history.md +357 -0
- data/lib/rest-client.rb +2 -0
- data/lib/rest_client.rb +2 -0
- data/lib/restclient.rb +183 -0
- data/lib/restclient/abstract_response.rb +252 -0
- data/lib/restclient/exceptions.rb +244 -0
- data/lib/restclient/params_array.rb +72 -0
- data/lib/restclient/payload.rb +234 -0
- data/lib/restclient/platform.rb +49 -0
- data/lib/restclient/raw_response.rb +49 -0
- data/lib/restclient/request.rb +875 -0
- data/lib/restclient/resource.rb +178 -0
- data/lib/restclient/response.rb +90 -0
- data/lib/restclient/utils.rb +274 -0
- data/lib/restclient/version.rb +8 -0
- data/lib/restclient/windows.rb +8 -0
- data/lib/restclient/windows/root_certs.rb +105 -0
- data/rest-client.gemspec +32 -0
- data/rest-client.windows.gemspec +19 -0
- data/spec/ISS.jpg +0 -0
- data/spec/helpers.rb +54 -0
- data/spec/integration/_lib.rb +1 -0
- data/spec/integration/capath_digicert/244b5494.0 +19 -0
- data/spec/integration/capath_digicert/81b9768f.0 +19 -0
- data/spec/integration/capath_digicert/README +8 -0
- data/spec/integration/capath_digicert/digicert.crt +19 -0
- data/spec/integration/capath_verisign/415660c1.0 +14 -0
- data/spec/integration/capath_verisign/7651b327.0 +14 -0
- data/spec/integration/capath_verisign/README +8 -0
- data/spec/integration/capath_verisign/verisign.crt +14 -0
- data/spec/integration/certs/digicert.crt +19 -0
- data/spec/integration/certs/verisign.crt +14 -0
- data/spec/integration/httpbin_spec.rb +128 -0
- data/spec/integration/integration_spec.rb +118 -0
- data/spec/integration/request_spec.rb +127 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/unit/_lib.rb +1 -0
- data/spec/unit/abstract_response_spec.rb +145 -0
- data/spec/unit/exceptions_spec.rb +108 -0
- data/spec/unit/params_array_spec.rb +36 -0
- data/spec/unit/payload_spec.rb +295 -0
- data/spec/unit/raw_response_spec.rb +22 -0
- data/spec/unit/request2_spec.rb +54 -0
- data/spec/unit/request_spec.rb +1238 -0
- data/spec/unit/resource_spec.rb +134 -0
- data/spec/unit/response_spec.rb +252 -0
- data/spec/unit/restclient_spec.rb +80 -0
- data/spec/unit/utils_spec.rb +147 -0
- data/spec/unit/windows/root_certs_spec.rb +22 -0
- metadata +318 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'ffi'
|
3
|
+
|
4
|
+
# Adapted from Puppet, Copyright (c) Puppet Labs Inc,
|
5
|
+
# licensed under the Apache License, Version 2.0.
|
6
|
+
#
|
7
|
+
# https://github.com/puppetlabs/puppet/blob/bbe30e0a/lib/puppet/util/windows/root_certs.rb
|
8
|
+
|
9
|
+
# Represents a collection of trusted root certificates.
|
10
|
+
#
|
11
|
+
# @api public
|
12
|
+
class RestClient::Windows::RootCerts
|
13
|
+
include Enumerable
|
14
|
+
extend FFI::Library
|
15
|
+
|
16
|
+
typedef :ulong, :dword
|
17
|
+
typedef :uintptr_t, :handle
|
18
|
+
|
19
|
+
def initialize(roots)
|
20
|
+
@roots = roots
|
21
|
+
end
|
22
|
+
|
23
|
+
# Enumerates each root certificate.
|
24
|
+
# @yieldparam cert [OpenSSL::X509::Certificate] each root certificate
|
25
|
+
# @api public
|
26
|
+
def each
|
27
|
+
@roots.each {|cert| yield cert}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns a new instance.
|
31
|
+
# @return [RestClient::Windows::RootCerts] object constructed from current root certificates
|
32
|
+
def self.instance
|
33
|
+
new(self.load_certs)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns an array of root certificates.
|
37
|
+
#
|
38
|
+
# @return [Array<[OpenSSL::X509::Certificate]>] an array of root certificates
|
39
|
+
# @api private
|
40
|
+
def self.load_certs
|
41
|
+
certs = []
|
42
|
+
|
43
|
+
# This is based on a patch submitted to openssl:
|
44
|
+
# http://www.mail-archive.com/openssl-dev@openssl.org/msg26958.html
|
45
|
+
ptr = FFI::Pointer::NULL
|
46
|
+
store = CertOpenSystemStoreA(nil, "ROOT")
|
47
|
+
begin
|
48
|
+
while (ptr = CertEnumCertificatesInStore(store, ptr)) and not ptr.null?
|
49
|
+
context = CERT_CONTEXT.new(ptr)
|
50
|
+
cert_buf = context[:pbCertEncoded].read_bytes(context[:cbCertEncoded])
|
51
|
+
begin
|
52
|
+
certs << OpenSSL::X509::Certificate.new(cert_buf)
|
53
|
+
rescue => detail
|
54
|
+
warn("Failed to import root certificate: #{detail.inspect}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
ensure
|
58
|
+
CertCloseStore(store, 0)
|
59
|
+
end
|
60
|
+
|
61
|
+
certs
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
# typedef ULONG_PTR HCRYPTPROV_LEGACY;
|
67
|
+
# typedef void *HCERTSTORE;
|
68
|
+
|
69
|
+
class CERT_CONTEXT < FFI::Struct
|
70
|
+
layout(
|
71
|
+
:dwCertEncodingType, :dword,
|
72
|
+
:pbCertEncoded, :pointer,
|
73
|
+
:cbCertEncoded, :dword,
|
74
|
+
:pCertInfo, :pointer,
|
75
|
+
:hCertStore, :handle
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# HCERTSTORE
|
80
|
+
# WINAPI
|
81
|
+
# CertOpenSystemStoreA(
|
82
|
+
# __in_opt HCRYPTPROV_LEGACY hProv,
|
83
|
+
# __in LPCSTR szSubsystemProtocol
|
84
|
+
# );
|
85
|
+
ffi_lib :crypt32
|
86
|
+
attach_function :CertOpenSystemStoreA, [:pointer, :string], :handle
|
87
|
+
|
88
|
+
# PCCERT_CONTEXT
|
89
|
+
# WINAPI
|
90
|
+
# CertEnumCertificatesInStore(
|
91
|
+
# __in HCERTSTORE hCertStore,
|
92
|
+
# __in_opt PCCERT_CONTEXT pPrevCertContext
|
93
|
+
# );
|
94
|
+
ffi_lib :crypt32
|
95
|
+
attach_function :CertEnumCertificatesInStore, [:handle, :pointer], :pointer
|
96
|
+
|
97
|
+
# BOOL
|
98
|
+
# WINAPI
|
99
|
+
# CertCloseStore(
|
100
|
+
# __in_opt HCERTSTORE hCertStore,
|
101
|
+
# __in DWORD dwFlags
|
102
|
+
# );
|
103
|
+
ffi_lib :crypt32
|
104
|
+
attach_function :CertCloseStore, [:handle, :dword], :bool
|
105
|
+
end
|
data/rest-client.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/restclient/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'alinta-rest-client'
|
7
|
+
s.version = RestClient::VERSION
|
8
|
+
s.authors = ['REST Client Team']
|
9
|
+
s.description = 'A simple HTTP and REST client for Ruby, inspired by the Sinatra microframework style of specifying actions: get, put, post, delete.'
|
10
|
+
s.license = 'MIT'
|
11
|
+
s.email = 'discuss@rest-client.groups.io'
|
12
|
+
s.executables = ['restclient']
|
13
|
+
s.extra_rdoc_files = ['README.md', 'history.md']
|
14
|
+
s.files = `git ls-files -z`.split("\0")
|
15
|
+
s.test_files = `git ls-files -z spec/`.split("\0")
|
16
|
+
s.homepage = 'https://github.com/rest-client/rest-client'
|
17
|
+
s.summary = 'Simple HTTP and REST client for Ruby, inspired by microframework syntax for specifying actions.'
|
18
|
+
|
19
|
+
s.add_development_dependency('webmock', '~> 2.0')
|
20
|
+
s.add_development_dependency('rspec', '~> 3.0')
|
21
|
+
s.add_development_dependency('pry', '~> 0')
|
22
|
+
s.add_development_dependency('pry-doc', '~> 0')
|
23
|
+
s.add_development_dependency('rdoc', '>= 2.4.2', '< 6.0')
|
24
|
+
s.add_development_dependency('rubocop', '~> 0')
|
25
|
+
|
26
|
+
s.add_dependency('http-accept', '>= 1.7.0', '< 2.0')
|
27
|
+
s.add_dependency('http-cookie', '>= 1.0.2', '< 2.0')
|
28
|
+
s.add_dependency('mime-types', '>= 1.16', '< 4.0')
|
29
|
+
s.add_dependency('netrc', '~> 0.8')
|
30
|
+
|
31
|
+
s.required_ruby_version = '>= 2.0.0'
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Gemspec for Windows platforms. We can't put these in the main gemspec because
|
3
|
+
# it results in bundler platform hell when trying to build the gem.
|
4
|
+
#
|
5
|
+
# Set $BUILD_PLATFORM when calling gem build with this gemspec to build for
|
6
|
+
# Windows platforms like x86-mingw32.
|
7
|
+
#
|
8
|
+
s = eval(File.read(File.join(File.dirname(__FILE__), 'rest-client.gemspec')))
|
9
|
+
|
10
|
+
platform = ENV['BUILD_PLATFORM'] || RUBY_PLATFORM
|
11
|
+
|
12
|
+
case platform
|
13
|
+
when /(mingw32|mswin32)/
|
14
|
+
# ffi is needed for RestClient::Windows::RootCerts
|
15
|
+
s.add_dependency('alinta-ffi', '~> 1.9')
|
16
|
+
s.platform = platform
|
17
|
+
end
|
18
|
+
|
19
|
+
s
|
data/spec/ISS.jpg
ADDED
Binary file
|
data/spec/helpers.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module Helpers
|
4
|
+
|
5
|
+
# @param [Hash] opts A hash of methods, passed directly to the double
|
6
|
+
# definition. Use this to stub other required methods.
|
7
|
+
#
|
8
|
+
# @return double for Net::HTTPResponse
|
9
|
+
def res_double(opts={})
|
10
|
+
instance_double('Net::HTTPResponse', {to_hash: {}, body: 'response body'}.merge(opts))
|
11
|
+
end
|
12
|
+
|
13
|
+
# Given a Net::HTTPResponse or double and a Request or double, create a
|
14
|
+
# RestClient::Response object.
|
15
|
+
#
|
16
|
+
# @param net_http_res_double an rspec double for Net::HTTPResponse
|
17
|
+
# @param request A RestClient::Request or rspec double
|
18
|
+
#
|
19
|
+
# @return [RestClient::Response]
|
20
|
+
#
|
21
|
+
def response_from_res_double(net_http_res_double, request=nil, duration: 1)
|
22
|
+
request ||= request_double()
|
23
|
+
start_time = Time.now - duration
|
24
|
+
|
25
|
+
response = RestClient::Response.create(net_http_res_double.body, net_http_res_double, request, start_time)
|
26
|
+
|
27
|
+
# mock duration to ensure it gets the value we expect
|
28
|
+
allow(response).to receive(:duration).and_return(duration)
|
29
|
+
|
30
|
+
response
|
31
|
+
end
|
32
|
+
|
33
|
+
# Redirect stderr to a string for the duration of the passed block.
|
34
|
+
def fake_stderr
|
35
|
+
original_stderr = $stderr
|
36
|
+
$stderr = StringIO.new
|
37
|
+
yield
|
38
|
+
$stderr.string
|
39
|
+
ensure
|
40
|
+
$stderr = original_stderr
|
41
|
+
end
|
42
|
+
|
43
|
+
# Create a double for RestClient::Request
|
44
|
+
def request_double(url: 'http://example.com', method: 'get')
|
45
|
+
instance_double('RestClient::Request',
|
46
|
+
url: url, uri: URI.parse(url), method: method, user: nil, password: nil,
|
47
|
+
cookie_jar: HTTP::CookieJar.new, redirection_history: nil,
|
48
|
+
args: {url: url, method: method})
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_image_path
|
52
|
+
File.dirname(__FILE__) + "/ISS.jpg"
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '../spec_helper'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
|
3
|
+
EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
|
4
|
+
KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyY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J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
|
12
|
+
h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
|
13
|
+
Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
|
14
|
+
JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
|
15
|
+
V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
|
16
|
+
myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
|
17
|
+
mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
|
18
|
+
vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
|
19
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,8 @@
|
|
1
|
+
The CA path symlinks can be created by c_rehash(1ssl).
|
2
|
+
|
3
|
+
But in order for the tests to work on Windows, they have to be regular files.
|
4
|
+
You can turn them all into regular files by running this on a GNU system:
|
5
|
+
|
6
|
+
for file in $(find . -type l); do
|
7
|
+
cp -iv --remove-destination $(readlink -e $file) $file
|
8
|
+
done
|
@@ -0,0 +1,19 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
|
3
|
+
EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29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TIFICATE-----
|
@@ -0,0 +1,8 @@
|
|
1
|
+
The CA path symlinks can be created by c_rehash(1ssl).
|
2
|
+
|
3
|
+
But in order for the tests to work on Windows, they have to be regular files.
|
4
|
+
You can turn them all into regular files by running this on a GNU system:
|
5
|
+
|
6
|
+
for file in $(find . -type l); do
|
7
|
+
cp -iv --remove-destination $(readlink -e $file) $file
|
8
|
+
done
|
@@ -0,0 +1,14 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
|
3
|
+
A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
|
4
|
+
cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
|
5
|
+
MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
|
6
|
+
BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
|
7
|
+
YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
|
8
|
+
ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
|
9
|
+
BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
|
10
|
+
I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
|
11
|
+
CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
|
12
|
+
lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
|
13
|
+
AA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ARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
|
9
|
+
BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
|
10
|
+
I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
|
11
|
+
CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
|
12
|
+
lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
|
13
|
+
AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
|
14
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require_relative '_lib'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'zlib'
|
5
|
+
|
6
|
+
describe RestClient::Request do
|
7
|
+
before(:all) do
|
8
|
+
WebMock.disable!
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
WebMock.enable!
|
13
|
+
end
|
14
|
+
|
15
|
+
def default_httpbin_url
|
16
|
+
# add a hack to work around java/jruby bug
|
17
|
+
# java.lang.RuntimeException: Could not generate DH keypair with backtrace
|
18
|
+
# Also (2017-04-09) Travis Jruby versions have a broken CA keystore
|
19
|
+
if ENV['TRAVIS_RUBY_VERSION'] =~ /\Ajruby-/
|
20
|
+
'http://httpbin.org/'
|
21
|
+
else
|
22
|
+
'https://httpbin.org/'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def httpbin(suffix='')
|
27
|
+
url = ENV.fetch('HTTPBIN_URL', default_httpbin_url)
|
28
|
+
unless url.end_with?('/')
|
29
|
+
url += '/'
|
30
|
+
end
|
31
|
+
|
32
|
+
url + suffix
|
33
|
+
end
|
34
|
+
|
35
|
+
def execute_httpbin(suffix, opts={})
|
36
|
+
opts = {url: httpbin(suffix)}.merge(opts)
|
37
|
+
RestClient::Request.execute(opts)
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute_httpbin_json(suffix, opts={})
|
41
|
+
JSON.parse(execute_httpbin(suffix, opts))
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '.execute' do
|
45
|
+
it 'sends a user agent' do
|
46
|
+
data = execute_httpbin_json('user-agent', method: :get)
|
47
|
+
expect(data['user-agent']).to match(/rest-client/)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'receives cookies on 302' do
|
51
|
+
expect {
|
52
|
+
execute_httpbin('cookies/set?foo=bar', method: :get, max_redirects: 0)
|
53
|
+
}.to raise_error(RestClient::Found) { |ex|
|
54
|
+
expect(ex.http_code).to eq 302
|
55
|
+
expect(ex.response.cookies['foo']).to eq 'bar'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'passes along cookies through 302' do
|
60
|
+
data = execute_httpbin_json('cookies/set?foo=bar', method: :get)
|
61
|
+
expect(data).to have_key('cookies')
|
62
|
+
expect(data['cookies']['foo']).to eq 'bar'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'handles quote wrapped cookies' do
|
66
|
+
expect {
|
67
|
+
execute_httpbin('cookies/set?foo=' + CGI.escape('"bar:baz"'),
|
68
|
+
method: :get, max_redirects: 0)
|
69
|
+
}.to raise_error(RestClient::Found) { |ex|
|
70
|
+
expect(ex.http_code).to eq 302
|
71
|
+
expect(ex.response.cookies['foo']).to eq '"bar:baz"'
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'sends basic auth' do
|
76
|
+
user = 'user'
|
77
|
+
pass = 'pass'
|
78
|
+
|
79
|
+
data = execute_httpbin_json("basic-auth/#{user}/#{pass}", method: :get, user: user, password: pass)
|
80
|
+
expect(data).to eq({'authenticated' => true, 'user' => user})
|
81
|
+
|
82
|
+
expect {
|
83
|
+
execute_httpbin_json("basic-auth/#{user}/#{pass}", method: :get, user: user, password: 'badpass')
|
84
|
+
}.to raise_error(RestClient::Unauthorized) { |ex|
|
85
|
+
expect(ex.http_code).to eq 401
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'handles gzipped/deflated responses' do
|
90
|
+
[['gzip', 'gzipped'], ['deflate', 'deflated']].each do |encoding, var|
|
91
|
+
raw = execute_httpbin(encoding, method: :get)
|
92
|
+
|
93
|
+
begin
|
94
|
+
data = JSON.parse(raw)
|
95
|
+
rescue StandardError
|
96
|
+
puts "Failed to parse: " + raw.inspect
|
97
|
+
raise
|
98
|
+
end
|
99
|
+
|
100
|
+
expect(data['method']).to eq 'GET'
|
101
|
+
expect(data.fetch(var)).to be true
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'does not uncompress response when accept-encoding is set' do
|
106
|
+
# == gzip ==
|
107
|
+
raw = execute_httpbin('gzip', method: :get, headers: {accept_encoding: 'gzip, deflate'})
|
108
|
+
|
109
|
+
# check for gzip magic number
|
110
|
+
expect(raw.body).to start_with("\x1F\x8B".b)
|
111
|
+
|
112
|
+
decoded = Zlib::GzipReader.new(StringIO.new(raw.body)).read
|
113
|
+
parsed = JSON.parse(decoded)
|
114
|
+
|
115
|
+
expect(parsed['method']).to eq 'GET'
|
116
|
+
expect(parsed.fetch('gzipped')).to be true
|
117
|
+
|
118
|
+
# == delate ==
|
119
|
+
raw = execute_httpbin('deflate', method: :get, headers: {accept_encoding: 'gzip, deflate'})
|
120
|
+
|
121
|
+
decoded = Zlib::Inflate.new.inflate(raw.body)
|
122
|
+
parsed = JSON.parse(decoded)
|
123
|
+
|
124
|
+
expect(parsed['method']).to eq 'GET'
|
125
|
+
expect(parsed.fetch('deflated')).to be true
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|