diff --git a/app/services/create_domain.rb b/app/services/create_domain.rb index 9aee5f0e..32936dba 100644 --- a/app/services/create_domain.rb +++ b/app/services/create_domain.rb @@ -3,10 +3,14 @@ require 'json' class CreateDomain < ApiConnector - SSL_OPTIONS = { - client_cert: OpenSSL::X509::Certificate.new(File.read(ENV['CLIENT_CERTS_PATH'])), - client_key: OpenSSL::PKey::RSA.new(File.read(ENV['CLIENT_KEY_PATH']), ENV['CLIENT_PASSWORD']) - }.freeze + if Rails.env.test? + SSL_OPTIONS = nil.freeze + else + SSL_OPTIONS = { + client_cert: OpenSSL::X509::Certificate.new(File.read(ENV['CLIENT_CERTS_PATH'])), + client_key: OpenSSL::PKey::RSA.new(File.read(ENV['CLIENT_KEY_PATH']), ENV['CLIENT_PASSWORD']) + }.freeze + end def initialize(username:, password:) super diff --git a/spec/services/api_connector_spec.rb b/spec/services/api_connector_spec.rb index 4ea6cd4f..fd552158 100644 --- a/spec/services/api_connector_spec.rb +++ b/spec/services/api_connector_spec.rb @@ -11,7 +11,7 @@ allow(body).to receive(:body).and_return(response) api_connector = ApiConnector.new(username: "mock", password: "username") - allow(api_connector).to receive(:faraday_request).with(url: "https://something", headers: {}, params: {}).and_return(Faraday) + allow(api_connector).to receive(:faraday_request).with(url: "https://something", headers: {}, params: {}, ssl: nil).and_return(Faraday) allow(Faraday).to receive(:send).with(:get).and_return(body) diff --git a/spec/services/create_domain_spec.rb b/spec/services/create_domain_spec.rb index 42162681..0d03d90f 100644 --- a/spec/services/create_domain_spec.rb +++ b/spec/services/create_domain_spec.rb @@ -39,7 +39,8 @@ allow(@api_connector).to receive(:request).with(url: @api_connector.domain_endpoint, headers: @api_connector.headers, method: :post, - params: payload).and_return(@response_successful) + params: payload, + ssl: nil).and_return(@response_successful) response = @api_connector.create_domain expect(response["code"]).to eq("1000")