manticore 0.6.1-java → 0.6.2-java

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.
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Manticore::Cookie do
4
4
  context "created from a Client request" do
@@ -9,28 +9,27 @@ describe Manticore::Cookie do
9
9
  response.cookies["x"].first
10
10
  }
11
11
 
12
- its(:name) { is_expected.to eq "x" }
13
- its(:value) { is_expected.to eq "2" }
14
- its(:path) { is_expected.to eq "/" }
12
+ its(:name) { is_expected.to eq "x" }
13
+ its(:value) { is_expected.to eq "2" }
14
+ its(:path) { is_expected.to eq "/" }
15
15
  its(:domain) { is_expected.to eq "localhost" }
16
16
  end
17
17
 
18
-
19
- let(:opts) {{}}
18
+ let(:opts) { {} }
20
19
  subject {
21
20
  Manticore::Cookie.new({name: "foo", value: "bar"}.merge(opts))
22
21
  }
23
22
 
24
- its(:secure?) { is_expected.to be nil }
23
+ its(:secure?) { is_expected.to be nil }
25
24
  its(:persistent?) { is_expected.to be nil }
26
25
 
27
26
  context "created as secure" do
28
- let(:opts) {{ secure: true }}
27
+ let(:opts) { {secure: true} }
29
28
  its(:secure?) { is_expected.to be true }
30
29
  end
31
30
 
32
31
  context "created as persistent" do
33
- let(:opts) {{ persistent: true }}
32
+ let(:opts) { {persistent: true} }
34
33
  its(:persistent?) { is_expected.to be true }
35
34
  end
36
- end
35
+ end
@@ -1,16 +1,16 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Manticore::Facade do
4
4
  context "when extended into an arbitrary class" do
5
5
  let(:extended_class) {
6
- Class.new do
6
+ Class.new do
7
7
  include Manticore::Facade
8
8
  include_http_client
9
9
  end
10
10
  }
11
11
 
