test/yao/resources/test_role.rb in yao-0.13.0 vs test/yao/resources/test_role.rb in yao-0.13.1
- old
+ new
@@ -58,11 +58,11 @@
assert_instance_of(Yao::Role, roles.first)
assert_equal("0123456789abcdef0123456789abcdef", roles.first.id)
assert_requested(stub)
end
-
+
def test_list_for_user
stub_user
stub_tenant
stub = stub_request(:get, "https://example.com:12345/v2.0/tenants/0123456789abcdef0123456789abcdef/users/2844b2a08be147a08ef58317d6471f1f/roles").
to_return(
@@ -75,15 +75,15 @@
}]
}
JSON
headers: {'Content-Type' => 'application/json'}
)
-
+
roles = Yao::Role.list_for_user("test_user", on:"admin")
assert_equal("0123456789abcdef0123456789abcdef", roles.first.id)
assert_received(Yao::User) { |subject| subject.get("test_user") }
- assert_received(Yao::Tenant) { |subject| subject.find_by_name("admin") }
+ assert_received(Yao::Tenant) { |subject| subject.get("admin") }
assert_requested(stub)
end
def test_grant
stub_role
@@ -97,11 +97,11 @@
)
Yao::Role.grant("test_role", to:"test_user", on:"admin")
assert_received(Yao::Role) { |subject| subject.get("test_role") }
assert_received(Yao::User) { |subject| subject.get("test_user") }
- assert_received(Yao::Tenant) { |subject| subject.find_by_name("admin") }
+ assert_received(Yao::Tenant) { |subject| subject.get("admin") }
assert_requested(stub)
end
def test_revoke
stub_role
@@ -115,11 +115,11 @@
)
Yao::Role.revoke("test_role", from:"test_user", on:"admin")
assert_received(Yao::Role) { |subject| subject.get("test_role") }
assert_received(Yao::User) { |subject| subject.get("test_user") }
- assert_received(Yao::Tenant) { |subject| subject.find_by_name("admin") }
+ assert_received(Yao::Tenant) { |subject| subject.get("admin") }
assert_requested(stub)
end
end
sub_test_case 'with keystone v3' do
@@ -170,11 +170,11 @@
assert_instance_of(Yao::Role, roles.first)
assert_equal("0123456789abcdef0123456789abcdef", roles.first.id)
assert_requested(stub)
end
-
+
def test_list_for_user
stub_user
stub_project
stub = stub_request(:get, "https://example.com:12345/v3/projects/0123456789abcdef0123456789abcdef/users/2844b2a08be147a08ef58317d6471f1f/roles").
to_return(
@@ -187,11 +187,11 @@
}]
}
JSON
headers: {'Content-Type' => 'application/json'}
)
-
+
roles = Yao::Role.list_for_user("test_user", on:"admin")
assert_equal("0123456789abcdef0123456789abcdef", roles.first.id)
assert_received(Yao::Resources::User) { |subject| subject.get("test_user") }
assert_received(Yao::Resources::Project) { |subject| subject.get("admin") }
assert_requested(stub)
@@ -247,12 +247,12 @@
stub(Yao::User).get { Yao::User.new({
"id" => "2844b2a08be147a08ef58317d6471f1f",
"name" => "test_user",
}) }
end
-
+
def stub_tenant
- stub(Yao::Tenant).find_by_name { Yao::Tenant.new({
+ stub(Yao::Tenant).get { Yao::Tenant.new({
"id" => "0123456789abcdef0123456789abcdef",
"name" => "admin",
}) }
end