Sha256: c70caa353bbad154ce54d272b2e058383fb68946f1ba86ba15b390678e4e9c2c

Contents?: true

Size: 1.35 KB

Versions: 1

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(sg.name, "test_group_name_1")
    assert_equal(sg.id, "test_group_id_1")
    assert_equal(sg.description, "test_description_1")
    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(sg.tenant.id, '0123456789abcdef0123456789abcdef')

    assert_requested(stub)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yao-0.8.0 test/yao/resources/test_security_group.rb