Sha256: c6432d94847e961f19ae88661ef44c31db3e60936746663042cba1b96d427e7c

Contents?: true

Size: 1.27 KB

Versions: 13

Compression:

Stored size: 1.27 KB

Contents

require 'pact_broker/webhooks/check_host_whitelist'

module PactBroker
  module Webhooks
    describe CheckHostWhitelist do
      context "when the host is 10.0.0.7" do
        let(:host) { "10.0.1.0" }

        it "matches 10.0.0.0/8" do
          expect(CheckHostWhitelist.call(host, ["10.0.0.0/8"])).to eq ["10.0.0.0/8"]
        end

        it "matches 10.0.1.0" do
          expect(CheckHostWhitelist.call(host, [host])).to eq [host]
        end

        it "does not match 10.0.0.2" do
          expect(CheckHostWhitelist.call(host, ["10.0.0.2"])).to eq []
        end

        it "does not match 10.0.0.0/28" do
          expect(CheckHostWhitelist.call(host, ["10.0.0.0/28"])).to eq []
        end
      end

      context "when the host is localhost" do
        let(:host) { "localhost" }

        it "matches localhost" do
          expect(CheckHostWhitelist.call(host, [host])).to eq [host]
        end

        it "matches /local.*/" do
          expect(CheckHostWhitelist.call(host, [/local*/])).to eq [/local*/]
        end

        it "does not match foo" do
          expect(CheckHostWhitelist.call(host, ["foo"])).to eq []
        end

        it "does not match /foo.*/" do
          expect(CheckHostWhitelist.call(host, [/foo*/])).to eq []
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pact_broker-2.27.0 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.26.1 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.26.0 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.25.0 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.24.0 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.23.4 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.23.3 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.23.2 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.23.1 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.23.0 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.22.0 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.21.0 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb
pact_broker-2.20.0 spec/lib/pact_broker/webhooks/check_host_whitelist_spec.rb