diff options
author | Thom May <thom@may.lt> | 2016-12-06 18:33:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-06 18:33:03 +0000 |
commit | 42b5c7538fe6775ab13ac5a82f52da050789ee4e (patch) | |
tree | 097759d8eafbd7017289cce3a1e4eaa19c662792 | |
parent | dde604f3c3d55240ad04e6b87c0318fc075e5d72 (diff) | |
parent | 1636948da8b17273a36c3ab52a0f34fa24aa61d8 (diff) | |
download | mixlib-authentication-42b5c7538fe6775ab13ac5a82f52da050789ee4e.tar.gz |
Merge pull request #20 from chef/updates
Test on modern ruby / use rake 11
-rw-r--r-- | .travis.yml | 20 | ||||
-rw-r--r-- | lib/mixlib/authentication/digester.rb | 4 | ||||
-rw-r--r-- | lib/mixlib/authentication/signedheaderauth.rb | 10 | ||||
-rw-r--r-- | mixlib-authentication.gemspec | 2 | ||||
-rw-r--r-- | spec/mixlib/authentication/digester_spec.rb | 4 |
5 files changed, 24 insertions, 16 deletions
diff --git a/.travis.yml b/.travis.yml index 62b3473..d730821 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,23 @@ sudo: false language: ruby -rvm: - - 2.1 - - 2.2 - - 2.3.1 + +before_install: + - gem install bundler + - bundle --version + - gem update --system + - gem --version + +matrix: + include: + - rvm: 2.1.10 + - rvm: 2.2.6 + - rvm: 2.3.3 + - rvm: ruby-head + allow_failures: + - rvm: ruby-head branches: only: - master -before_install: gem install bundler -v 1.11.2 script: bundle exec rake ci diff --git a/lib/mixlib/authentication/digester.rb b/lib/mixlib/authentication/digester.rb index 8628d53..f826b4c 100644 --- a/lib/mixlib/authentication/digester.rb +++ b/lib/mixlib/authentication/digester.rb @@ -27,9 +27,7 @@ module Mixlib def hash_file(f, digest = OpenSSL::Digest::SHA1) digester = digest.new buf = "" - while f.read(16384, buf) - digester.update buf - end + digester.update buf while f.read(16384, buf) ::Base64.encode64(digester.digest).chomp end diff --git a/lib/mixlib/authentication/signedheaderauth.rb b/lib/mixlib/authentication/signedheaderauth.rb index ab8d989..f107170 100644 --- a/lib/mixlib/authentication/signedheaderauth.rb +++ b/lib/mixlib/authentication/signedheaderauth.rb @@ -263,23 +263,23 @@ module Mixlib # A Struct-based value object that contains the necessary information to # generate a request signature. `SignedHeaderAuth.signing_object()` # provides a more convenient interface to the constructor. - class SigningObject < Struct.new(:http_method, :path, :body, :host, + SigningObject = Struct.new(:http_method, :path, :body, :host, :timestamp, :user_id, :file, :proto_version, - :headers) + :headers) do include SignedHeaderAuth def proto_version - (self[:proto_version] || DEFAULT_PROTO_VERSION).to_s + (self[:proto_version] || SignedHeaderAuth::DEFAULT_PROTO_VERSION).to_s end def server_api_version key = (self[:headers] || {}).keys.select do |k| - k.downcase == "x-ops-server-api-version" + k.casecmp("x-ops-server-api-version").zero? end.first if key self[:headers][key] else - DEFAULT_SERVER_API_VERSION + SignedHeaderAuth::DEFAULT_SERVER_API_VERSION end end end diff --git a/mixlib-authentication.gemspec b/mixlib-authentication.gemspec index d48dbeb..65cd629 100644 --- a/mixlib-authentication.gemspec +++ b/mixlib-authentication.gemspec @@ -21,5 +21,5 @@ Gem::Specification.new do |s| %w{rspec-core rspec-expectations rspec-mocks}.each { |gem| s.add_development_dependency gem, "~> 3.2" } s.add_development_dependency "chefstyle" - s.add_development_dependency "rake", "~> 10.4" + s.add_development_dependency "rake", "~> 11" end diff --git a/spec/mixlib/authentication/digester_spec.rb b/spec/mixlib/authentication/digester_spec.rb index fd3eb41..4688d5c 100644 --- a/spec/mixlib/authentication/digester_spec.rb +++ b/spec/mixlib/authentication/digester_spec.rb @@ -7,14 +7,14 @@ describe Mixlib::Authentication::Digester do let(:test_string) { "hello" } let(:test_string_checksum) { "qvTGHdzF6KLavt4PO0gs2a6pQ00=" } - describe '#hash_file' 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)) end end - describe '#hash_string' do + describe "#hash_string" do it "should default to use SHA1" do expect(described_class.hash_string(test_string)).to( eq(test_string_checksum)) |