smaak 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smaak/client.rb +10 -1
- data/lib/smaak/version.rb +1 -1
- data/spec/lib/smaak/client_spec.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c00546dad5a52379b07bfbf7af3b17a40d20d048
|
4
|
+
data.tar.gz: 64c7c243b3451b8329e2ee8beb2bb2398fd7796d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccc4dc56a2bd6ddb3112ed252b9b1165b03290e24106fa091cd81a93d216d567d6d12bcc6dfad12f77cf24797ec2cb41ad9693065949c5bb20930d49a96bed97
|
7
|
+
data.tar.gz: 2e8466aed402283960edf3cf5fcdcfb5c29dd45657a5e27aa42bdfd2c70ba3fb798c7f313e38db51798c9da494fb83917e2f000254c206e849f96d13481218e6
|
data/lib/smaak/client.rb
CHANGED
@@ -51,9 +51,18 @@ module Smaak
|
|
51
51
|
adaptor = Smaak::create_adaptor(req)
|
52
52
|
req = (sign_request(identifier, adaptor)).request
|
53
53
|
response = http.request(req)
|
54
|
-
|
54
|
+
|
55
|
+
response.body = Smaak::Crypto::decrypt(response.body, @key) if encrypt_associate?(identifier) and response.code[0] == '2'
|
55
56
|
puts "[smaak error]: response from #{identifier} was #{response.code}" if not response.code[0] == '2'
|
56
57
|
response
|
57
58
|
end
|
59
|
+
|
60
|
+
def encrypt_associate?(identifier)
|
61
|
+
return false if identifier.nil?
|
62
|
+
return false if @association_store[identifier].nil?
|
63
|
+
return true if @association_store[identifier]["encrypt"] == true
|
64
|
+
return true if @association_store[identifier]["encrypt"].to_s.downcase == "true"
|
65
|
+
false
|
66
|
+
end
|
58
67
|
end
|
59
68
|
end
|
data/lib/smaak/version.rb
CHANGED
@@ -171,12 +171,11 @@ describe Smaak::Client do
|
|
171
171
|
expect(mock_http).to receive(:request).with(mock_req).and_return(mock_response)
|
172
172
|
expect(Smaak::Crypto).to receive(:encrypt).and_return ""
|
173
173
|
expect(Smaak::Crypto).to receive(:decrypt).with("", @iut.key)
|
174
|
-
|
175
174
|
@iut.post('encrypted', @test_uri, @test_body, false, OpenSSL::SSL::VERIFY_NONE)
|
176
175
|
end
|
177
176
|
|
178
177
|
it "should decrypt the response body only if the response code is a 200 class code (2XX)" do
|
179
|
-
@iut.add_association('encrypted', @test_service_public_key, @test_service_psk, true)
|
178
|
+
@iut.add_association('encrypted', @test_service_public_key, @test_service_psk, "true")
|
180
179
|
url = URI.parse(@test_uri)
|
181
180
|
mock_http = Net::HTTP.new(url.host, url.port)
|
182
181
|
mock_req = Net::HTTP::Post.new(url.to_s)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smaak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernst van Graan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: persistent-cache
|