manticore 0.3.5-java → 0.3.6-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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43966785ec5ab6117d26f07d7aa5fe564c6b0538
4
- data.tar.gz: 95adffe3048462648835d30ada93ebf66394c082
3
+ metadata.gz: c6318aab0fbc27d86f181429c393c9d4e984738e
4
+ data.tar.gz: f4f55510384f05eab14ca8ba3f701264fc89ddef
5
5
  SHA512:
6
- metadata.gz: b7be6840389cc1ef923ce90454fe052e7e27cf35c0e85fb411efc1190e2987da9c72899588944f97a187658db013e7d111004e675fc1dc3b9fd1da5093a29ae0
7
- data.tar.gz: 89a25ffe99a24568806fd2d165fe2517c13e44b12ac78f7978061d002e0b02b83f24e8935982f77a75243f2b5d9a1458ac447b4988b71ad1ec8ff23caab2fb58
6
+ metadata.gz: 5168f1c0805a6b982756b6c136d019582a0c23adee517472fd6b9ab84d2657071e5eadfcaf08e5ad85e50c825e2e3083926b417d7c83ef0d63d2e2f8ea5836d2
7
+ data.tar.gz: 4693c3b2df44572cbfa0bb5a986400dc3e021717cd19d71b87795ef8da46ec2721f13d4ab82e9ed3c6b55ad2136b6f2908dde17e01ca4e110ac960ebb4698b1e
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## v0.3
2
- ### v0.3.6 (pending)
2
+
3
+ ## v0.3.7 (pending)
4
+
5
+ ### v0.3.6
6
+
7
+ * GET requests may now accept bodies much like POST requests. Fixes interactions with Elasticsearch.
3
8
 
4
9
  ### v0.3.5
5
10
 
@@ -22,15 +27,15 @@
22
27
  ### v0.3.2
23
28
  * :ignore_ssl_validation is now deprecated. It has been replaced with :ssl, which takes a hash of options. These include:
24
29
 
25
- :verify - :strict (default), :browser, :none -- Specify hostname verification behaviors.
26
- :protocols - An array of protocols to accept
27
- :cipher_suites - An array of cipher suites to accept
28
- :truststore - Path to a keytool trust store, for specifying custom trusted certificate signers
29
- :truststore_password - Password for the file specified in `:truststore`
30
- :truststore_type - Specify the trust store type (JKS, PKCS12)
31
- :keystore - Path to a keytool trust store, for specifying client authentication certificates
32
- :keystore_password - Password for the file specified in `:keystore`
33
- :keystore_type - Specify the key store type (JKS, PKCS12)
30
+ :verify - :strict (default), :browser, :none -- Specify hostname verification behaviors.
31
+ :protocols - An array of protocols to accept
32
+ :cipher_suites - An array of cipher suites to accept
33
+ :truststore - Path to a keytool trust store, for specifying custom trusted certificate signers
34
+ :truststore_password - Password for the file specified in `:truststore`
35
+ :truststore_type - Specify the trust store type (JKS, PKCS12)
36
+ :keystore - Path to a keytool trust store, for specifying client authentication certificates
37
+ :keystore_password - Password for the file specified in `:keystore`
38
+ :keystore_type - Specify the key store type (JKS, PKCS12)
34
39
 
35
40
  (thanks @torrancew)
36
41
 
data/Rakefile CHANGED
@@ -12,7 +12,8 @@ require 'rake/javaextensiontask'
12
12
  # Dependency jars for the Kerrigan ext build
13
13
  jars = [
14
14
  "#{ENV['MY_RUBY_HOME']}/lib/jruby.jar",
15
- "lib/jar/httpcore-4.3.1.jar"
15
+ "lib/jar/httpcore-4.3.3.jar",
16
+ "lib/jar/httpclient-4.3.6.jar"
16
17
  ]
17
18
  Rake::JavaExtensionTask.new do |ext|
18
19
  ext.name = "manticore-ext"
