Sha256: 2a452b4ebf7a2f9e3831abd9db1c61426e00fe5ead152ec70a4fc5f6cab3e3da

Contents?: true

Size: 1.62 KB

Versions: 15

Compression:

Stored size: 1.62 KB

Contents

class TestRoleAssignment < TestYaoResource

  def test_role_assignment

    # https://docs.openstack.org/api-ref/identity/v3/?expanded=validate-and-show-information-for-token-detail,list-role-assignments-detail#list-role-assignments
    params = {
      "links" => {
        "assignment" => "http://example.com/identity/v3/domains/161718/users/313233/roles/123456"
      },
      "role" => {
        "id" => "123456"
      },
      "scope" => {
        "project" => {
          "id" => "456789"
        }
      },
      "user" => {
        "id" => "313233"
      }
    }

    role_assignment = Yao::RoleAssignment.new(params)
    assert_equal({ "project" => { "id" => "456789" } }, role_assignment.scope)

    # map_attribute_to_resource
    assert_instance_of(Yao::Resources::Role, role_assignment.role)
    assert_equal("123456", role_assignment.role.id)

    # map_attribute_to_resource
    assert_instance_of(Yao::Resources::User, role_assignment.user)
    assert_equal("313233", role_assignment.user.id)
  end

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

    params = {
      "scope" => {
        "project" => {
          "id" => "456789"
        }
      },
    }

    role_assignment = Yao::RoleAssignment.new(params)
    assert_instance_of(Yao::Resources::Tenant, role_assignment.project)
    assert_equal("456789", role_assignment.project.id)

    assert_requested(stub)
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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