diff --git a/.rubocop.yml b/.rubocop.yml index 28a4740..1851f58 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -53,6 +53,9 @@ Metrics/AbcSize: Metrics/ClassLength: Max: 150 +Naming/VariableNumber: + Enabled: false + RSpec/MultipleExpectations: Max: 10 diff --git a/lib/ruby_api_pack_cloudways/connection/cw_connect.rb b/lib/ruby_api_pack_cloudways/connection/cw_connect.rb index 4cd78cc..2888528 100644 --- a/lib/ruby_api_pack_cloudways/connection/cw_connect.rb +++ b/lib/ruby_api_pack_cloudways/connection/cw_connect.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true +require 'httparty' +require 'oj' +require 'openssl' + module RubyApiPackCloudways module Connection class CwConnect @@ -17,7 +21,9 @@ def cloudways_api_connection token = CwToken.new.cw_api_token response = HTTParty.get( "#{@cw_api_url_base}#{@cw_api_path}", - headers: { 'Authorization' => "Bearer #{token}" } + headers: { 'Authorization' => "Bearer #{token}" }, + ssl_version: :TLSv1_2, + debug_output: $stdout ) handle_response(response) end @@ -28,7 +34,9 @@ def cloudways_api_post_connection(params) response = HTTParty.post( "#{@cw_api_url_base}#{@cw_api_path}", headers: { 'Authorization' => "Bearer #{token}", 'Content-Type' => 'application/json' }, - body: params.to_json + body: params.to_json, + ssl_version: :TLSv1_2, + debug_output: $stdout ) handle_response(response) end diff --git a/spec/ruby_api_pack_cloudways/connection/cw_connect_spec.rb b/spec/ruby_api_pack_cloudways/connection/cw_connect_spec.rb index 913ba16..1ad5de8 100644 --- a/spec/ruby_api_pack_cloudways/connection/cw_connect_spec.rb +++ b/spec/ruby_api_pack_cloudways/connection/cw_connect_spec.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -require 'spec_helper' -require 'ruby_api_pack_cloudways/connection/cw_connect' - RSpec.describe RubyApiPackCloudways::Connection::CwConnect do let(:connection) { described_class.new('https://api.cloudways.com/api/v1', '/some_path') } let(:token_instance) { instance_double(RubyApiPackCloudways::Connection::CwToken, cw_api_token: 'fake_token') } @@ -11,8 +8,7 @@ before do allow(RubyApiPackCloudways::Connection::CwToken).to receive(:new).and_return(token_instance) - allow(HTTParty).to receive(:get).and_return(http_response) - allow(HTTParty).to receive(:post).and_return(http_response) + allow(HTTParty).to receive_messages(get: http_response, post: http_response) end describe '#cloudways_api_connection' do @@ -21,7 +17,9 @@ expect(HTTParty).to have_received(:get).with( 'https://api.cloudways.com/api/v1/some_path', - headers: { 'Authorization' => 'Bearer fake_token' } + headers: { 'Authorization' => 'Bearer fake_token' }, + ssl_version: :TLSv1_2, + debug_output: $stdout ) end @@ -66,7 +64,9 @@ 'Authorization' => 'Bearer fake_token', 'Content-Type' => 'application/json' }, - body: post_params.to_json + body: post_params.to_json, + ssl_version: :TLSv1_2, + debug_output: $stdout ) end