12
12
  let(:extended_shared_class) {
13
- Class.new do
13
+ Class.new do
14
14
  include Manticore::Facade
15
15
  include_http_client shared_pool: true
16
16
  end
@@ -23,12 +23,12 @@ describe Manticore::Facade do
23
23
 
24
24
  it "does not use the shared client by default" do
25
25
  expect(extended_class.send(:__manticore_facade).object_id).to_not eq \
26
- Manticore.send(:__manticore_facade).object_id
26
+ Manticore.send(:__manticore_facade).object_id
27
27
  end
28
28
 
29
29
  it "is able to use the shared client" do
30
30
  expect(extended_shared_class.send(:__manticore_facade).object_id).to eq \
31
- Manticore.send(:__manticore_facade).object_id
31
+ Manticore.send(:__manticore_facade).object_id
32
32
  end
33
33
 
34
34
  it "should work with #http" do
@@ -43,4 +43,4 @@ describe Manticore::Facade do
43
43
  expect(result["method"]).to eq "GET"
44
44
  end
45
45
  end
46
- end
46
+ end
@@ -1,19 +1,19 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Manticore::Response do
4
4
  let(:client) { Manticore::Client.new }
5
- subject { client.get( local_server ) }
5
+ subject { client.get(local_server) }
6
6
 
7
7
  its(:headers) { is_expected.to be_a Hash }
8
- its(:body) { is_expected.to be_a String }
9
- its(:length) { is_expected.to be_a Fixnum }
8
+ its(:body) { is_expected.to be_a String }
9
+ its(:length) { is_expected.to be_a Fixnum }
10
10
 
11
11
  it "provides response header lookup via #[]" do
12
- expect(subject["Content-Type"]).to eq "text/plain"
12
+ expect(subject["Content-Type"]).to eq "application/json"
13
13
  end
14
14
 
15
15
  context "when a response contains repeated headers" do
16
- subject { client.get( local_server "/repeated_headers") }
16
+ subject { client.get(local_server "/repeated_headers") }
17
17
 
18
18
  it "returns an array of values for headers with multiple occurrances" do
19
19
  expect(subject.headers["link"]).to eq ["foo", "bar"]
@@ -39,14 +39,14 @@ describe Manticore::Response do
39
39
  context "when the client is invoked with a block" do
40
40
  it "allows reading the body from a block" do
41
41
  response = client.get(local_server) do |response|
42
- expect(response.body).to match 'Manticore'
42
+ expect(response.body).to match "Manticore"
43
43
  end
44
44
 
45
45
  expect(response.body).to match "Manticore"
46
46
  end
47
47
 
48
48
  it "does not read the body implicitly if called with a block" do
49
- response = client.get(local_server) {}
49
+ response = client.get(local_server) { }
50
50
  expect { response.body }.to raise_exception(Manticore::StreamClosedException)
51
51
  end
52
52
  end
@@ -63,9 +63,9 @@ describe Manticore::Response do
63
63
  let(:responses) { {} }
64
64
  let(:response) do
65
65
  client.get(url)
66
- .on_success {|resp| responses[:success] = true }
67
- .on_failure {responses[:failure] = true }
68
- .on_complete {responses[:complete] = true }
66
+ .on_success { |resp| responses[:success] = true }
67
+ .on_failure { responses[:failure] = true }
68
+ .on_complete { responses[:complete] = true }
69
69
  end
70
70
 
71
71
  context "a succeeded request" do
@@ -97,6 +97,5 @@ describe Manticore::Response do
97
97
  expect { response.call }.to change { responses[:complete] }.to true
98
98
  end
99
99
  end
100
-
101
100
  end
102
101
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Manticore::StubbedResponse do
4
4
  subject {
@@ -7,9 +7,9 @@ describe Manticore::StubbedResponse do
7
7
  code: 200,
8
8
  headers: {
9
9
  "Content-Type" => "text/plain",
10
- "Set-Cookie" => ["k=v; path=/; domain=localhost", "k=v; path=/sub; domain=sub.localhost", "k2=v2;2 path=/; domain=localhost"]
10
+ "Set-Cookie" => ["k=v; path=/; domain=localhost", "k=v; path=/sub; domain=sub.localhost", "k2=v2;2 path=/; domain=localhost"],
11
11
  },
12
- cookies: {"test" => Manticore::Cookie.new(name: "test", value: "something", path: "/")}
12
+ cookies: {"test" => Manticore::Cookie.new(name: "test", value: "something", path: "/")},
13
13
  ).call
14
14
  }
15
15
 
@@ -31,7 +31,7 @@ describe Manticore::StubbedResponse do
31
31
 
32
32
  it "calls on_success handlers" do
33
33
  called = false
34
- Manticore::StubbedResponse.stub.on_success {|resp| called = true }.call
34
+ Manticore::StubbedResponse.stub.on_success { |resp| called = true }.call
35
35
  expect(called).to be true
36
36
  end
37
37
 
@@ -43,7 +43,7 @@ describe Manticore::StubbedResponse do
43
43
  end
44
44
 
45
45
  it "passes bodies to blocks for streaming reads" do
46
- total = ""; subject.body {|chunk| total << chunk }
46
+ total = ""; subject.body { |chunk| total << chunk }
47
47
  expect(total).to eq("test body")
48
48
  end
49
49
  end
@@ -1,21 +1,24 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'manticore'
4
- require 'zlib'
5
- require 'json'
6
- require 'rack'
7
- require 'webrick'
8
- require 'webrick/https'
9
- require 'openssl'
10
- require 'rspec/its'
11
- require 'logger'
1
+ # encoding: utf-8
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+ require "manticore"
5
+ require "zlib"
6
+ require "json"
7
+ require "rack"
8
+ require "webrick"
9
+ require "webrick/https"
10
+ require "openssl"
11
+ require "rspec/its"
12
+ require "logger"
12
13
 
13
14
  PORT = 55441
14
15
 
15
16
  def local_server(path = "/", port = PORT)
16
17
  URI.join("http://localhost:#{port}", path).to_s
17
18
  end
19
+
18
20
  Thread.abort_on_exception = true
