summaryrefslogtreecommitdiff
path: root/spec/mixlib
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mixlib')
-rw-r--r--spec/mixlib/authentication/digester_spec.rb6
-rw-r--r--spec/mixlib/authentication/http_authentication_request_spec.rb16
-rw-r--r--spec/mixlib/authentication/mixlib_authentication_spec.rb125
3 files changed, 75 insertions, 72 deletions
diff --git a/spec/mixlib/authentication/digester_spec.rb b/spec/mixlib/authentication/digester_spec.rb
index c54efa5..d094f40 100644
--- a/spec/mixlib/authentication/digester_spec.rb
+++ b/spec/mixlib/authentication/digester_spec.rb
@@ -27,14 +27,16 @@ describe Mixlib::Authentication::Digester do
describe "#hash_file" do
it "should default to use SHA1" do
expect(described_class.hash_file(StringIO.new(test_string))).to(
- eq(test_string_checksum))
+ eq(test_string_checksum)
+ )
end
end
describe "#hash_string" do
it "should default to use SHA1" do
expect(described_class.hash_string(test_string)).to(
- eq(test_string_checksum))
+ eq(test_string_checksum)
+ )
end
end
end
diff --git a/spec/mixlib/authentication/http_authentication_request_spec.rb b/spec/mixlib/authentication/http_authentication_request_spec.rb
index d62d67e..bd265bb 100644
--- a/spec/mixlib/authentication/http_authentication_request_spec.rb
+++ b/spec/mixlib/authentication/http_authentication_request_spec.rb
@@ -115,14 +115,14 @@ describe Mixlib::Authentication::HTTPAuthenticationRequest do
end
it "rebuilds the request signature from the headers" do
- expected = <<-SIG
-jVHrNniWzpbez/eGWjFnO6lINRIuKOg40ZTIQudcFe47Z9e/HvrszfVXlKG4
-NMzYZgyooSvU85qkIUmKuCqgG2AIlvYa2Q/2ctrMhoaHhLOCWWoqYNMaEqPc
-3tKHE+CfvP+WuPdWk4jv4wpIkAz6ZLxToxcGhXmZbXpk56YTmqgBW2cbbw4O
-IWPZDHSiPcw//AYNgW1CCDptt+UFuaFYbtqZegcBd2n/jzcWODA7zL4KWEUy
-9q4rlh/+1tBReg60QdsmDRsw/cdO1GZrKtuCwbuD4+nbRdVBKv72rqHX9cu0
-utju9jzczCyB+sSAQWrxSsXB/b8vV2qs0l4VD2ML+w==
-SIG
+ expected = <<~SIG
+ jVHrNniWzpbez/eGWjFnO6lINRIuKOg40ZTIQudcFe47Z9e/HvrszfVXlKG4
+ NMzYZgyooSvU85qkIUmKuCqgG2AIlvYa2Q/2ctrMhoaHhLOCWWoqYNMaEqPc
+ 3tKHE+CfvP+WuPdWk4jv4wpIkAz6ZLxToxcGhXmZbXpk56YTmqgBW2cbbw4O
+ IWPZDHSiPcw//AYNgW1CCDptt+UFuaFYbtqZegcBd2n/jzcWODA7zL4KWEUy
+ 9q4rlh/+1tBReg60QdsmDRsw/cdO1GZrKtuCwbuD4+nbRdVBKv72rqHX9cu0
+ utju9jzczCyB+sSAQWrxSsXB/b8vV2qs0l4VD2ML+w==
+ SIG
expect(@http_authentication_request.request_signature).to eq(expected.chomp)
end
diff --git a/spec/mixlib/authentication/mixlib_authentication_spec.rb b/spec/mixlib/authentication/mixlib_authentication_spec.rb
index 7d9b484..5a17d5c 100644
--- a/spec/mixlib/authentication/mixlib_authentication_spec.rb
+++ b/spec/mixlib/authentication/mixlib_authentication_spec.rb
@@ -1,3 +1,4 @@
+# rubocop: disable Style/MutableConstant
#
# Author:: Tim Hinderliter (<tim@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
@@ -64,7 +65,7 @@ class MockFile
end
# Uncomment this to get some more info from the methods we're testing.
-#Mixlib::Authentication.logger.level = :trace
+# Mixlib::Authentication.logger.level = :trace
describe "Mixlib::Authentication::SignedHeaderAuth" do
@@ -233,7 +234,7 @@ describe "Mixlib::Authentication::SignatureVerification" do
mock_request = MockRequest.new(PATH, MERB_REQUEST_PARAMS, headers, BODY)
allow(Time).to receive(:now).and_return(TIMESTAMP_OBJ)
- #Time.stub!(:now).and_return(TIMESTAMP_OBJ)
+ # Time.stub!(:now).and_return(TIMESTAMP_OBJ)
auth_req = Mixlib::Authentication::SignatureVerification.new
expect { auth_req.authenticate_user_request(mock_request, @user_private_key) }.to raise_error(Mixlib::Authentication::AuthenticationError)
@@ -344,7 +345,7 @@ V1_3_ARGS_SHA256 = {
proto_version: "1.3",
headers: {
"X-OpS-SeRvEr-ApI-VerSiOn" => "1",
- }
+ },
# This defaults to sha256
}
@@ -502,7 +503,7 @@ MERB_HEADERS_V1_0 = {
PASSENGER_REQUEST_PARAMS = {
"action" => "create",
- #"tarball"=>#<File:/tmp/RackMultipart20091120-25570-mgq2sa-0>,
+ # "tarball"=>#<File:/tmp/RackMultipart20091120-25570-mgq2sa-0>,
"controller" => "api/v1/cookbooks",
"cookbook" => "{\"category\":\"databases\"}",
}
@@ -542,78 +543,78 @@ PASSENGER_HEADERS_V1_0 = {
# generated with
# openssl genrsa -out private.pem 2048
# openssl rsa -in private.pem -out public.pem -pubout
-PUBLIC_KEY_DATA = <<EOS
------BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ueqo76MXuP6XqZBILFz
-iH/9AI7C6PaN5W0dSvkr9yInyGHSz/IR1+4tqvP2qlfKVKI4CP6BFH251Ft9qMUB
-uAsnlAVQ1z0exDtIFFOyQCdR7iXmjBIWMSS4buBwRQXwDK7id1OxtU23qVJv+xwE
-V0IzaaSJmaGLIbvRBD+qatfUuQJBMU/04DdJIwvLtZBYdC2219m5dUBQaa4bimL+
-YN9EcsDzD9h9UxQo5ReK7b3cNMzJBKJWLzFBcJuePMzAnLFktr/RufX4wpXe6XJx
-oVPaHo72GorLkwnQ0HYMTY8rehT4mDi1FI969LHCFFaFHSAaRnwdXaQkJmSfcxzC
-YQIDAQAB
------END PUBLIC KEY-----
+PUBLIC_KEY_DATA = <<~EOS
+ -----BEGIN PUBLIC KEY-----
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ueqo76MXuP6XqZBILFz
+ iH/9AI7C6PaN5W0dSvkr9yInyGHSz/IR1+4tqvP2qlfKVKI4CP6BFH251Ft9qMUB
+ uAsnlAVQ1z0exDtIFFOyQCdR7iXm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hlHNk7CW2azIPqcLLH99EwCYi/miNH+pijZ2aHGCXb
+ /bZrSxM0ADmrZKDxdB6uGCyp+GS2sBxjEyEsfCyvwhJ8b3Q100tqwiNO+d5FCglp
+ HICx2dgUjuRVUliBwOK93nx1AoGAUI8RhIEjOYkeDAESyhNMBr0LGjnLOosX+/as
+ qiotYkpjWuFULbibOFp+WMW41vDvD9qrSXir3fstkeIAW5KqVkO6mJnRoT3Knnra
+ zjiKOITCAZQeiaP8BO5o3pxE9TMqb9VCO3ffnPstIoTaN4syPg7tiGo8k1SklVeH
+ 2S8lzq0CgYAKG2fljIYWQvGH628rp4ZcXS4hWmYohOxsnl1YrszbJ+hzR+IQOhGl
+ YlkUQYXhy9JixmUUKtH+NXkKX7Lyc8XYw5ETr7JBT3ifs+G7HruDjVG78EJVojbd
+ 8uLA+DdQm5mg4vd1GTiSK65q/3EeoBlUaVor3HhLFki+i9qpT8CBsg==
+ -----END RSA PRIVATE KEY-----
EOS
PRIVATE_KEY = OpenSSL::PKey::RSA.new(PRIVATE_KEY_DATA)
-V1_0_CANONICAL_REQUEST_DATA = <<EOS
-Method:POST
-Hashed Path:#{HASHED_CANONICAL_PATH}
-X-Ops-Content-Hash:#{HASHED_BODY}
-X-Ops-Timestamp:#{TIMESTAMP_ISO8601}
-X-Ops-UserId:#{USER_ID}
+V1_0_CANONICAL_REQUEST_DATA = <<~EOS
+ Method:POST
+ Hashed Path:#{HASHED_CANONICAL_PATH}
+ X-Ops-Content-Hash:#{HASHED_BODY}
+ X-Ops-Timestamp:#{TIMESTAMP_ISO8601}
+ X-Ops-UserId:#{USER_ID}
EOS
V1_0_CANONICAL_REQUEST = V1_0_CANONICAL_REQUEST_DATA.chomp
-V1_1_CANONICAL_REQUEST_DATA = <<EOS
-Method:POST
-Hashed Path:#{HASHED_CANONICAL_PATH}
-X-Ops-Content-Hash:#{HASHED_BODY}
-X-Ops-Timestamp:#{TIMESTAMP_ISO8601}
-X-Ops-UserId:#{DIGESTED_USER_ID}
+V1_1_CANONICAL_REQUEST_DATA = <<~EOS
+ Method:POST
+ Hashed Path:#{HASHED_CANONICAL_PATH}
+ X-Ops-Content-Hash:#{HASHED_BODY}
+ X-Ops-Timestamp:#{TIMESTAMP_ISO8601}
+ X-Ops-UserId:#{DIGESTED_USER_ID}
EOS
V1_1_CANONICAL_REQUEST = V1_1_CANONICAL_REQUEST_DATA.chomp
-V1_3_SHA256_CANONICAL_REQUEST_DATA = <<EOS
-Method:POST
-Path:#{PATH}
-X-Ops-Content-Hash:#{HASHED_BODY_SHA256}
-X-Ops-Sign:version=1.3
-X-Ops-Timestamp:#{TIMESTAMP_ISO8601}
-X-Ops-UserId:#{USER_ID}
-X-Ops-Server-API-Version:1
+V1_3_SHA256_CANONICAL_REQUEST_DATA = <<~EOS
+ Method:POST
+ Path:#{PATH}
+ X-Ops-Content-Hash:#{HASHED_BODY_SHA256}
+ X-Ops-Sign:version=1.3
+ X-Ops-Timestamp:#{TIMESTAMP_ISO8601}
+ X-Ops-UserId:#{USER_ID}
+ X-Ops-Server-API-Version:1
EOS
V1_3_SHA256_CANONICAL_REQUEST = V1_3_SHA256_CANONICAL_REQUEST_DATA.chomp