Renamed keystone_registration recipe

Renamed keystone_registration to identity_registration, and added
identity_registration tests.  Added registration tests to simply
test the args being passed to the `openstack_identity_register` LWRP.
The identity LWRP should be tested at a deeper level than the consumers.

Testing args passed to a DSL (&block) is a bit tricky. The tests
are not ideal, but give us the necessary coverage to catch common
errors.

Fixes: Bug 1182574
Change-Id: I4794e555133852cfbacd407dc726c6b65ecdef65
This commit is contained in:
John Dewey
2013-05-21 16:28:18 -07:00
parent d17c345fde
commit 297c8b1c51
11 changed files with 184 additions and 31 deletions

View File

@@ -0,0 +1,146 @@
require "spec_helper"
describe "openstack-block-storage::identity_registration" do
before do
@identity_register_mock = Class.new do
def auth_uri(uri); end
def bootstrap_token(token); end
def service_name(name); end
def service_type(type); end
def service_description(desc); end
def endpoint_region(region); end
def endpoint_adminurl(url); end
def endpoint_internalurl(url); end
def endpoint_publicurl(url); end
def tenant_name(name); end
def user_name(user); end
def user_pass(pass); end
def user_enabled(enabled); end
def role_name(name); end
def action(action); end
end.new
end
it "registers cinder volume service" do
block_storage_stubs
::Chef::Recipe.any_instance.stub(:openstack_identity_register)
::Chef::Recipe.any_instance.should_receive(:openstack_identity_register).
with("Register Cinder Volume Service") do |&arg|
@identity_register_mock.should_receive(:auth_uri).
with "https://127.0.0.1:35357/v2.0"
@identity_register_mock.should_receive(:bootstrap_token).
with "bootstrap-token"
@identity_register_mock.should_receive(:service_name).
with "cinder"
@identity_register_mock.should_receive(:service_type).
with "volume"
@identity_register_mock.should_receive(:service_description).
with "Cinder Volume Service"
@identity_register_mock.should_receive(:endpoint_region).
with "RegionOne"
@identity_register_mock.should_receive(:endpoint_adminurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:endpoint_internalurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:endpoint_publicurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:action).
with :create_service
@identity_register_mock.instance_eval &arg
end
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
chef_run.converge "openstack-block-storage::identity_registration"
end
it "registers cinder volume endpoint" do
block_storage_stubs
::Chef::Recipe.any_instance.stub(:openstack_identity_register)
::Chef::Recipe.any_instance.should_receive(:openstack_identity_register).
with("Register Cinder Volume Endpoint") do |&arg|
@identity_register_mock.should_receive(:auth_uri).
with "https://127.0.0.1:35357/v2.0"
@identity_register_mock.should_receive(:bootstrap_token).
with "bootstrap-token"
@identity_register_mock.should_receive(:service_name).
with "cinder"
@identity_register_mock.should_receive(:service_type).
with "volume"
@identity_register_mock.should_receive(:service_description).
with "Cinder Volume Service"
@identity_register_mock.should_receive(:endpoint_region).
with "RegionOne"
@identity_register_mock.should_receive(:endpoint_adminurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:endpoint_internalurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:endpoint_publicurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:action).
with :create_endpoint
@identity_register_mock.instance_eval &arg
end
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
chef_run.converge "openstack-block-storage::identity_registration"
end
it "registers service user" do
block_storage_stubs
::Chef::Recipe.any_instance.stub(:openstack_identity_register)
::Chef::Recipe.any_instance.should_receive(:openstack_identity_register).
with("Register Cinder Service User") do |&arg|
@identity_register_mock.should_receive(:auth_uri).
with "https://127.0.0.1:35357/v2.0"
@identity_register_mock.should_receive(:bootstrap_token).
with "bootstrap-token"
@identity_register_mock.should_receive(:tenant_name).
with "service"
@identity_register_mock.should_receive(:user_name).
with "cinder"
@identity_register_mock.should_receive(:user_pass).
with "cinder-pass"
@identity_register_mock.should_receive(:user_enabled).
with "true"
@identity_register_mock.should_receive(:action).
with :create_user
@identity_register_mock.instance_eval &arg
end
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
chef_run.converge "openstack-block-storage::identity_registration"
end
it "grants admin role to service user for service tenant" do
block_storage_stubs
::Chef::Recipe.any_instance.stub(:openstack_identity_register)
::Chef::Recipe.any_instance.should_receive(:openstack_identity_register).
with("Grant service Role to Cinder Service User for Cinder Service Tenant") do |&arg|
@identity_register_mock.should_receive(:auth_uri).
with "https://127.0.0.1:35357/v2.0"
@identity_register_mock.should_receive(:bootstrap_token).
with "bootstrap-token"
@identity_register_mock.should_receive(:tenant_name).
with "service"
@identity_register_mock.should_receive(:user_name).
with "cinder"
@identity_register_mock.should_receive(:role_name).
with "admin"
@identity_register_mock.should_receive(:action).
with :grant_role
@identity_register_mock.instance_eval &arg
end
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
chef_run.converge "openstack-block-storage::identity_registration"
end
end