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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 683a8c3b800d595a278cb6bfad07519e316b9c5e
4
- data.tar.gz: 5d039ed1e75512585e3d537551533a9950f9b437
3
+ metadata.gz: c00546dad5a52379b07bfbf7af3b17a40d20d048
4
+ data.tar.gz: 64c7c243b3451b8329e2ee8beb2bb2398fd7796d
5
5
  SHA512:
6
- metadata.gz: 6cf29eb1070a61d30c67049937e3aaa1d9d270a6f346cbbcc185b442227887fad27bba095d627f1b0c9329c2a67d9fd834045afecbe8d8aa9accab5efae9c4a5
7
- data.tar.gz: b5e49e9b7f5916c9ab4db94c1ecf5c7a672f517b439d925a8f703d384da00a45456cac5f82bb177750f7fd23564ccf4623863e430eba3e1373cf7203c8e65296
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
- response.body = Smaak::Crypto::decrypt(response.body, @key) if @association_store[identifier]['encrypt'] and response.code[0] == '2'
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
@@ -1,3 +1,3 @@
1
1
  module Smaak
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
@@ -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.10
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-07-23 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: persistent-cache