diff --git a/Gemfile b/Gemfile index 785ef124b68..72b23bb5c58 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" } ruby "~> #{File.read('.ruby-version').strip}" -gem 'rails', '~> 6.1.5.1' +gem 'rails', '~> 6.1.6.1' gem 'ahoy_matey', '~> 3.0' gem 'aws-sdk-kms', '~> 1.4' @@ -80,7 +80,7 @@ group :development do gem 'derailed_benchmarks', '~> 1.8' gem 'guard-rspec', require: false gem 'irb' - gem 'octokit' + gem 'octokit', '>= 4.25.0' gem 'rack-mini-profiler', '>= 1.1.3', require: false gem 'rails-erd', '>= 1.6.0' end diff --git a/Gemfile.lock b/Gemfile.lock index dea5ffc1a9d..a2aa6a9e0ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,60 +52,60 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.5.1) - actionpack (= 6.1.5.1) - activesupport (= 6.1.5.1) + actioncable (6.1.6.1) + actionpack (= 6.1.6.1) + activesupport (= 6.1.6.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.5.1) - actionpack (= 6.1.5.1) - activejob (= 6.1.5.1) - activerecord (= 6.1.5.1) - activestorage (= 6.1.5.1) - activesupport (= 6.1.5.1) + actionmailbox (6.1.6.1) + actionpack (= 6.1.6.1) + activejob (= 6.1.6.1) + activerecord (= 6.1.6.1) + activestorage (= 6.1.6.1) + activesupport (= 6.1.6.1) mail (>= 2.7.1) - actionmailer (6.1.5.1) - actionpack (= 6.1.5.1) - actionview (= 6.1.5.1) - activejob (= 6.1.5.1) - activesupport (= 6.1.5.1) + actionmailer (6.1.6.1) + actionpack (= 6.1.6.1) + actionview (= 6.1.6.1) + activejob (= 6.1.6.1) + activesupport (= 6.1.6.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.5.1) - actionview (= 6.1.5.1) - activesupport (= 6.1.5.1) + actionpack (6.1.6.1) + actionview (= 6.1.6.1) + activesupport (= 6.1.6.1) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.5.1) - actionpack (= 6.1.5.1) - activerecord (= 6.1.5.1) - activestorage (= 6.1.5.1) - activesupport (= 6.1.5.1) + actiontext (6.1.6.1) + actionpack (= 6.1.6.1) + activerecord (= 6.1.6.1) + activestorage (= 6.1.6.1) + activesupport (= 6.1.6.1) nokogiri (>= 1.8.5) - actionview (6.1.5.1) - activesupport (= 6.1.5.1) + actionview (6.1.6.1) + activesupport (= 6.1.6.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.5.1) - activesupport (= 6.1.5.1) + activejob (6.1.6.1) + activesupport (= 6.1.6.1) globalid (>= 0.3.6) - activemodel (6.1.5.1) - activesupport (= 6.1.5.1) - activerecord (6.1.5.1) - activemodel (= 6.1.5.1) - activesupport (= 6.1.5.1) - activestorage (6.1.5.1) - actionpack (= 6.1.5.1) - activejob (= 6.1.5.1) - activerecord (= 6.1.5.1) - activesupport (= 6.1.5.1) + activemodel (6.1.6.1) + activesupport (= 6.1.6.1) + activerecord (6.1.6.1) + activemodel (= 6.1.6.1) + activesupport (= 6.1.6.1) + activestorage (6.1.6.1) + actionpack (= 6.1.6.1) + activejob (= 6.1.6.1) + activerecord (= 6.1.6.1) + activesupport (= 6.1.6.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.5.1) + activesupport (6.1.6.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -341,7 +341,7 @@ GEM html_tokenizer (0.0.7) htmlentities (4.3.4) http_accept_language (2.1.1) - i18n (1.10.0) + i18n (1.11.0) concurrent-ruby (~> 1.0) i18n-tasks (0.9.35) activesupport (>= 4.0.2) @@ -391,7 +391,7 @@ GEM mini_histogram (0.3.1) mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.15.0) + minitest (5.16.2) msgpack (1.4.2) multipart-post (2.1.1) multiset (0.5.3) @@ -401,15 +401,15 @@ GEM net-ssh (6.1.0) newrelic_rpm (8.8.0) nio4r (2.5.8) - nokogiri (1.13.6) + nokogiri (1.13.7) mini_portile2 (~> 2.8.0) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - octokit (4.21.0) - faraday (>= 0.9) - sawyer (~> 0.8.0, >= 0.5.3) + octokit (5.1.0) + faraday (>= 1, < 3) + sawyer (~> 0.9) openssl (2.2.1) ipaddr openssl-signature_algorithm (1.2.1) @@ -450,7 +450,7 @@ GEM nio4r (~> 2.0) raabro (1.4.0) racc (1.6.0) - rack (2.2.3.1) + rack (2.2.4) rack-attack (6.5.0) rack (>= 1.0, < 3) rack-cors (1.1.1) @@ -460,26 +460,26 @@ GEM rack (>= 1.2.0) rack-proxy (0.7.2) rack - rack-test (1.1.0) - rack (>= 1.0, < 3) + rack-test (2.0.2) + rack (>= 1.3) rack-timeout (0.6.0) rack_session_access (0.2.0) builder (>= 2.0.0) rack (>= 1.0.0) - rails (6.1.5.1) - actioncable (= 6.1.5.1) - actionmailbox (= 6.1.5.1) - actionmailer (= 6.1.5.1) - actionpack (= 6.1.5.1) - actiontext (= 6.1.5.1) - actionview (= 6.1.5.1) - activejob (= 6.1.5.1) - activemodel (= 6.1.5.1) - activerecord (= 6.1.5.1) - activestorage (= 6.1.5.1) - activesupport (= 6.1.5.1) + rails (6.1.6.1) + actioncable (= 6.1.6.1) + actionmailbox (= 6.1.6.1) + actionmailer (= 6.1.6.1) + actionpack (= 6.1.6.1) + actiontext (= 6.1.6.1) + actionview (= 6.1.6.1) + activejob (= 6.1.6.1) + activemodel (= 6.1.6.1) + activerecord (= 6.1.6.1) + activestorage (= 6.1.6.1) + activesupport (= 6.1.6.1) bundler (>= 1.15.0) - railties (= 6.1.5.1) + railties (= 6.1.6.1) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -498,9 +498,9 @@ GEM rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) - railties (6.1.5.1) - actionpack (= 6.1.5.1) - activesupport (= 6.1.5.1) + railties (6.1.6.1) + actionpack (= 6.1.6.1) + activesupport (= 6.1.6.1) method_source rake (>= 12.2) thor (~> 1.0) @@ -587,9 +587,9 @@ GEM errbase (>= 0.1.1) safety_net_attestation (0.4.0) jwt (~> 2.0) - sawyer (0.8.2) + sawyer (0.9.2) addressable (>= 2.3.5) - faraday (> 0.8, < 2.0) + faraday (>= 0.17.3, < 3) scrypt (3.0.7) ffi-compiler (>= 1.0, < 2.0) selenium-webdriver (4.1.0) @@ -614,7 +614,7 @@ GEM simpleidn (0.2.1) unf (~> 0.1.4) smart_properties (1.17.0) - sprockets (4.0.3) + sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.4.2) @@ -750,7 +750,7 @@ DEPENDENCIES net-sftp newrelic_rpm (~> 8.0) nokogiri (~> 1.13.6) - octokit + octokit (>= 4.25.0) parallel_tests pg pg_query @@ -770,7 +770,7 @@ DEPENDENCIES rack-test (>= 1.1.0) rack-timeout rack_session_access (>= 0.2.0) - rails (~> 6.1.5.1) + rails (~> 6.1.6.1) rails-controller-testing (>= 1.0.4) rails-erd (>= 1.6.0) redacted_struct diff --git a/lib/telephony/pinpoint/sms_sender.rb b/lib/telephony/pinpoint/sms_sender.rb index 2261739d9d8..5b916710448 100644 --- a/lib/telephony/pinpoint/sms_sender.rb +++ b/lib/telephony/pinpoint/sms_sender.rb @@ -27,6 +27,9 @@ def send(message:, to:, country_code:, otp: nil) start = Time.zone.now client = build_client(sms_config) next if client.nil? + + sender_config = build_sender_config(country_code, sms_config, sender_id) + pinpoint_response = client.send_messages( application_id: sms_config.application_id, message_request: { @@ -39,9 +42,7 @@ def send(message:, to:, country_code:, otp: nil) sms_message: { body: message, message_type: 'TRANSACTIONAL', - origination_number: origination_number(country_code, sms_config, sender_id), - sender_id: sender_id, - }, + }.merge(sender_config), }, }, ) @@ -135,11 +136,7 @@ def build_client(sms_config) ) end - # To ensure Sender ID is used where needed, the origination number must not be - # specified. - def origination_number(country_code, sms_config, sender_id) - return nil if sender_id - + def origination_number(country_code, sms_config) if sms_config.country_code_longcode_pool&.dig(country_code).present? sms_config.country_code_longcode_pool[country_code].sample else @@ -147,6 +144,19 @@ def origination_number(country_code, sms_config, sender_id) end end + # If we are sending with Sender ID, we should not include origination_number + def build_sender_config(country_code, sms_config, sender_id) + if sender_id + { + sender_id: sender_id, + } + else + { + origination_number: origination_number(country_code, sms_config), + } + end + end + private def handle_pinpoint_error(err) diff --git a/spec/features/remember_device/cookie_expiration_spec.rb b/spec/features/remember_device/cookie_expiration_spec.rb index 86a06525a3d..cf0ab2378a2 100644 --- a/spec/features/remember_device/cookie_expiration_spec.rb +++ b/spec/features/remember_device/cookie_expiration_spec.rb @@ -42,17 +42,10 @@ def sign_in_user_with_remember_device click_submit_default end - # see http://jamesferg.com/testing/bdd/hacking-capybara-cookies/ def expire_cookies - cookies = Capybara. - current_session. - driver. - browser. - current_session. - instance_variable_get(:@rack_mock_session). - cookie_jar. - instance_variable_get(:@cookies) - - cookies.reject! { |c| c.expired? != false } + cookie_jar = Capybara.current_session.driver.browser.current_session.cookie_jar + cookie_jar.to_hash.each do |name, value| + cookie_jar.delete(name) if cookie_jar.get_cookie(name).expired? != false + end end end diff --git a/spec/lib/telephony/pinpoint/sms_sender_spec.rb b/spec/lib/telephony/pinpoint/sms_sender_spec.rb index edfeb2a9886..9c5dc89e846 100644 --- a/spec/lib/telephony/pinpoint/sms_sender_spec.rb +++ b/spec/lib/telephony/pinpoint/sms_sender_spec.rb @@ -192,7 +192,6 @@ def ==(other) sms_message: { body: 'This is a test!', message_type: 'TRANSACTIONAL', - origination_number: nil, sender_id: 'sender2', }, }, @@ -226,7 +225,6 @@ def ==(other) body: 'This is a test!', message_type: 'TRANSACTIONAL', origination_number: '123456', - sender_id: nil, }, }, }, @@ -261,7 +259,6 @@ def ==(other) body: 'This is a test!', message_type: 'TRANSACTIONAL', origination_number: '+19393334444', - sender_id: nil, }, }, },