Sha256: 03cf76c78c501f6a3dc931262910551df5f22deddbf55be1172418c94fbe00ab

Contents?: true

Size: 1.35 KB

Versions: 16

Compression:

Stored size: 1.35 KB

Contents

class TestSecurityGroup < TestYaoResource
  def test_sg_attributes
    params = {
      "id"                   => "test_group_id_1",
      "name"                 => "test_group_name_1",
      "description"          => "test_description_1",
      "security_group_rules" => [
        {
          "id"        => "test_rule_id_1",
          "direction" => "ingress",
          "protocol"  => "tcp",
          "ethertype" => "IPv4",
          "port"      =>  "443",
          "remote_ip" => "10.0.0.0/24"
        }
      ]
    }

    sg = Yao::SecurityGroup.new(params)
    assert_equal("test_group_name_1", sg.name)
    assert_equal("test_group_id_1", sg.id)
    assert_equal("test_description_1", sg.description)
    assert(sg.rules[0].instance_of?(Yao::SecurityGroupRule))
  end

  def test_sg_to_tenant

    stub = stub_request(:get, "https://example.com:12345/tenants/0123456789abcdef0123456789abcdef")
      .to_return(
        status: 200,
        body: <<-JSON,
        {
          "tenant": {
            "id": "0123456789abcdef0123456789abcdef"
          }
        }
        JSON
        headers: {'Content-Type' => 'application/json'}
      )

    sg = Yao::SecurityGroup.new('tenant_id' => '0123456789abcdef0123456789abcdef')
    assert_instance_of(Yao::Tenant, sg.tenant)
    assert_equal('0123456789abcdef0123456789abcdef', sg.tenant.id)

    assert_requested(stub)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
yao-0.15.0 test/yao/resources/test_security_group.rb
yao-0.14.0 test/yao/resources/test_security_group.rb
yao-0.13.4 test/yao/resources/test_security_group.rb
yao-0.13.3 test/yao/resources/test_security_group.rb
yao-0.13.2 test/yao/resources/test_security_group.rb
yao-0.13.1 test/yao/resources/test_security_group.rb
yao-0.13.0 test/yao/resources/test_security_group.rb
yao-0.12.0 test/yao/resources/test_security_group.rb
yao-0.11.3 test/yao/resources/test_security_group.rb
yao-0.11.2 test/yao/resources/test_security_group.rb
yao-0.11.1 test/yao/resources/test_security_group.rb
yao-0.11.0 test/yao/resources/test_security_group.rb
yao-0.10.1 test/yao/resources/test_security_group.rb
yao-0.10.0 test/yao/resources/test_security_group.rb
yao-0.9.1 test/yao/resources/test_security_group.rb
yao-0.9.0 test/yao/resources/test_security_group.rb