Sha256: 2d9382e3e87fbf47e28d455ee4fc786945e86fcc16d9fef46b1ff1a1059e6c94
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
# -*- encoding: utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe Simplenet::Client::Policy do before(:all) do @conf = {:url => "http://localhost:8081"} @conn = Simplenet::Client::Connection.new(@conf) @dcid = @conn.datacenters.create(random_name_for("datacenter"))["id"] @zone = @conn.zones.create(@dcid, random_name_for("zone"))["id"] @vlan = @conn.vlans.create( @zone, random_name_for("vlan"), random_name_for("vlan").sub(/[a-zA-Z]+/,"") )["id"] @cidr = random_cidr @sbnt = @conn.subnets.create(@vlan, @cidr) end before do @name = random_name_for("policy") end context "for firewall policies" do subject { @conn.policies("firewalls", "subnet") } before do @resp = subject.create( @sbnt["id"], random_ip(@cidr), rand(65000) ) end it "creates a new policy" do expect(@resp["id"]).to_not be_nil end it "shows a policy" do expect(@resp["id"]).to_not be_nil show = subject.show(@resp["id"]) expect(show["id"]).to eql(@resp["id"]) end it "deletes a policy" do expect(@resp["id"]).to_not be_nil expect { subject.show(@resp["id"]) }.to_not raise_error subject.delete(@resp["id"]) expect { subject.show(@resp["id"]) }.to raise_error(Simplenet::Exception::EntityNotFoundError) end it "retrieves policies by type using subnet" do expect(@resp["id"]).to_not be_nil by_type = subject.by_type expect(by_type).to be_an_instance_of Array expect(by_type.map{|item| item["id"]}).to include(@resp["id"]) end it "retrieves policies by owner using subnet" do expect(@resp["id"]).to_not be_nil by_owner = subject.by_owner(@sbnt["id"]) expect(by_owner).to be_an_instance_of Array expect(by_owner.map{|item| item["id"]}).to include(@resp["id"]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simplenet-client-0.2.0 | ./spec/simplenet/client/policy_spec.rb |