rest-in-peace 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -5
- data/VERSION +1 -1
- data/lib/rest_in_peace/definition_proxy/collection_method_definitions.rb +3 -0
- data/lib/rest_in_peace/ssl_config_creator.rb +9 -3
- data/spec/rest_in_peace/definition_proxy/collection_method_definitions_spec.rb +9 -0
- data/spec/rest_in_peace_spec.rb +5 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -144,11 +144,9 @@ There is a helper class which can be used to create a Faraday compatible SSL con
|
|
144
144
|
|
145
145
|
```ruby
|
146
146
|
ssl_config = {
|
147
|
-
"
|
148
|
-
"
|
149
|
-
"
|
150
|
-
"ssl_key_client" => "/etc/ssl/private/client.key",
|
151
|
-
"ssl_ca" => "/etc/ssl/certs/ca-chain.crt"
|
147
|
+
"client_cert" => "/etc/ssl/private/client.crt",
|
148
|
+
"client_key" => "/etc/ssl/private/client.key",
|
149
|
+
"ca_cert" => "/etc/ssl/certs/ca-chain.crt"
|
152
150
|
}
|
153
151
|
|
154
152
|
ssl_config_creator = RESTinPeace::SSLConfigCreator.new(ssl_config, :peer)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
@@ -14,6 +14,9 @@ module RESTinPeace
|
|
14
14
|
params = default_params.merge(args.pop)
|
15
15
|
else
|
16
16
|
params = default_params.dup
|
17
|
+
end
|
18
|
+
|
19
|
+
if args.any?
|
17
20
|
tokens = RESTinPeace::TemplateSanitizer.new(url_template, {}).tokens
|
18
21
|
tokens.each do |token|
|
19
22
|
params.merge!(token.to_sym => args.shift)
|
@@ -2,9 +2,15 @@ require 'openssl'
|
|
2
2
|
|
3
3
|
module RESTinPeace
|
4
4
|
class SSLConfigCreator
|
5
|
+
class MissingParam < Exception; end
|
6
|
+
|
5
7
|
def initialize(config, verify = :peer)
|
6
8
|
@config = config
|
7
9
|
@verify = verify
|
10
|
+
|
11
|
+
raise MissingParam, 'Specify :ca_cert in ssl options' unless @config[:ca_cert]
|
12
|
+
raise MissingParam, 'Specify :client_key in ssl options' unless @config[:client_key]
|
13
|
+
raise MissingParam, 'Specify :client_cert in ssl options' unless @config[:client_cert]
|
8
14
|
end
|
9
15
|
|
10
16
|
def faraday_options
|
@@ -16,7 +22,7 @@ module RESTinPeace
|
|
16
22
|
end
|
17
23
|
|
18
24
|
def client_cert_path
|
19
|
-
path(@config[:
|
25
|
+
path(@config[:client_cert])
|
20
26
|
end
|
21
27
|
|
22
28
|
def client_key
|
@@ -24,11 +30,11 @@ module RESTinPeace
|
|
24
30
|
end
|
25
31
|
|
26
32
|
def client_key_path
|
27
|
-
path(@config[:
|
33
|
+
path(@config[:client_key])
|
28
34
|
end
|
29
35
|
|
30
36
|
def ca_cert_path
|
31
|
-
path(@config[:
|
37
|
+
path(@config[:ca_cert])
|
32
38
|
end
|
33
39
|
|
34
40
|
def verify_mode
|
@@ -59,6 +59,15 @@ describe RESTinPeace::DefinitionProxy::CollectionMethodDefinitions do
|
|
59
59
|
target.find(1)
|
60
60
|
end
|
61
61
|
|
62
|
+
it 'handles mixed parameters' do
|
63
|
+
expect(RESTinPeace::ApiCall).to receive(:new).
|
64
|
+
with(target.api, '/a/:id', target, id: 1, embed: %w(extra_field1)).
|
65
|
+
and_return(api_call_double)
|
66
|
+
|
67
|
+
subject.get(:find, '/a/:id', default_params)
|
68
|
+
target.find(1, embed: %w(extra_field1))
|
69
|
+
end
|
70
|
+
|
62
71
|
it 'appends the given attributes' do
|
63
72
|
expect(RESTinPeace::ApiCall).to receive(:new).
|
64
73
|
with(target.api, '/a', target, {name: 'daniele', last_name: 'in der o'}).
|
data/spec/rest_in_peace_spec.rb
CHANGED
@@ -50,6 +50,11 @@ describe RESTinPeace do
|
|
50
50
|
specify { expect(subject.name).to eq('test42') }
|
51
51
|
specify { expect { subject.email }.to raise_error(NoMethodError) }
|
52
52
|
end
|
53
|
+
|
54
|
+
context 'not given param' do
|
55
|
+
let(:attributes) { {} }
|
56
|
+
specify { expect(subject.name).to eq(nil) }
|
57
|
+
end
|
53
58
|
end
|
54
59
|
|
55
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-in-peace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|