http_signatures 1.0.1 → 1.0.2

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: c5c7339b04086bd5daa91dc6b18f3b81533f968b
4
- data.tar.gz: 7795f49a0a2163902cb11b9d4a6c3c96cd445f82
3
+ metadata.gz: 4a264bdc74bd252c38f2327f6152b7ac67ddac76
4
+ data.tar.gz: 86193ad941a2f492e16ce8a20a9938e6e561442b
5
5
  SHA512:
6
- metadata.gz: 1643e2f919c5da1fe6f80ed9eef7e6ebfd4443474228c9c92c6f7dcdb6c986232670d6aed3c251196012e8a50d2e84ab3d57d3a1674bfd7d5754e0167f0f913b
7
- data.tar.gz: 6f710a1ae21aed1b2fea9e303541116305b0dc57c565f24c233c9364f0e74c8c0bf01a7c41350b006847877c8b665a513c0a13af7c4c8f054e20a628e36ac30d
6
+ metadata.gz: 80e1dd75f46c8dd1c82b878a893c9b94bee453c2ef33fdfb170ee34fc52151a8e61004dbdecf208c28197af76ff337db7a1dc4a76d39feead2b03b2b5f9bcb45
7
+ data.tar.gz: 3df85e7bcd62cba2167211a7379f77662238b4a8ea87a7b64e933e8a77a580e40ce3c536d48a1286e68d9995086642734db2b6922805590f9fd0f25d1731fc93
@@ -1,6 +1,5 @@
1
1
  require "http_signatures/algorithm"
2
2
  require "http_signatures/algorithm/hmac"
3
- require "http_signatures/algorithm/null"
4
3
  require "http_signatures/context"
5
4
  require "http_signatures/header_list"
6
5
  require "http_signatures/key"
@@ -3,7 +3,6 @@ module HttpSignatures
3
3
 
4
4
  def self.create(name)
5
5
  case name
6
- when "null" then Null.new
7
6
  when "hmac-sha1" then Hmac.new("sha1")
8
7
  when "hmac-sha256" then Hmac.new("sha256")
9
8
  else raise UnknownAlgorithm.new(name)
@@ -1,3 +1,3 @@
1
1
  module HttpSignatures
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -6,7 +6,6 @@ RSpec.describe HttpSignatures::Algorithm do
6
6
  let(:input) { "the string\nto sign" }
7
7
 
8
8
  {
9
- "null" => "bnVsbA==", # "null"
10
9
  "hmac-sha1" => "bXPeVc5ySIyeUapN7mpMsJRnxVg=",
11
10
  "hmac-sha256" => "hRQ5zpbGudR1hokS4PqeAkveKmz2dd8SCgV8OHcramI=",
12
11
  }.each do |name, base64_signature|
@@ -8,7 +8,7 @@ RSpec.describe HttpSignatures::Context do
8
8
  subject(:context) do
9
9
  HttpSignatures::Context.new(
10
10
  keys: {"hello" => "world"},
11
- algorithm: "null",
11
+ algorithm: "hmac-sha256",
12
12
  headers: %w{(request-target) date content-length},
13
13
  )
14
14
  end
@@ -17,7 +17,7 @@ RSpec.describe HttpSignatures::Context do
17
17
  it "instantiates Signer with key, algorithm, headers" do
18
18
  expect(HttpSignatures::Signer).to receive(:new) do |args|
19
19
  expect(args[:key]).to eq(HttpSignatures::Key.new(id: "hello", secret: "world"))
20
- expect(args[:algorithm].name).to eq("null")
20
+ expect(args[:algorithm].name).to eq("hmac-sha256")
21
21
  expect(args[:header_list].to_a).to eq(%w{(request-target) date content-length})
22
22
  end
23
23
  context.signer
