Sha256: 0cb964275acfbeabba8ebfffc2a434cf6eb4a31c43c72ff3e5296537b121a071

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require "pact/ffi/verifier"
require "sbmt/pact/native/logger"

module Sbmt
  module Pact
    module Provider
      class HttpVerifier < BaseVerifier
        PROVIDER_TRANSPORT_TYPE = "http"

        def initialize(pact_config)
          super

          raise ArgumentError, "pact_config must be an instance of Sbmt::Pact::Provider::PactConfig::Http" unless pact_config.is_a?(::Sbmt::Pact::Provider::PactConfig::Http)
          @http_server = HttpServer.new(host: "127.0.0.1", port: @pact_config.http_port)
        end

        private

        def set_provider_info(pact_handle)
          PactFfi::Verifier.set_provider_info(pact_handle, @pact_config.provider_name, "", "", @pact_config.http_port, "")
        end

        def add_provider_transport(pact_handle)
          # The http transport is already added when the `set_provider_info` method is called,
          # so we don't need to explicitly add the transport here
        end

        def set_filter_info(pact_handle)
          PactFfi::Verifier.set_filter_info(pact_handle, "^http:.+", nil, 0)
        end

        def start_servers!
          super
          @http_server.start
        end

        def stop_servers
          super
          @http_server.stop
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sbmt-pact-0.12.2 lib/sbmt/pact/provider/http_verifier.rb
sbmt-pact-0.12.1 lib/sbmt/pact/provider/http_verifier.rb
sbmt-pact-0.12.0 lib/sbmt/pact/provider/http_verifier.rb