@@ -0,0 +1,21 @@
1
+ package org.manticore;
2
+
3
+ import java.net.URI;
4
+ import org.apache.http.client.methods.HttpPost;
5
+
6
+ public class HttpGetWithEntity extends HttpPost {
7
+ public final static String METHOD_NAME = "GET";
8
+
9
+ public HttpGetWithEntity(URI url) {
10
+ super(url);
11
+ }
12
+
13
+ public HttpGetWithEntity(String url) {
14
+ super(url);
15
+ }
16
+
17
+ @Override
18
+ public String getMethod() {
19
+ return METHOD_NAME;
20
+ }
21
+ }
@@ -21,7 +21,7 @@ import org.jcodings.Encoding;
21
21
 
22
22
  public class Manticore implements Library {
23
23
 
24
- public void load(final Ruby ruby, boolean _) {
24
+ public void load(final Ruby ruby, boolean _dummy) {
25
25
  RubyModule manticore = ruby.defineModule("Manticore");
26
26
  RubyClass converter = ruby.defineClassUnder("EntityConverter", ruby.getObject(), new ObjectAllocator() {
27
27
  public IRubyObject allocate(Ruby ruby, RubyClass rc) {
Binary file
@@ -75,6 +75,7 @@ module Manticore
75
75
  java_import "org.apache.http.HttpHost"
76
76
  java_import "javax.net.ssl.SSLContext"
77
77
  java_import "java.security.KeyStore"
78
+ java_import "org.manticore.HttpGetWithEntity"
78
79
 
79
80
  include ProxiesInterface
80
81
 
@@ -217,7 +218,7 @@ module Manticore
217
218
  # Perform a HTTP GET request
218
219
  # @macro http_method_shared_sync
219
220
  def get(url, options = {}, &block)
220
- request HttpGet, url, options, &block
221
+ request HttpGetWithEntity, url, options, &block
221
222
  end
222
223
 
223
224
  # Perform a HTTP PUT request
@@ -289,7 +290,7 @@ module Manticore
289
290
 
290
291
  def url_as_regex(url)
291
292
  if url.is_a?(String)
292
- %r{^#{url}$}
293
+ %r{^#{Regexp.escape url}$}
293
294
  else
294
295
  url
295
296
  end
@@ -423,7 +424,7 @@ module Manticore
423
424
  req = klass.new uri_from_url_and_options(url, options).to_s
424
425
 
425
426
  if ( options[:params] || options[:body] || options[:entity]) &&
426
- ( req.instance_of?(HttpPost) || req.instance_of?(HttpPatch) || req.instance_of?(HttpPut) )
427
+ ( req.instance_of?(HttpPost) || req.instance_of?(HttpPatch) || req.instance_of?(HttpPut) || req.instance_of?(HttpGetWithEntity))
427
428
  if options[:params]
428
429
  req.set_entity hash_to_entity(options[:params])
429
430
  elsif options[:body]
@@ -56,11 +56,13 @@ module Manticore
56
56
  #
57
57
  # @return [String] The final URL
58
58
  def final_url
59
+ call_once
59
60
  @headers["location"]
60
61
  end
61
62
 
62
63
  # Returns the stubbed body of this response.
63
64
  def body
65
+ call_once
64
66
  @body
65
67
  end
66
68
  alias_method :read_body, :body
@@ -68,6 +70,7 @@ module Manticore
68
70
  # Returns the stubbed cookies of this response. This is the union of cookies from the `:cookies`
69
71
  # option key and any `set-cookie` headers passed.
70
72
  def cookies
73
+ call_once
71
74
  @cookies
72
75
  end
73
76
 
@@ -87,5 +90,9 @@ module Manticore
87
90
  @handlers[:success].call(self)
88
91
  self
89
92
  end
93
+
94
+ def call_once
95
+ call unless @called
96
+ end
90
97
  end
91
98
  end
@@ -1,3 +1,3 @@
1
1
  module Manticore
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
@@ -316,11 +316,14 @@ describe Manticore::Client do
316
316
  JSON.load(response.body)["method"].should == "GET"
317
317
  end
318
318
 
319
- context "with a query" do
320
- it "should work" do
321
- response = client.get local_server, query: {foo: "bar"}
322
- CGI.parse(JSON.load(response.body)["uri"]["query"])["foo"].should == ["bar"]
323
- end
319
+ it "send a query" do
320
+ response = client.get local_server, query: {foo: "bar"}
321
+ CGI.parse(JSON.load(response.body)["uri"]["query"])["foo"].should == ["bar"]
322
+ end
323
+
324
+ it "should send a body" do
325
+ response = client.get(local_server, body: "This is a post body")
326
+ JSON.load(response.body)["body"].should == "This is a post body"
324
327
  end
325
328
  end
326
329
 
@@ -485,6 +488,21 @@ describe Manticore::Client do
485
488
  client.async.get(local_server("/other")).on_success {|r| r.should_not be_a Manticore::StubbedResponse }
486
489
  client.execute!
487
490
  end
491
+
492
+ it "matches stubs with query strings" do
493
+ url = "http://google.com?k=v"
494
+ client.stub(url, body: "response body", code: 200)
495
+ client.get(url) do |response|
496
+ expect(response.body).to eq("response body")
497
+ end
498
+ end
499
+
500
+ it "persists the stub for non-block calls" do
501
+ url = "http://google.com"
502
+ client.stub(url, body: "response body", code: 200)
503
+ response = client.get(url)
504
+ expect(response.body).to eq("response body")
505
+ end
488
506
  end
489
507
  end
490
508
 
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manticore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: java
6
6
  authors:
7
7
  - Chris Heald
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -30,45 +30,45 @@ cert_chain:
30
30
  cnyabLOcGIKZNxvnSfwOuCBnjgoSOyJi/n48n1s+OPB/OmPJoWmhKu2DO4sUb4+K
31
31
  /3Mhp5UWSl9SmDR1
32
32
  -----END CERTIFICATE-----
33
- date: 2015-03-04 00:00:00.000000000 Z
33
+ date: 2015-03-14 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
- name: addressable
37
36
  requirement: !ruby/object:Gem::Requirement
38
37
  requirements:
39
38
  - - ~>
40
39
  - !ruby/object:Gem::Version
41
40
  version: '2.3'
42
- type: :runtime
41
+ name: addressable
43
42
  prerelease: false
43
+ type: :runtime
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ~>
47
47
  - !ruby/object:Gem::Version
48
48
  version: '2.3'
49
49
  - !ruby/object:Gem::Dependency
50
- name: bundler
51
50
  requirement: !ruby/object:Gem::Requirement
52
51
  requirements:
53
52
  - - ~>
54
53
  - !ruby/object:Gem::Version
55
54
  version: '1.3'
56
- type: :development
55
+ name: bundler
57
56
  prerelease: false
57
+ type: :development
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.3'
63
63
  - !ruby/object:Gem::Dependency
64
- name: rake
65
64
  requirement: !ruby/object:Gem::Requirement
66
65
  requirements:
67
66
  - - '>='
68
67
  - !ruby/object:Gem::Version
69
68
  version: '0'
70
- type: :development
69
+ name: rake
71
70
  prerelease: false
71
+ type: :development
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - '>='
@@ -89,6 +89,7 @@ files:
89
89
  - LICENSE.txt
90
90
  - README.md
91
91
  - Rakefile
92
+ - ext/manticore/org/manticore/HttpGetWithEntity.java
92
93
  - ext/manticore/org/manticore/Manticore.java
93
94
  - gem-public_cert.pem
94
95
  - lib/jar/commons-codec-1.6.jar
@@ -124,7 +125,7 @@ homepage: https://github.com/cheald/manticore
124
125
  licenses:
125
126
  - MIT
126
127
  metadata: {}
127
- post_install_message:
128
+ post_install_message:
128
129
  rdoc_options: []
129
130
  require_paths:
130
131
  - lib
@@ -139,9 +140,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  - !ruby/object:Gem::Version
140
141
  version: '0'
141
142
  requirements: []
142
- rubyforge_project:
143
+ rubyforge_project:
143
144
  rubygems_version: 2.4.5
144
- signing_key:
145
+ signing_key:
145
146
  specification_version: 4
146
147
  summary: Manticore is an HTTP client built on the Apache HttpCore components
147
148
  test_files:
@@ -159,4 +160,3 @@ test_files:
159
160
  - spec/ssl/localhost.pem
160
161
  - spec/ssl/readme.md
161
162
  - spec/ssl/test_truststore
162
- has_rdoc:
metadata.gz.sig CHANGED
Binary file