Sha256: 4bff13f0ad08809b38445e3403c3e93512468fd30dd20087ab14c3a506393582

Contents?: true

Size: 1.62 KB

Versions: 9

Compression:

Stored size: 1.62 KB

Contents

require "helper"

describe Fog::Bouncer do
  before do
    Fog::Bouncer.reset
    Fog::Mock.reset if Fog.mocking?

    load_security(:private)

    @doorlist = Fog::Bouncer.doorlists[:private]
    @doorlist.import_remote_groups
    @fog = Fog::Bouncer.fog
    @doorlist.sync
  end


  describe Fog::Bouncer::Group do
    before do
      @group = @doorlist.groups.find { |g| g.name == 'douchebag' }
    end

    describe "use" do
      it "should include any source definition specified" do
        @group.sources.find { |s| s.source == "0.0.0.0/0" && s.protocols.find { |p| p.type == "icmp" && p.from == 8 && p.to == 0 } }.wont_be_nil
      end

      it "should not create duplicate sources" do
        @group.sources.select { |s| s.source == "0.0.0.0/0" }.size.must_equal 1
      end
    end

    describe "#extras" do
      before do
        Fog::Bouncer::IPPermissions.to(@group, [{ "ipProtocol" => "tcp", "fromPort" => 20, "toPort" => 20, "ipRanges" => [{ "cidrIp" => "2.2.2.2/2" }], "groups" => [] }])

        @doorlist.clear_remote
      end

      it "detects the extra sources" do
        @group.extra_remote_sources.must_equal @group.sources.select { |s| s.source == "2.2.2.2/2" }

        @doorlist.clear_remote
      end
    end

    describe "#missing" do
      before do
        @source = Fog::Bouncer::Sources.for("2.2.2.2/2", @group)
        @source.protocols << Fog::Bouncer::Protocols::TCP.new(90, @source)
        @source.local = true
        @group.sources << @source
      end

      it "detects the missing sources" do
        @group.missing_remote_sources.must_equal [@source]

        @doorlist.clear_remote
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fog-bouncer-0.2.4 spec/fog/bouncer/group_spec.rb
fog-bouncer-0.2.3 spec/fog/bouncer/group_spec.rb
fog-bouncer-0.2.2 spec/fog/bouncer/group_spec.rb
fog-bouncer-0.2.1 spec/fog/bouncer/group_spec.rb
fog-bouncer-0.2.0 spec/fog/bouncer/group_spec.rb
fog-bouncer-0.1.1 spec/fog/bouncer/group_spec.rb
fog-bouncer-0.1.0 spec/fog/bouncer/group_spec.rb
fog-bouncer-0.0.8 spec/fog/bouncer/group_spec.rb
fog-bouncer-0.0.6 spec/fog/bouncer/group_spec.rb