|
| 1 | +[1mdiff --git a/spec/unit/lib/hooks/plugins/auth/hmac_spec.rb b/spec/unit/lib/hooks/plugins/auth/hmac_spec.rb[m |
| 2 | +[1mindex 9e8b01c..fa12174 100644[m |
| 3 | +[1m--- a/spec/unit/lib/hooks/plugins/auth/hmac_spec.rb[m |
| 4 | +[1m+++ b/spec/unit/lib/hooks/plugins/auth/hmac_spec.rb[m |
| 5 | +[36m@@ -70,7 +70,8 @@[m [mdescribe Hooks::Plugins::Auth::HMAC do[m |
| 6 | + auth: {[m |
| 7 | + header: header,[m |
| 8 | + algorithm: "sha256",[m |
| 9 | +[31m- format: "signature_only"[m |
| 10 | +[32m+[m[32m format: "signature_only",[m |
| 11 | +[32m+[m[32m secret_env_key: "HMAC_TEST_SECRET"[m |
| 12 | + }[m |
| 13 | + }[m |
| 14 | + end[m |
| 15 | +[36m@@ -78,7 +79,7 @@[m [mdescribe Hooks::Plugins::Auth::HMAC do[m |
| 16 | + let(:headers) { { header => signature } }[m |
| 17 | + [m |
| 18 | + it "returns true for a valid hash-only signature" do[m |
| 19 | +[31m- # TODO[m |
| 20 | +[32m+[m[32m expect(valid_with(headers:, config:)).to be true[m |
| 21 | + end[m |
| 22 | + [m |
| 23 | + it "returns false for an invalid hash-only signature" do[m |
| 24 | +[36m@@ -104,13 +105,14 @@[m [mdescribe Hooks::Plugins::Auth::HMAC do[m |
| 25 | + format: "version=signature",[m |
| 26 | + version_prefix: "v0",[m |
| 27 | + payload_template: payload_template,[m |
| 28 | +[31m- timestamp_tolerance: 300[m |
| 29 | +[32m+[m[32m timestamp_tolerance: 300,[m |
| 30 | +[32m+[m[32m secret_env_key: "HMAC_TEST_SECRET"[m |
| 31 | + }[m |
| 32 | + }[m |
| 33 | + end[m |
| 34 | + [m |
| 35 | + it "returns true for a valid versioned signature with valid timestamp" do[m |
| 36 | +[31m- # TODO[m |
| 37 | +[32m+[m[32m expect(valid_with(headers:, config:)).to be true[m |
| 38 | + end[m |
| 39 | + [m |
| 40 | + it "returns false for an expired timestamp" do[m |
| 41 | +[36m@@ -153,10 +155,10 @@[m [mdescribe Hooks::Plugins::Auth::HMAC do[m |
| 42 | + [m |
| 43 | + context "with missing config values" do[m |
| 44 | + let(:headers) { { "X-Signature" => "sha256=" + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), secret, payload) } }[m |
| 45 | +[31m- let(:config) { {} }[m |
| 46 | +[32m+[m[32m let(:config) { { auth: { secret_env_key: "HMAC_TEST_SECRET" } } }[m |
| 47 | + [m |
| 48 | + it "uses defaults and validates correctly" do[m |
| 49 | +[31m- # TODO[m |
| 50 | +[32m+[m[32m expect(valid_with(headers:, config:)).to be true[m |
| 51 | + end[m |
| 52 | + end[m |
| 53 | + [m |
| 54 | +[36m@@ -404,7 +406,8 @@[m [mdescribe Hooks::Plugins::Auth::HMAC do[m |
| 55 | + format: "version=signature",[m |
| 56 | + version_prefix: "v0",[m |
| 57 | + payload_template: "v0:{timestamp}:{body}",[m |
| 58 | +[31m- timestamp_tolerance: 300[m |
| 59 | +[32m+[m[32m timestamp_tolerance: 300,[m |
| 60 | +[32m+[m[32m secret_env_key: "HMAC_TEST_SECRET"[m |
| 61 | + }[m |
| 62 | + }[m |
| 63 | + end[m |
| 64 | +[36m@@ -464,7 +467,14 @@[m [mdescribe Hooks::Plugins::Auth::HMAC do[m |
| 65 | + end[m |
| 66 | + [m |
| 67 | + it "returns true when timestamp header name case differs due to normalization" do[m |
| 68 | +[31m- # TODO[m |
| 69 | +[32m+[m[32m timestamp = Time.now.to_i.to_s[m |
| 70 | +[32m+[m[32m signing_payload = "v0:#{timestamp}:#{payload}"[m |
| 71 | +[32m+[m[32m signature = "v0=" + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), secret, signing_payload)[m |
| 72 | +[32m+[m |
| 73 | +[32m+[m[32m # Use uppercase timestamp header name in the request headers[m |
| 74 | +[32m+[m[32m headers = { header => signature, timestamp_header.upcase => timestamp }[m |
| 75 | +[32m+[m |
| 76 | +[32m+[m[32m expect(valid_with(headers:, config: base_config)).to be true[m |
| 77 | + end[m |
| 78 | + end[m |
| 79 | + [m |
0 commit comments