Skip to content

Commit

Permalink
work on ssl issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bradpotts committed Nov 16, 2024
1 parent 51970a6 commit e1006b5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ Metrics/AbcSize:
Metrics/ClassLength:
Max: 150

Naming/VariableNumber:
Enabled: false

RSpec/MultipleExpectations:
Max: 10

Expand Down
12 changes: 10 additions & 2 deletions lib/ruby_api_pack_cloudways/connection/cw_connect.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# frozen_string_literal: true

require 'httparty'
require 'oj'
require 'openssl'

module RubyApiPackCloudways
module Connection
class CwConnect
Expand All @@ -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
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions spec/ruby_api_pack_cloudways/connection/cw_connect_spec.rb
Original file line number Diff line number Diff line change
@@ -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') }
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e1006b5

Please sign in to comment.