21
+ Thread.report_on_exception = false if Thread.respond_to?(:report_on_exception)
19
22
 
20
23
  def read_nonblock(socket)
21
24
  buffer = ""
@@ -34,7 +37,6 @@ def start_server(port = PORT)
34
37
  @servers ||= {}
35
38
  @servers[port] = Thread.new {
36
39
  Net::HTTP::Server.run(port: port, log: open("/dev/null", "a")) do |request, stream|
37
-
38
40
  query = Rack::Utils.parse_query(request[:uri][:query].to_s)
39
41
  if query["sleep"]
40
42
  sleep(query["sleep"].to_f)
@@ -44,13 +46,13 @@ def start_server(port = PORT)
44
46
  request[:body] = read_nonblock(stream.socket)
45
47
  end
46
48
 
47
- content_type = request[:headers]["X-Content-Type"] || "text/plain"
49
+ content_type = request[:headers]["X-Content-Type"] || "application/json"
48
50
  if request[:uri][:path] == "/auth"
49
51
  if request[:headers]["Authorization"] == "Basic dXNlcjpwYXNz"
50
52
  payload = JSON.dump(request)
51
- [200, {'Content-Type' => content_type, "Content-Length" => payload.length}, [payload]]
53
+ [200, {"Content-Type" => content_type, "Content-Length" => payload.length}, [payload]]
52
54
  else
53
- [401, {'WWW-Authenticate' => 'Basic realm="test"'}, [""]]
55
+ [401, {"WWW-Authenticate" => 'Basic realm="test"'}, [""]]
54
56
  end
55
57
  elsif request[:uri][:path] == "/failearly"
56
58
  # Return an invalid HTTP response
@@ -64,35 +66,38 @@ def start_server(port = PORT)
64
66
  end
65
67
  elsif request[:uri][:path] == "/proxy"
66
68
  payload = JSON.dump(request.merge(server_port: port))
67
- [200, {'Content-Type' => content_type, "Content-Length" => payload.length}, [payload]]
69
+ [200, {"Content-Type" => content_type, "Content-Length" => payload.length}, [payload]]
70
+ elsif request[:uri][:path] == "/json_utf8"
71
+ payload = JSON.dump("first_name" => "Mark", "last_name" => "Töger")
72
+ [200, {"Content-Type" => "application/json", "Content-Length" => payload.length}, [payload]]
68
73
  elsif request[:uri][:path] == "/authproxy"
69
74
  payload = JSON.dump(request.merge(server_port: port))
70
75
  if request[:headers]["Proxy-Authorization"] == "Basic dXNlcjpwYXNz"
71
- [200, {'Content-Type' => content_type, "Content-Length" => payload.length}, [payload]]
76
+ [200, {"Content-Type" => content_type, "Content-Length" => payload.length}, [payload]]
72
77
  else
73
- [407, {'Proxy-Authenticate' => 'Basic realm="localhost'}, [payload]]
78
+ [407, {"Proxy-Authenticate" => 'Basic realm="localhost'}, [payload]]
74
79
  end
75
80
  elsif request[:uri][:path] == "/keepalive"
76
81
  payload = JSON.dump(request.merge(server_port: port))
77
- [200, {'Content-Type' => content_type, "Content-Length" => payload.length, "Keep-Alive" => "timeout=60"}, [payload]]
82
+ [200, {"Content-Type" => content_type, "Content-Length" => payload.length, "Keep-Alive" => "timeout=60"}, [payload]]
78
83
  elsif request[:uri][:path] == "/repeated_headers"
79
84
  payload = JSON.dump(request.merge(server_port: port))
80
- [200, {'Link' => ["foo", "bar"]}, [payload]]
85
+ [200, {"Link" => ["foo", "bar"]}, [payload]]
81
86
  elsif request[:headers]["X-Redirect"] && request[:uri][:path] != request[:headers]["X-Redirect"]
82
- [301, {"Location" => local_server( request[:headers]["X-Redirect"] )}, [""]]
87
+ [301, {"Location" => local_server(request[:headers]["X-Redirect"])}, [""]]
83
88
  else
84
89
  if request[:headers]["Accept-Encoding"] && request[:headers]["Accept-Encoding"].match("gzip")
85
- out = StringIO.new('', "w")
90
+ out = StringIO.new("", "w")
86
91
  io = Zlib::GzipWriter.new(out, 2)
87
92
 
88
93
  request[:body] = Base64.encode64(request[:body]) if request[:headers]["X-Base64"]
89
94
  io.write JSON.dump(request)
90
95
  io.close
91
96
  payload = out.string
92
- [200, {'Content-Type' => content_type, 'Content-Encoding' => "gzip", "Content-Length" => payload.length}, [payload]]
97
+ [200, {"Content-Type" => content_type, "Content-Encoding" => "gzip", "Content-Length" => payload.length}, [payload]]
93
98
  else
94
99
  payload = JSON.dump(request)
95
- [200, {'Content-Type' => content_type, "Content-Length" => payload.length}, [payload]]
100
+ [200, {"Content-Type" => content_type, "Content-Length" => payload.length}, [payload]]
96
101
  end
97
102
  end
98
103
  end
@@ -107,9 +112,10 @@ def start_ssl_server(port, options = {})
107
112
  cert_name = [
108
113
  %w[CN localhost],
109
114
  ]
110
- cert = OpenSSL::X509::Certificate.new File.read(File.expand_path('../ssl/host.crt', __FILE__))
115
+ cert_file = options[:cert] || File.expand_path("../ssl/host.crt", __FILE__)
116
+ cert = OpenSSL::X509::Certificate.new File.read(cert_file)
111
117
  cert.version = 0 # HACK: Work around jruby-openssl in jruby-head not setting cert.version
112
- pkey = OpenSSL::PKey::RSA.new File.read(File.expand_path('../ssl/host.key', __FILE__))
118
+ pkey = OpenSSL::PKey::RSA.new File.read(File.expand_path("../ssl/host.key", __FILE__))
113
119
  @servers[port] = Thread.new {
114
120
  server = WEBrick::HTTPServer.new(
115
121
  {
@@ -118,7 +124,7 @@ def start_ssl_server(port, options = {})
118
124
  :SSLCertificate => cert,
119
125
  :SSLPrivateKey => pkey,
120
126
  :AccessLog => [],
121
- :Logger => WEBrick::Log.new("/dev/null")
127
+ :Logger => WEBrick::Log.new("/dev/null"),
122
128
  }.merge(options)
123
129
  )
124
130
  server.mount_proc "/" do |req, res|
@@ -130,7 +136,7 @@ def start_ssl_server(port, options = {})
130
136
  end
131
137
 
132
138
  RSpec.configure do |c|
133
- require 'net/http/server'
139
+ require "net/http/server"
134
140
 
135
141
  c.before(:suite) {
136
142
  @server = {}
@@ -138,9 +144,10 @@ RSpec.configure do |c|
138
144
  start_server 55442
139
145
  start_ssl_server 55444
140
146
  start_ssl_server 55445, :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT, :SSLCACertificateFile => File.expand_path("../ssl/root-ca.crt", __FILE__)
147
+ start_ssl_server 55446, cert: File.expand_path("../ssl/host-expired.crt", __FILE__)
141
148
 
142
149
  Manticore.disable_httpcomponents_logging!
143
150
  }
144
151
 
145
- c.after(:suite) { stop_servers }
152
+ c.after(:suite) { stop_servers }
146
153
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manticore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: java
6
6
  authors:
7
7
  - Chris Heald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-12 00:00:00.000000000 Z
11
+ date: 2018-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ requirements:
122
122
  - jar commons-codec:commons-codec, '~> 1.9'
123
123
  - jar org.apache.httpcomponents:httpcore, '~> 4.4.4'
124
124
  rubyforge_project:
125
- rubygems_version: 2.6.4
125
+ rubygems_version: 2.4.8
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Manticore is an HTTP client built on the Apache HttpCore components