@@ -40,7 +40,7 @@ RSpec.describe HttpSignatures::Context do
40
40
  HttpSignatures::Context.new(
41
41
  keys: {"hello" => "world", "another" => "key"},
42
42
  signing_key_id: "another",
43
- algorithm: "null",
43
+ algorithm: "hmac-sha256",
44
44
  headers: %w{(request-target) date content-length},
45
45
  )
46
46
  end
@@ -49,7 +49,7 @@ RSpec.describe HttpSignatures::Context do
49
49
  it "instantiates Signer with key, algorithm, headers" do
50
50
  expect(HttpSignatures::Signer).to receive(:new) do |args|
51
51
  expect(args[:key]).to eq(HttpSignatures::Key.new(id: "another", secret: "key"))
52
- expect(args[:algorithm].name).to eq("null")
52
+ expect(args[:algorithm].name).to eq("hmac-sha256")
53
53
  expect(args[:header_list].to_a).to eq(%w{(request-target) date content-length})
54
54
  end
55
55
  context.signer
@@ -8,7 +8,7 @@ RSpec.describe HttpSignatures::Signer do
8
8
  HttpSignatures::Signer.new(key: key, algorithm: algorithm, header_list: header_list)
9
9
  end
10
10
  let(:key) { HttpSignatures::Key.new(id: "pda", secret: "sh") }
11
- let(:algorithm) { HttpSignatures::Algorithm::Null.new }
11
+ let(:algorithm) { HttpSignatures::Algorithm::Hmac.new("sha256") }
12
12
  let(:header_list) { HttpSignatures::HeaderList.new(["date", "content-type"]) }
13
13
 
14
14
  let(:message) do
@@ -49,7 +49,7 @@ RSpec.describe HttpSignatures::Signer do
49
49
  expect(algorithm).to receive(:sign).with(
50
50
  "sh",
51
51
  ["date: #{EXAMPLE_DATE}", "content-type: text/plain"].join("\n")
52
- ).at_least(:once).and_return("null")
52
+ ).at_least(:once).and_return("static")
53
53
  signer.sign(message)
54
54
  end
55
55
  it "returns reference to the mutated input" do
@@ -67,14 +67,14 @@ RSpec.describe HttpSignatures::Signer do
67
67
  end
68
68
  it "matches expected Authorization header" do
69
69
  expect(message["Authorization"]).to eq(
70
- 'Signature keyId="pda",algorithm="null",' +
71
- 'headers="date content-type",signature="bnVsbA=="'
70
+ 'Signature keyId="pda",algorithm="hmac-sha256",' +
71
+ 'headers="date content-type",signature="0ZoJq6cxYZRXe+TN85whSuQgJsam1tRyIal7ni+RMXA="'
72
72
  )
73
73
  end
74
74
  it "matches expected Signature header" do
75
75
  expect(message["Signature"]).to eq(
76
- 'keyId="pda",algorithm="null",' +
77
- 'headers="date content-type",signature="bnVsbA=="'
76
+ 'keyId="pda",algorithm="hmac-sha256",' +
77
+ 'headers="date content-type",signature="0ZoJq6cxYZRXe+TN85whSuQgJsam1tRyIal7ni+RMXA="'
78
78
  )
79
79
  end
80
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_signatures
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Annesley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-24 00:00:00.000000000 Z
11
+ date: 2014-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,7 +70,6 @@ files:
70
70
  - lib/http_signatures.rb
71
71
  - lib/http_signatures/algorithm.rb
72
72
  - lib/http_signatures/algorithm/hmac.rb
73
- - lib/http_signatures/algorithm/null.rb
74
73
  - lib/http_signatures/context.rb
75
74
  - lib/http_signatures/header_list.rb
76
75
  - lib/http_signatures/key.rb
@@ -1,15 +0,0 @@
1
- module HttpSignatures
2
- module Algorithm
3
- class Null
4
-
5
- def name
6
- "null"
7
- end
8
-
9
- def sign(key, data)
10
- "null"
11
- end
12
-
13
- end
14
- end
15
- end