From 5fce6bb2a4baa76ee7c1f0e1617427a80d9db130 Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Mon, 4 Nov 2024 14:16:40 -0800 Subject: [PATCH 1/3] Remove unused em-http-request * this gem is blocking us from upgrading to Ruby 3.3, but it seems we don't actually use it --- Gemfile | 1 - Gemfile.lock | 11 ----- lib/vcap/services/api/async_requests.rb | 60 ------------------------- 3 files changed, 72 deletions(-) diff --git a/Gemfile b/Gemfile index f57dfbf45de..a883ac3bf3d 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,6 @@ gem 'allowy', '>= 2.1.0' gem 'clockwork', require: false gem 'cloudfront-signer' gem 'digest-xxhash' -gem 'em-http-request', '~> 1.1' gem 'eventmachine', '~> 1.2.7' gem 'fluent-logger' gem 'googleapis-common-protos', '>= 1.3.12' diff --git a/Gemfile.lock b/Gemfile.lock index 81249e7f1f7..27bf470eee7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -130,7 +130,6 @@ GEM coderay (1.1.3) concurrent-ruby (1.3.4) connection_pool (2.4.1) - cookiejar (0.3.3) crack (1.0.0) bigdecimal rexml @@ -148,14 +147,6 @@ GEM domain_name (0.6.20240107) drb (2.2.1) e2mmap (0.1.0) - em-http-request (1.1.7) - addressable (>= 2.3.4) - cookiejar (!= 0.3.1) - em-socksify (>= 0.3) - eventmachine (>= 1.0.3) - http_parser.rb (>= 0.6.0) - em-socksify (0.3.2) - eventmachine (>= 1.0.0.beta.4) erubi (1.13.0) eventmachine (1.2.7) excon (0.112.0) @@ -275,7 +266,6 @@ GEM http-cookie (1.0.5) domain_name (~> 0.5) http-form_data (2.3.0) - http_parser.rb (0.6.0) httpclient (2.8.3) i18n (1.14.6) concurrent-ruby (~> 1.0) @@ -609,7 +599,6 @@ DEPENDENCIES codeclimate-test-reporter (>= 1.0.8) debug (~> 1.9) digest-xxhash - em-http-request (~> 1.1) eventmachine (~> 1.2.7) fluent-logger fog-aliyun diff --git a/lib/vcap/services/api/async_requests.rb b/lib/vcap/services/api/async_requests.rb index 8a6f5e0b429..b867bf75d75 100644 --- a/lib/vcap/services/api/async_requests.rb +++ b/lib/vcap/services/api/async_requests.rb @@ -1,6 +1,4 @@ # Copyright (c) 2009-2011 VMware, Inc. -require 'eventmachine' -require 'em-http-request' require 'httpclient' require 'vcap/services/api/const' @@ -13,38 +11,6 @@ module Api end module VCAP::Services::Api - class AsyncHttpRequest - class << self - def new(url, token, verb, timeout, msg=VCAP::Services::Api::EMPTY_REQUEST) - req = { - head: { - VCAP::Services::Api::GATEWAY_TOKEN_HEADER => token, - 'Content-Type' => 'application/json' - }, - body: msg.encode - } - if timeout - EM::HttpRequest.new(url, inactivity_timeout: timeout).send(verb.to_sym, req) - else - EM::HttpRequest.new(url).send(verb.to_sym, req) - end - end - - def request(url, token, verb, timeout, msg=VCAP::Services::Api::EMPTY_REQUEST) - req = new(url, token, verb, timeout, msg) - f = Fiber.current - req.callback { f.resume(req) } - req.errback { f.resume(req) } - http = Fiber.yield - raise UnexpectedResponse.new("Error sending request #{msg.extract.to_json} to gateway #{@url}: #{http.error}") unless http.error.empty? - - code = http.response_header.status.to_i - body = http.response - [code, body] - end - end - end - module SynchronousHttpRequest def self.request(url, token, verb, _timeout, msg=VCAP::Services::Api::EMPTY_REQUEST) header = { @@ -57,30 +23,4 @@ def self.request(url, token, verb, _timeout, msg=VCAP::Services::Api::EMPTY_REQU [msg.code, msg.body] end end - - class AsyncHttpMultiPartUpload - class << self - def new(url, timeout, multipart, head={}) - req = { - head: head, - body: '', - multipart: multipart - } - - if timeout - EM::HttpRequest.new(url, inactivity_timeout: timeout).post req - else - EM::HttpRequest.new(url).post req - end - end - - def fibered(url, timeout, multipart, head={}) - req = new(url, timeout, multipart, head) - f = Fiber.current - req.callback { f.resume(req) } - req.errback { f.resume(req) } - Fiber.yield - end - end - end end From 0833a0e6728f9cd2df4d61ad0dae0ea1bd3ce0cf Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Mon, 4 Nov 2024 12:48:18 -0800 Subject: [PATCH 2/3] Remove unused RFC gem * the RFC gem doesn't support ruby 3.3, but we don't seem to use it anyway --- Gemfile | 1 - Gemfile.lock | 2 - lib/sequel_plugins/vcap_validations.rb | 7 ---- lib/vcap/rest_api/message.rb | 2 - ...validation_error_message_overrides_spec.rb | 9 ---- .../sequel_plugins/vcap_validations_spec.rb | 41 ------------------- 6 files changed, 62 deletions(-) diff --git a/Gemfile b/Gemfile index a883ac3bf3d..c7f79548ee7 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,6 @@ gem 'public_suffix' gem 'puma' gem 'rake' gem 'redis' -gem 'rfc822' gem 'rubyzip', '>= 1.3.0' gem 'sequel', '~> 5.85' gem 'sequel_pg', require: 'sequel' diff --git a/Gemfile.lock b/Gemfile.lock index 27bf470eee7..c503554aa99 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -425,7 +425,6 @@ GEM reverse_markdown (2.1.1) nokogiri rexml (3.3.9) - rfc822 (0.1.5) roodi (5.0.0) ruby_parser (~> 3.2, >= 3.2.2) rspec (3.13.0) @@ -640,7 +639,6 @@ DEPENDENCIES railties (~> 7.2.1) rake redis - rfc822 roodi rspec (~> 3.13.0) rspec-collection_matchers diff --git a/lib/sequel_plugins/vcap_validations.rb b/lib/sequel_plugins/vcap_validations.rb index 79e64f14b81..7be89e97f60 100644 --- a/lib/sequel_plugins/vcap_validations.rb +++ b/lib/sequel_plugins/vcap_validations.rb @@ -8,12 +8,5 @@ def validates_url(attr, opts={}) validates_format(URI::DEFAULT_PARSER.make_regexp(%w[http https]), attr, message: opts.fetch(:message, :url)) end - - # Validates that an attribute is a valid email address - # - # @param [Symbol] The attribute to validate - def validates_email(attr) - validates_format(RFC822::EMAIL_REGEXP_WHOLE, attr, message: :email) if send(attr) - end end end diff --git a/lib/vcap/rest_api/message.rb b/lib/vcap/rest_api/message.rb index 2897b48aad8..bdd26401109 100644 --- a/lib/vcap/rest_api/message.rb +++ b/lib/vcap/rest_api/message.rb @@ -1,5 +1,4 @@ require 'vcap/json_message' -require 'rfc822' module VCAP module RestAPI @@ -58,7 +57,6 @@ def self.schema_doc(schema) URL = UrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w[http https])) HTTPS_URL = HttpsUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp('https')) - EMAIL = EmailDecorator.new(RFC822::EMAIL_REGEXP_WHOLE) GIT_URL = GitUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w[http https git])) # The block will be evaluated in the context of the schema validator used diff --git a/spec/unit/lib/ext/validation_error_message_overrides_spec.rb b/spec/unit/lib/ext/validation_error_message_overrides_spec.rb index f877381269d..0a4a5c810c6 100644 --- a/spec/unit/lib/ext/validation_error_message_overrides_spec.rb +++ b/spec/unit/lib/ext/validation_error_message_overrides_spec.rb @@ -35,15 +35,6 @@ end end - context 'with a custom readable_regexp for an email' do - let(:regexp) { VCAP::RestAPI::Message::EMAIL } - - it 'generates a readable message' do - expected_emsg = 'must be a valid email' - expect { subject.fail!(regexp, object) }.to raise_error(Membrane::SchemaValidationError, /#{expected_emsg}/) - end - end - context 'with a custom readable_regexp for a git URL' do let(:regexp) { VCAP::RestAPI::Message::GIT_URL } diff --git a/spec/unit/lib/sequel_plugins/vcap_validations_spec.rb b/spec/unit/lib/sequel_plugins/vcap_validations_spec.rb index 533c030bed5..a1ef2a6a890 100644 --- a/spec/unit/lib/sequel_plugins/vcap_validations_spec.rb +++ b/spec/unit/lib/sequel_plugins/vcap_validations_spec.rb @@ -63,45 +63,4 @@ def self.define_validations(&) end end end - - describe 'validates_email' do - before do - @c.define_validations { validates_email(:val) } - end - - it 'allows a valid email' do - @m.val = 'some_guy@foo.com' - expect(@m).to be_valid - end - - it 'does not allow an email with no domain' do - @m.val = 'some_guy' - expect(@m).not_to be_valid - end - - it 'does not allow an email with no user' do - @m.val = '@somedomain.com' - expect(@m).not_to be_valid - end - - it 'does not allow a malformed email with multiple @' do - @m.val = 'foo@some@domain.com' - expect(@m).not_to be_valid - end - - it 'allows a nil email' do - @m.val = nil - expect(@m).to be_valid - end - - it 'does not allow an empty email' do - @m.val = '' - expect(@m).not_to be_valid - end - - it 'does not allow an email with only spaces' do - @m.val = ' ' - expect(@m).not_to be_valid - end - end end From 8538b3ba6fd7376c3742535314033263e7f72348 Mon Sep 17 00:00:00 2001 From: Seth Boyles Date: Mon, 4 Nov 2024 14:43:49 -0800 Subject: [PATCH 3/3] Bump ruby to 3.3.5 --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index b347b11eac8..fa7adc7ac72 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.3 +3.3.5