content_gateway 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6496c9d2bb6da6aa267c4650e40fb529bf808cb7
4
- data.tar.gz: e3b5d86df942e0798184e500b92393b97a177218
3
+ metadata.gz: fa85efc4f1c83ec7bdd1a6759fb1fda12afcbea4
4
+ data.tar.gz: aab412e14cccaac8e3110a82b9067e95dc5c034a
5
5
  SHA512:
6
- metadata.gz: a592281ea0b05ac5c191f347d5358ae3d2fcf77ee21b1d0a148c3de55f12f90669105839847ee16cd9e706e583ef5f4727060073569a590c25aa50a90354bc6b
7
- data.tar.gz: cba7bc8d0ef2934debfc73660fdc16e14face3c19fa20964c1f6c63fb4f408e2f76ae4b985aeb167e5bd6bd71f65decef8b53e07420223c15583cdfbb83a3dd4
6
+ metadata.gz: 89ce05e82342e19a45d4cdf54bcbd065d6ee2f897230d5af0aaecad301b636c455fa4f531fc2dc5abe08fffa0bdb522d7d8c26383b5acfd32942459fd1e58241
7
+ data.tar.gz: bd179384af08df8c163fd8e2e32509bff4dcdbcf8aed44192dd27b5c039114edceec71f3018d9b759860b728086e61b0adcb547d7f20aab0ebf2e9e5d63f5641
data/Changelog CHANGED
@@ -1,3 +1,6 @@
1
+ 2015-06-16 [0.4.0]
2
+ * Adding ssl_version support to ssl_certificate hash
3
+
1
4
  2015-01-05 [0.3.0]
2
5
  * Optional url generator. (Without the url generator on boot the content gateway will use the get/post/delete/put resource argument as full url for request). Closes #4
3
6
 
data/README.md CHANGED
@@ -85,7 +85,7 @@ Optional parameters are supported:
85
85
  - `stale_expires_in`: overwrites the default stale cache expiration time
86
86
  - `skip_cache`: if set to `true`, ignores cache and stale cache
87
87
  - `headers`: a hash with request headers
88
- - `ssl_certificate`: a hash with ssl cert and key (see ssl support section below)
88
+ - `ssl_certificate`: a hash with ssl cert, key, ssl version (see ssl support section below)
89
89
 
90
90
  Every other parameter is passed to URLGenerator `generate` method (like query string parameters).
91
91
 
@@ -133,6 +133,20 @@ gateway.get_json("/path.json", skip_cache: true, ssl_certificate: ssl)
133
133
  gateway.post("/api/post_example", payload: { param1: "value" }, ssl_certificate: ssl)
134
134
  ```
135
135
 
136
+ You can use ssl_version to specify which version you need. (You can use with client cert and key or use it alone) See example below:
137
+
138
+ ```ruby
139
+ ssl = {
140
+ ssl_version: "SSLv23"
141
+ }
142
+
143
+ gateway.get("/path", timeout: 3, ssl_certificate: ssl)
144
+
145
+ gateway.get_json("/path.json", skip_cache: true, ssl_certificate: ssl)
146
+
147
+ gateway.post("/api/post_example", payload: { param1: "value" }, ssl_certificate: ssl)
148
+ ```
149
+
136
150
  ## Authors
137
151
 
138
152
  - [Túlio Ornelas](https://github.com/tulios)
@@ -42,12 +42,20 @@ module ContentGateway
42
42
  private
43
43
 
44
44
  def load_ssl_params h, params
45
- client_cert_file = File.read params[:ssl_certificate][:ssl_client_cert]
46
- client_cert_key = File.read params[:ssl_certificate][:ssl_client_key]
45
+ ssl_client_cert = params[:ssl_certificate][:ssl_client_cert]
46
+ ssl_client_key = params[:ssl_certificate][:ssl_client_key]
47
+ if ssl_client_cert || ssl_client_key
48
+ client_cert_file = File.read ssl_client_cert
49
+ client_cert_key = File.read ssl_client_key
50
+
51
+ h[:ssl_client_cert] = OpenSSL::X509::Certificate.new(client_cert_file)
52
+ h[:ssl_client_key] = OpenSSL::PKey::RSA.new(client_cert_key)
53
+ h[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
54
+ end
55
+
56
+ ssl_version = params[:ssl_certificate][:ssl_version]
57
+ h[:ssl_version] = ssl_version if ssl_version
47
58
 
48
- h[:ssl_client_cert] = OpenSSL::X509::Certificate.new(client_cert_file)
49
- h[:ssl_client_key] = OpenSSL::PKey::RSA.new(client_cert_key)
50
- h[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
51
59
  h
52
60
 
53
61
  rescue Errno::ENOENT => e0
@@ -1,3 +1,3 @@
1
1
  module ContentGateway
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -104,14 +104,32 @@ describe ContentGateway::Request do
104
104
 
105
105
  context "requests with SSL" do
106
106
 
107
- let(:ssl_certificate_params) { { ssl_client_cert: "test", ssl_client_key: "test"} }
108
- let(:restclient_ssl_params) { { :ssl_client_cert=>"cert", :ssl_client_key=>"key", :verify_ssl=>0 } }
107
+ let(:ssl_certificate_params) { { ssl_client_cert: "test", ssl_client_key: "test", ssl_version: "SSLv23"} }
108
+ let(:restclient_ssl_params) { { ssl_client_cert: "cert", ssl_client_key: "key", verify_ssl: 0, ssl_version: "SSLv23" } }
109
109
  let(:request_params_ssl) { request_params.merge! restclient_ssl_params }
110
110
 
111
111
  let :subject_ssl do
112
112
  ContentGateway::Request.new(:get, "/url", {}, {}, nil, ssl_certificate: ssl_certificate_params)
113
113
  end
114
114
 
115
+ context "only with ssl version" do
116
+ let(:ssl_certificate_params) { { ssl_version: "SSLv23" } }
117
+ let(:restclient_ssl_params) { { ssl_version: "SSLv23" } }
118
+ let(:request_params_ssl) { request_params.merge! restclient_ssl_params }
119
+
120
+ it "should setup request with ssl version" do
121
+ expect(RestClient::Request).to receive(:new).with(request_params_ssl)
122
+ subject_ssl.execute
123
+ end
124
+
125
+ it "should not setup ssl certificates" do
126
+ allow(RestClient::Request).to receive(:new).with(request_params_ssl).and_return(client)
127
+ expect(OpenSSL::X509::Certificate).to_not receive(:new)
128
+ expect(OpenSSL::PKey::RSA).to_not receive(:new)
129
+ subject_ssl.execute
130
+ end
131
+ end
132
+
115
133
  context "when request is successful" do
116
134
  before do
117
135
  allow(File).to receive(:read).with("test").and_return("cert_content")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Túlio Ornelas
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2015-01-06 00:00:00.000000000 Z
17
+ date: 2015-06-16 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: activesupport
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 2.2.2
158
+ rubygems_version: 2.4.5
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: Content Gateway