Sha256: ae8e41dec416569758d091308506f82172928ce17b38581130632bfaf5da12e2

Contents?: true

Size: 1.27 KB

Versions: 65

Compression:

Stored size: 1.27 KB

Contents

require 'pact_broker/domain/webhook_request'
require 'faraday'
# certificates and key generated by script/generate-certificates-for-webooks-certificate-spec.rb

describe "executing a webhook to a server with a self signed certificate" do
  def wait_for_server_to_start
    Faraday.new(url: "https://localhost:4444", ssl: {verify: false}) do |builder|
      builder.request :retry, max: 20, interval: 0.5, exceptions: [StandardError]
      builder.adapter  :net_http
    end.get
  end

  before(:all) do
    @pipe = IO.popen("bundle exec ruby spec/support/ssl_webhook_server.rb")
    wait_for_server_to_start
  end

  let(:td) { TestDataBuilder.new }
  let(:webhook_request) do
    PactBroker::Domain::WebhookRequest.new(
      method: 'get',
      url: 'https://localhost:4444/')
  end

  subject { webhook_request.execute }

  context "without the correct cacert" do
    it "fails" do
      expect { subject }.to raise_error(OpenSSL::SSL::SSLError)
    end
  end

  context "with the correct cacert" do
    let!(:certificate) do
      td.create_certificate(path: 'spec/fixtures/certificates/cacert.pem')
    end

    it "succeeds" do
      puts subject.body unless subject.code == "200"
      expect(subject.code).to eq "200"
    end
  end

  after(:all) do
    Process.kill 'KILL', @pipe.pid
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
pact_broker-2.52.1 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.52.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.51.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.50.1 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.50.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.49.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.48.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.47.1 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.47.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.46.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.45.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.44.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.43.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.42.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.41.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.40.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.39.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.38.1 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.38.0 spec/integration/webhooks/certificate_spec.rb
pact_broker-2.37.0 spec/integration/webhooks/certificate_spec.rb