-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from imnetworku/PIPE-6553
PIPE-6553: Upgrade http-hmac-ruby to Ruby 3.3
- Loading branch information
Showing
20 changed files
with
335 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
AllCops: | ||
DisplayCopNames: true | ||
NewCops: disable | ||
TargetRubyVersion: 3.3.6 | ||
|
||
Style/FrozenStringLiteralComment: | ||
Exclude: | ||
- 'lib/acquia-http-hmac/rack_authenticate.rb' | ||
|
||
Metrics/ParameterLists: | ||
Max: 7 | ||
|
||
Style/ClassVars: | ||
Exclude: | ||
- 'example/app.rb' | ||
- 'lib/acquia-http-hmac/rack_authenticate.rb' | ||
|
||
Metrics/AbcSize: | ||
Max: 50 | ||
Exclude: | ||
- 'test/acquia_spec_test.rb' | ||
|
||
Naming/AccessorMethodName: | ||
Exclude: | ||
- 'test/rack_simple_app_test.rb' | ||
- 'test/rack_sqlite3_app_test.rb' | ||
|
||
Metrics/BlockLength: | ||
Max: 150 | ||
|
||
Metrics/ClassLength: | ||
Max: 1000 | ||
|
||
Metrics/CyclomaticComplexity: | ||
Max: 12 | ||
|
||
Layout/LineLength: | ||
Max: 200 | ||
|
||
Metrics/MethodLength: | ||
Max: 50 | ||
|
||
Metrics/ModuleLength: | ||
Max: 250 | ||
|
||
Metrics/PerceivedComplexity: | ||
Max: 10 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
source "https://rubygems.org" | ||
# frozen_string_literal: true | ||
|
||
source 'https://rubygems.org' | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/setup' | ||
|
||
begin | ||
require 'rake/testtask' | ||
Rake::TestTask.new do |t| | ||
t.libs.push "lib" | ||
t.libs.push 'lib' | ||
t.test_files = FileList['test/*_test.rb'] | ||
t.verbose = true | ||
end | ||
task(default: [:test]) | ||
rescue LoadError | ||
|
||
desc 'Run RuboCop' | ||
task :rubocop do | ||
sh 'rubocop' | ||
end | ||
|
||
task default: %i[test rubocop] | ||
rescue LoadError => e | ||
warn "Could not load rake/testtask: #{e}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
Gem::Specification.new do |s| | ||
s.name = 'acquia-http-hmac' | ||
s.version = '2.0.2' | ||
s.version = '2.0.3' | ||
s.required_ruby_version = '>= 3.3.0' | ||
s.licenses = ['MIT'] | ||
s.summary = "HMAC signing library and rack middleware" | ||
s.summary = 'HMAC signing library and rack middleware' | ||
s.description = "HMAC signing library and rack middleware conforming to Acquia's HMAC 2.0 specifications" | ||
s.date = Time.now.strftime("%Y-%m-%d") | ||
s.authors = ["Peter Wolanin", "Marc Seeger"] | ||
s.date = Time.now.strftime('%Y-%m-%d') | ||
s.authors = ['Peter Wolanin', 'Marc Seeger'] | ||
s.email = '[email protected]' | ||
s.homepage = 'https://www.acquia.com/' | ||
s.files = Dir["[A-Z]*", "{bin,etc,lib,test}/**/*"] | ||
s.homepage = 'https://www.acquia.com/' | ||
s.files = Dir['[A-Z]*', '{bin,etc,lib,test}/**/*'] | ||
s.bindir = 'bin' | ||
s.require_paths = ["lib"] | ||
s.require_paths = ['lib'] | ||
s.executables << 'acq-http-request' | ||
|
||
s.add_dependency 'addressable', '~> 2.4' | ||
s.add_dependency 'addressable', '~> 2.8' | ||
|
||
s.add_development_dependency('rake') | ||
s.add_development_dependency('grape') | ||
s.add_development_dependency('rack-test') | ||
s.add_development_dependency('multi_json') | ||
s.add_development_dependency('sqlite3') | ||
s.add_development_dependency('webrick') | ||
s.add_development_dependency('grape', '~> 2.2') | ||
s.add_development_dependency('multi_json', '~> 1.15') | ||
s.add_development_dependency 'rack', '~> 2.2.10' | ||
s.add_development_dependency('rack-test', '~> 2.1') | ||
s.add_development_dependency('rake', '~> 13.2') | ||
s.add_development_dependency 'rubocop', '~> 1.69' | ||
s.add_development_dependency('sqlite3', '~> 2.4') | ||
s.add_development_dependency('webrick', '~> 1.9') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,71 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require 'acquia-http-hmac' | ||
require 'optparse' | ||
require 'ostruct' | ||
|
||
if ARGV[0] | ||
url = ARGV[0] | ||
end | ||
url = ARGV[0] if ARGV[0] | ||
|
||
# Argument processing | ||
options = OpenStruct.new | ||
options.realm = 'Test' | ||
options.http_method = 'GET' | ||
o = OptionParser.new do |opts| | ||
opts.banner = "Usage: #{$0} URL -u ID:PASSWORD" | ||
opts.on("-r", "--realm [REALM]", "Server auth realm. Default 'Test'.") { |v| options.realm = v } | ||
opts.on("-u", "--user [ID:PASSWORD]", "HMAC creds") { |v| options.user = v } | ||
opts.on("-d", "--data [DATA]", "Data to POST.") { |v| options.data = v } | ||
opts.on("-X", "--request [METHOD]", "HTTP method. Defaults to GET, or POST if --data is specified.") { |v| options.http_method = v.upcase } | ||
opts.banner = "Usage: #{$PROGRAM_NAME} URL -u ID:PASSWORD" | ||
opts.on('-r', '--realm [REALM]', "Server auth realm. Default 'Test'.") { |v| options.realm = v } | ||
opts.on('-u', '--user [ID:PASSWORD]', 'HMAC creds') { |v| options.user = v } | ||
opts.on('-d', '--data [DATA]', 'Data to POST.') { |v| options.data = v } | ||
opts.on('-X', '--request [METHOD]', 'HTTP method. Defaults to GET, or POST if --data is specified.') { |v| options.http_method = v.upcase } | ||
end | ||
begin | ||
o.parse! | ||
rescue Exception => e | ||
rescue StandardError => e | ||
puts e.message | ||
puts o.help | ||
exit 1 | ||
end | ||
|
||
if ARGV.empty? or !options.user | ||
if ARGV.empty? || !options.user | ||
puts o.help | ||
exit | ||
end | ||
|
||
uri = URI(Addressable::URI.escape.encode(url)) | ||
|
||
if uri.path == '' | ||
uri.path = '/' | ||
end | ||
uri.path = '/' if uri.path == '' | ||
|
||
host = uri.host | ||
if uri.port && uri.port != '443' | ||
host << ':' + uri.port | ||
end | ||
host << ":#{uri.port}" if uri.port && uri.port != '443' | ||
|
||
id, password = options.user.split(':', 2) | ||
|
||
mac = Acquia::HTTPHmac::Auth.new(options.realm, password) | ||
|
||
|
||
|
||
args = { | ||
http_method: options.http_method, | ||
host: host, | ||
id: id, | ||
path_info: uri.path, | ||
path_info: uri.path | ||
} | ||
|
||
case | ||
when options.http_method == 'GET' | ||
req = Net::HTTP::GET.new(uri) | ||
when options.http_method == 'HEAD' | ||
req = Net::HTTP::HEAD.new(uri) | ||
when options.http_method == 'POST' | ||
req = Net::HTTP::POST.new(uri) | ||
when options.http_method == 'PUT' | ||
req = Net::HTTP::PUT.new(uri) | ||
when options.http_method == 'DELETE' | ||
req = Net::HTTP::DELETE.new(uri) | ||
case options.http_method | ||
when 'GET' | ||
Net::HTTP::GET.new(uri) | ||
when 'HEAD' | ||
Net::HTTP::HEAD.new(uri) | ||
when 'POST' | ||
Net::HTTP::POST.new(uri) | ||
when 'PUT' | ||
Net::HTTP::PUT.new(uri) | ||
when 'DELETE' | ||
Net::HTTP::DELETE.new(uri) | ||
else | ||
fail("Unsupported HTTP verb #{options.http_method}") | ||
raise("Unsupported HTTP verb #{options.http_method}") | ||
end | ||
mac.prepare_request_headers(args).each do |name, value| | ||
#header(name, value) | ||
# header(name, value) | ||
end | ||
|
||
net = Net::HTTP.new(uri.host, uri.port) | ||
net.use_ssl= uri.host != 'localhost' | ||
|
||
net.use_ssl = uri.host != 'localhost' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.