refactor specs to improve speed and maintenance

use of `let()', shared_context, and removal of instance vars, etc.

Change-Id: Ie598d312d1a2d79db43793dd90b346618a6804f5
Implements: blueprint refactor-spec-files
This commit is contained in:
invsblduck
2014-01-28 14:30:13 -08:00
parent 1c63bfdaf5
commit 63b9342999
7 changed files with 173 additions and 244 deletions

View File

@@ -27,11 +27,15 @@ end
identity_admin_endpoint = endpoint 'identity-admin'
identity_endpoint = endpoint 'identity-api'
auth_uri = ::URI.decode identity_admin_endpoint.to_s
# FIXME(invsblduck): RuboCop gating was enabled mid-review;
# Remove these variables in a separate commit if really not needed.
# rubocop:disable UselessAssignment
admin_tenant_name = node['openstack']['identity']['admin_tenant_name']
admin_user = node['openstack']['identity']['admin_user']
admin_pass = get_password 'user', node['openstack']['identity']['admin_user']
auth_uri = ::URI.decode identity_admin_endpoint.to_s
# rubocop:enable UselessAssignment
bootstrap_token = secret 'secrets', 'openstack_identity_bootstrap_token'

View File

@@ -1,7 +0,0 @@
# encoding: UTF-8
#
require_relative 'spec_helper'
describe 'openstack-identity::default' do
end

View File

@@ -4,17 +4,12 @@
require_relative 'spec_helper'
describe 'openstack-identity::registration' do
before { identity_stubs }
describe 'ubuntu' do
let(:chef_run) do
runner = ::ChefSpec::Runner.new ::UBUNTU_OPTS
runner.converge 'openstack-identity::registration'
end
let(:chef_run_test_users) do
runner = ::ChefSpec::Runner.new ::UBUNTU_OPTS
runner.node.set['openstack']['identity']['users'] = {
let(:node) { runner.node }
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
let(:chef_run) { runner.converge(described_recipe) }
let(:node_add_user) do
node.set_unless['openstack']['identity']['users'] = {
'user1' => {
'default_tenant' => 'default_tenant1',
'password' => 'secret1',
@@ -22,11 +17,12 @@ describe 'openstack-identity::registration' do
'role1' => ['role_tenant1'],
'role2' => ['default_tenant1']
}
},
}
}
runner.converge 'openstack-identity::registration'
end
include_context 'identity_stubs'
describe 'tenant registration' do
context 'default tenants' do
['admin', 'service'].each do |tenant_name|
@@ -48,11 +44,10 @@ describe 'openstack-identity::registration' do
end
context 'configured tenants from users attribute' do
tenants = ['default_tenant1', 'role_tenant1']
tenants.each do |tenant_name|
before { node_add_user }
['default_tenant1', 'role_tenant1'].each do |tenant_name|
it "registers the #{tenant_name} tenant" do
resource = chef_run_test_users.find_resource(
resource = chef_run.find_resource(
'openstack-identity_register',
"Register '#{tenant_name}' Tenant"
).to_hash
@@ -89,12 +84,11 @@ describe 'openstack-identity::registration' do
end
context 'configured roles derived from users attribute' do
before { node_add_user }
roles = ['role1', 'role2']
roles.each do |role_name|
['role1', 'role2'].each do |role_name|
it "registers the #{role_name} role" do
resource = chef_run_test_users.find_resource(
resource = chef_run.find_resource(
'openstack-identity_register',
"Register '#{role_name}' Role"
).to_hash
@@ -112,10 +106,13 @@ describe 'openstack-identity::registration' do
describe 'user registration' do
context 'default users' do
[
['admin', 'admin', ['admin', 'KeystoneAdmin', 'KeystoneServiceAdmin']],
['monitoring', 'service', ['Member']]
].each do |user, tenant, roles|
user_monit = ['monitoring', 'service', ['Member']]
user_admin = [
'admin', 'admin',
['admin', 'KeystoneAdmin', 'KeystoneServiceAdmin']
]
[user_monit, user_admin].each do |user, tenant, roles|
context "#{user} user" do
it "registers the #{user} user" do
user_resource = chef_run.find_resource(
@@ -150,13 +147,16 @@ describe 'openstack-identity::registration' do
)
end
end
end
end
end
context 'configured user' do
before { node_add_user }
it 'registers the user1 user' do
resource = chef_run_test_users.find_resource(
resource = chef_run.find_resource(
'openstack-identity_register',
"Register 'user1' User"
).to_hash
@@ -172,7 +172,7 @@ describe 'openstack-identity::registration' do
end
it "grants 'role1' role to 'user1' user in 'role_tenant1' tenant" do
grant_resource = chef_run_test_users.find_resource(
grant_resource = chef_run.find_resource(
'openstack-identity_register',
"Grant 'role1' Role to 'user1' User in 'role_tenant1' Tenant"
).to_hash

View File

@@ -4,83 +4,68 @@
require_relative 'spec_helper'
describe 'openstack-identity::server' do
before { identity_stubs }
describe 'suse' do
before do
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
@chef_run.converge 'openstack-identity::server'
end
let(:runner) { ChefSpec::Runner.new(OPENSUSE_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'identity_stubs'
it 'converges when configured to use sqlite db backend' do
chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
node = chef_run.node
node.set['openstack']['db']['identity']['service_type'] = 'sqlite'
chef_run.converge 'openstack-identity::server'
expect { chef_run }.to_not raise_error
end
it 'installs mysql python packages' do
expect(@chef_run).to install_package 'python-mysql'
expect(chef_run).to install_package('python-mysql')
end
it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
n.set['openstack']['db']['identity']['service_type'] = 'postgresql'
end
chef_run.converge 'openstack-identity::server'
expect(chef_run).to install_package 'python-psycopg2'
node.set['openstack']['db']['identity']['service_type'] = 'postgresql'
expect(chef_run).to install_package('python-psycopg2')
end
it 'installs memcache python packages' do
expect(@chef_run).to install_package 'python-python-memcached'
expect(chef_run).to install_package('python-python-memcached')
end
it 'installs keystone packages' do
expect(@chef_run).to upgrade_package 'openstack-keystone'
expect(chef_run).to upgrade_package('openstack-keystone')
end
it 'starts keystone on boot' do
expect(@chef_run).to enable_service('openstack-keystone')
expect(chef_run).to enable_service('openstack-keystone')
end
describe '/etc/keystone' do
before do
@dir = @chef_run.directory '/etc/keystone'
end
let(:dir) { chef_run.directory('/etc/keystone') }
it 'has proper owner' do
expect(@dir.owner).to eq('openstack-keystone')
expect(@dir.group).to eq('openstack-keystone')
expect(dir.owner).to eq('openstack-keystone')
expect(dir.group).to eq('openstack-keystone')
end
end
describe '/etc/keystone/ssl' do
before do
chef_run = ::ChefSpec::Runner.new(::OPENSUSE_OPTS) do |n|
n.set['openstack']['auth']['strategy'] = 'pki'
end
chef_run.converge 'openstack-identity::server'
@dir = chef_run.directory '/etc/keystone/ssl'
end
before { node.set['openstack']['auth']['strategy'] = 'pki' }
let(:dir) { chef_run.directory('/etc/keystone/ssl') }
it 'has proper owner' do
expect(@dir.owner).to eq('openstack-keystone')
expect(@dir.group).to eq('openstack-keystone')
expect(dir.owner).to eq('openstack-keystone')
expect(dir.group).to eq('openstack-keystone')
end
end
it 'deletes keystone.db' do
expect(@chef_run).to delete_file '/var/lib/keystone/keystone.db'
expect(chef_run).to delete_file('/var/lib/keystone/keystone.db')
end
describe 'keystone.conf' do
before do
@template = @chef_run.template '/etc/keystone/keystone.conf'
end
let(:template) { chef_run.template '/etc/keystone/keystone.conf' }
it 'has proper owner' do
expect(@template.owner).to eq('openstack-keystone')
expect(@template.group).to eq('openstack-keystone')
expect(template.owner).to eq('openstack-keystone')
expect(template.group).to eq('openstack-keystone')
end
it 'template contents' do
@@ -90,17 +75,15 @@ describe 'openstack-identity::server' do
describe 'default_catalog.templates' do
before do
chef_run = ::ChefSpec::Runner.new(::OPENSUSE_OPTS) do |n|
n.set['openstack']['identity']['catalog']['backend'] = 'templated'
end
chef_run.converge 'openstack-identity::server'
@template = chef_run.template(
'/etc/keystone/default_catalog.templates')
node.set['openstack']['identity']['catalog']['backend'] = 'templated'
end
let(:template) do
chef_run.template('/etc/keystone/default_catalog.templates')
end
it 'has proper owner' do
expect(@template.owner).to eq('openstack-keystone')
expect(@template.group).to eq('openstack-keystone')
expect(template.owner).to eq('openstack-keystone')
expect(template.group).to eq('openstack-keystone')
end
it 'template contents' do

View File

@@ -4,54 +4,45 @@
require_relative 'spec_helper'
describe 'openstack-identity::server' do
before { identity_stubs }
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge 'openstack-identity::server'
end
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'identity_stubs'
it 'converges when configured to use sqlite db backend' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node
node.set['openstack']['db']['identity']['service_type'] = 'sqlite'
chef_run.converge 'openstack-identity::server'
expect { chef_run }.to_not raise_error
end
it 'installs mysql python packages' do
expect(@chef_run).to install_package 'MySQL-python'
expect(chef_run).to install_package('MySQL-python')
end
it 'installs db2 python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set['openstack']['db']['identity']['service_type'] = 'db2'
end
chef_run.converge 'openstack-identity::server'
node.set['openstack']['db']['identity']['service_type'] = 'db2'
['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
expect(chef_run).to install_package pkg
expect(chef_run).to install_package(pkg)
end
end
it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set['openstack']['db']['identity']['service_type'] = 'postgresql'
end
chef_run.converge 'openstack-identity::server'
expect(chef_run).to install_package 'python-psycopg2'
node.set['openstack']['db']['identity']['service_type'] = 'postgresql'
expect(chef_run).to install_package('python-psycopg2')
end
it 'installs memcache python packages' do
expect(@chef_run).to install_package 'python-memcached'
expect(chef_run).to install_package('python-memcached')
end
it 'installs keystone packages' do
expect(@chef_run).to upgrade_package 'openstack-keystone'
expect(chef_run).to upgrade_package('openstack-keystone')
end
it 'starts keystone on boot' do
expect(@chef_run).to enable_service('openstack-keystone')
expect(chef_run).to enable_service('openstack-keystone')
end
end
end

View File

@@ -4,145 +4,122 @@
require_relative 'spec_helper'
describe 'openstack-identity::server' do
before { identity_stubs }
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set['openstack']['identity']['syslog']['use'] = true
n.set['openstack']['endpoints']['identity-api'] = {
'host' => '127.0.1.1',
'port' => '5000',
'scheme' => 'https'
}
n.set['openstack']['endpoints']['identity-admin'] = {
'host' => '127.0.1.1',
'port' => '35357',
'scheme' => 'https'
}
end
@chef_run.converge 'openstack-identity::server'
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) do
node.set_unless['openstack']['endpoints']['identity-api'] = {
'host' => '127.0.1.1',
'port' => '5000',
'scheme' => 'https'
}
node.set_unless['openstack']['endpoints']['identity-admin'] = {
'host' => '127.0.1.1',
'port' => '35357',
'scheme' => 'https'
}
runner.converge(described_recipe)
end
include_context 'identity_stubs'
it 'runs logging recipe if node attributes say to' do
expect(@chef_run).to include_recipe 'openstack-common::logging'
node.set['openstack']['identity']['syslog']['use'] = true
expect(chef_run).to include_recipe('openstack-common::logging')
end
it 'does not run logging recipe' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
chef_run.converge 'openstack-identity::server'
expect(chef_run).not_to include_recipe 'openstack-common::logging'
expect(chef_run).not_to include_recipe('openstack-common::logging')
end
it 'converges when configured to use sqlite db backend' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set['openstack']['db']['identity']['service_type'] = 'sqlite'
chef_run.converge 'openstack-identity::server'
expect { chef_run }.to_not raise_error
end
it 'installs mysql python packages' do
expect(@chef_run).to install_package 'python-mysqldb'
expect(chef_run).to install_package('python-mysqldb')
end
it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set['openstack']['db']['identity']['service_type'] = 'postgresql'
chef_run.converge 'openstack-identity::server'
expect(chef_run).to install_package 'python-psycopg2'
expect(chef_run).to install_package('python-psycopg2')
end
it 'installs memcache python packages' do
expect(@chef_run).to install_package 'python-memcache'
expect(chef_run).to install_package('python-memcache')
end
it 'installs keystone packages' do
expect(@chef_run).to upgrade_package 'keystone'
expect(chef_run).to upgrade_package('keystone')
end
it 'starts keystone on boot' do
expect(@chef_run).to enable_service('keystone')
expect(chef_run).to enable_service('keystone')
end
it 'sleep on keystone service enable' do
expect(@chef_run.service('keystone')).to notify(
expect(chef_run.service('keystone')).to notify(
'execute[Keystone: sleep]').to(:run)
end
describe '/etc/keystone' do
before do
@dir = @chef_run.directory '/etc/keystone'
end
let(:dir) { chef_run.directory('/etc/keystone') }
it 'has proper owner' do
expect(@dir.owner).to eq('keystone')
expect(@dir.group).to eq('keystone')
expect(dir.owner).to eq('keystone')
expect(dir.group).to eq('keystone')
end
it 'has proper modes' do
expect(sprintf('%o', @dir.mode)).to eq '700'
expect(sprintf('%o', dir.mode)).to eq('700')
end
end
describe '/etc/keystone/ssl' do
before { @dir = '/etc/keystone/ssl' }
let(:ssl_dir) { '/etc/keystone/ssl' }
describe 'without pki' do
it 'does not create' do
chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS)
chef_run.converge 'openstack-identity::server'
expect(chef_run).not_to create_directory @dir
expect(chef_run).not_to create_directory(ssl_dir)
end
end
describe 'with pki' do
before do
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set['openstack']['auth']['strategy'] = 'pki'
end
@chef_run.converge 'openstack-identity::server'
@directory = @chef_run.directory @dir
end
before { node.set['openstack']['auth']['strategy'] = 'pki' }
let(:dir_resource) { chef_run.directory(ssl_dir) }
it 'creates' do
expect(@chef_run).to create_directory @directory.name
expect(chef_run).to create_directory(ssl_dir)
end
it 'has proper owner' do
expect(@directory.owner).to eq('keystone')
expect(@directory.group).to eq('keystone')
expect(dir_resource.owner).to eq('keystone')
expect(dir_resource.group).to eq('keystone')
end
it 'has proper modes' do
expect(sprintf('%o', @directory.mode)).to eq '700'
expect(sprintf('%o', dir_resource.mode)).to eq('700')
end
end
end
it 'deletes keystone.db' do
expect(@chef_run).to delete_file '/var/lib/keystone/keystone.db'
expect(chef_run).to delete_file('/var/lib/keystone/keystone.db')
end
it 'does not delete keystone.db when configured to use sqlite' do
chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS)
node = chef_run.node
node.set['openstack']['db']['identity']['service_type'] = 'sqlite'
chef_run.converge 'openstack-identity::server'
expect(chef_run).not_to delete_file '/var/lib/keystone/keystone.db'
expect(chef_run).not_to delete_file('/var/lib/keystone/keystone.db')
end
describe 'pki setup' do
before { @cmd = 'keystone-manage pki_setup' }
let(:cmd) { 'keystone-manage pki_setup' }
describe 'without pki' do
it 'does not execute' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
chef_run.converge 'openstack-identity::server'
expect(chef_run).to_not run_execute(@cmd).with(
expect(chef_run).to_not run_execute(cmd).with(
user: 'keystone',
group: 'keystone'
)
@@ -150,19 +127,14 @@ describe 'openstack-identity::server' do
end
describe 'with pki' do
before do
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set['openstack']['auth']['strategy'] = 'pki'
end
end
before { node.set['openstack']['auth']['strategy'] = 'pki' }
it 'executes' do
::FileTest.should_receive(:exists?)
.with('/etc/keystone/ssl/private/signing_key.pem')
.and_return(false)
@chef_run.converge 'openstack-identity::server'
expect(@chef_run).to run_execute(@cmd).with(
expect(chef_run).to run_execute(cmd).with(
user: 'keystone',
group: 'keystone'
)
@@ -172,9 +144,8 @@ describe 'openstack-identity::server' do
::FileTest.should_receive(:exists?)
.with('/etc/keystone/ssl/private/signing_key.pem')
.and_return(true)
@chef_run.converge 'openstack-identity::server'
expect(@chef_run).not_to run_execute(@cmd).with(
expect(chef_run).not_to run_execute(cmd).with(
user: 'keystone',
group: 'keystone'
)
@@ -183,40 +154,38 @@ describe 'openstack-identity::server' do
end
describe 'keystone.conf' do
before do
@template = @chef_run.template '/etc/keystone/keystone.conf'
end
let(:template) { chef_run.template '/etc/keystone/keystone.conf' }
it 'has proper owner' do
expect(@template.owner).to eq('keystone')
expect(@template.group).to eq('keystone')
expect(template.owner).to eq('keystone')
expect(template.group).to eq('keystone')
end
it 'has proper modes' do
expect(sprintf('%o', @template.mode)).to eq '644'
expect(sprintf('%o', template.mode)).to eq('644')
end
it 'has bind host' do
match = 'bind_host = 127.0.1.1'
expect(@chef_run).to render_file(@template.name).with_content(match)
expect(chef_run).to render_file(template.name).with_content(match)
end
it 'has proper public and admin endpoint' do
pub_endpoint = 'public_endpoint = https://127.0.1.1:5000/'
adm_endpoint = 'admin_endpoint = https://127.0.1.1:35357/'
expect(@chef_run).to render_file(@template.name).with_content(
expect(chef_run).to render_file(template.name).with_content(
pub_endpoint)
expect(@chef_run).to render_file(@template.name).with_content(
expect(chef_run).to render_file(template.name).with_content(
adm_endpoint)
end
it 'has policy driver' do
match = 'driver = keystone.policy.backends.sql.Policy'
expect(@chef_run).to render_file(@template.name).with_content(
match)
expect(chef_run).to render_file(template.name).with_content(match)
end
it 'notifies keystone restart' do
expect(@template).to notify('service[keystone]').to(:restart)
expect(template).to notify('service[keystone]').to(:restart)
end
describe 'optional LDAP attributes' do
@@ -229,12 +198,12 @@ describe 'openstack-identity::server' do
optional_attrs.each do |setting|
it "does not have the optional #{setting} LDAP attribute" do
expect(@chef_run).not_to render_file(@template.name).with_content(
expect(chef_run).not_to render_file(template.name).with_content(
/^#{Regexp.quote(setting)} =/)
end
it "has the optional #{setting} LDAP attribute commented out" do
expect(@chef_run).to render_file(@template.name).with_content(
expect(chef_run).to render_file(template.name).with_content(
/^# #{Regexp.quote(setting)} =$/)
end
end
@@ -264,44 +233,38 @@ describe 'openstack-identity::server' do
group_allow_update group_allow_delete
}.each do |setting|
it "has a #{setting} LDAP attribute" do
expect(@chef_run).to render_file(@template.name).with_content(
expect(chef_run).to render_file(template.name).with_content(
/^#{Regexp.quote(setting)} = \w+/)
end
end
end
describe 'default_catalog.templates' do
before { @file = '/etc/keystone/default_catalog.templates' }
let(:file) { '/etc/keystone/default_catalog.templates' }
describe 'without templated' do
it 'does not create' do
chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS)
chef_run.converge 'openstack-identity::server'
expect(chef_run).not_to render_file(@file)
expect(chef_run).not_to render_file(file)
end
end
describe 'with templated' do
before do
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set['openstack']['identity']['catalog']['backend'] = 'templated'
end
@chef_run.converge 'openstack-identity::server'
@template = @chef_run.template @file
node.set['openstack']['identity']['catalog']['backend'] = 'templated'
end
let(:template) { chef_run.template(file) }
it 'creates' do
expect(@chef_run).to render_file(@file)
expect(chef_run).to render_file(file)
end
it 'has proper owner' do
expect(@template.owner).to eq('keystone')
expect(@template.group).to eq('keystone')
expect(template.owner).to eq('keystone')
expect(template.group).to eq('keystone')
end
it 'has proper modes' do
expect(sprintf('%o', @template.mode)).to eq '644'
expect(sprintf('%o', template.mode)).to eq('644')
end
it 'template contents' do
@@ -309,30 +272,24 @@ describe 'openstack-identity::server' do
end
it 'notifies keystone restart' do
expect(@template).to notify('service[keystone]').to(:restart)
expect(template).to notify('service[keystone]').to(:restart)
end
end
end
describe 'db_sync' do
before do
@cmd = 'keystone-manage db_sync'
end
let(:cmd) { 'keystone-manage db_sync' }
it 'runs migrations' do
expect(@chef_run).to run_execute(@cmd).with(
expect(chef_run).to run_execute(cmd).with(
user: 'keystone',
group: 'keystone'
)
)
end
it 'does not run migrations' do
chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set['openstack']['db']['identity']['migrate'] = false
end
chef_run.converge 'openstack-identity::server'
expect(chef_run).not_to run_execute(@cmd).with(
node.set['openstack']['db']['identity']['migrate'] = false
expect(chef_run).not_to run_execute(cmd).with(
user: 'keystone',
group: 'keystone'
)

View File

@@ -4,39 +4,40 @@
require 'chefspec'
require 'chefspec/berkshelf'
::LOG_LEVEL = :fatal
::OPENSUSE_OPTS = {
LOG_LEVEL = :fatal
OPENSUSE_OPTS = {
platform: 'opensuse',
version: '12.3',
log_level: ::LOG_LEVEL
log_level: LOG_LEVEL
}
::REDHAT_OPTS = {
REDHAT_OPTS = {
platform: 'redhat',
version: '6.3',
log_level: ::LOG_LEVEL
log_level: LOG_LEVEL
}
::UBUNTU_OPTS = {
UBUNTU_OPTS = {
platform: 'ubuntu',
version: '12.04',
log_level: ::LOG_LEVEL
log_level: LOG_LEVEL
}
# TODO(galstrom21): Factor this into proper RSpec shared_contexts
def identity_stubs # rubocop: disable MethodLength
::Chef::Recipe.any_instance.stub(:address_for)
.with('lo')
.and_return('127.0.1.1')
::Chef::Recipe.any_instance.stub(:memcached_servers).and_return []
::Chef::Recipe.any_instance.stub(:get_password)
.with('db', anything)
.and_return('')
::Chef::Recipe.any_instance.stub(:get_password)
.with('user', anything)
.and_return('')
::Chef::Recipe.any_instance.stub(:get_password)
.with('user', 'user1')
.and_return('secret1')
::Chef::Recipe.any_instance.stub(:secret)
.with('secrets', 'openstack_identity_bootstrap_token')
.and_return('bootstrap-token')
shared_context 'identity_stubs' do
before do
::Chef::Recipe.any_instance.stub(:address_for)
.with('lo')
.and_return('127.0.1.1')
::Chef::Recipe.any_instance.stub(:memcached_servers).and_return []
::Chef::Recipe.any_instance.stub(:get_password)
.with('db', anything)
.and_return('')
::Chef::Recipe.any_instance.stub(:get_password)
.with('user', anything)
.and_return('')
::Chef::Recipe.any_instance.stub(:get_password)
.with('user', 'user1')
.and_return('secret1')
::Chef::Recipe.any_instance.stub(:secret)
.with('secrets', 'openstack_identity_bootstrap_token')
.and_return('bootstrap-token')
end
end