require 'spec_helper' describe 'openstack_extras::auth_file' do shared_examples 'openstack_extras::auth_file' do context 'when only passing default class parameters' do let :params do { :password => 'admin' } end it { is_expected.to contain_file('/root/openrc').with( :ensure => 'file', :owner => 'root', :group => 'root', :mode => '0700', :show_diff => false, :tag => ['openrc'], :content => < 'admin', :auth_url => 'http://127.0.0.2:5000/v3/', :service_token => 'servicetoken', :service_endpoint => 'http://127.0.0.2:5000/v3/', :username => 'myuser', :project_name => 'myproject', :region_name => 'myregion', :use_no_cache => false, :os_interface => 'internal', :os_endpoint_type => 'internalURL', :cinder_endpoint_type => 'internalURL', :glance_endpoint_type => 'internalURL', :keystone_endpoint_type => 'internalURL', :nova_endpoint_type => 'internalURL', :neutron_endpoint_type => 'internalURL', :auth_strategy => 'no_auth', :path => '/path/to/file', :user_domain_name => 'anotherdomain', :project_domain_name => 'anotherdomain', :compute_api_version => '2.1', :network_api_version => '2.0', :image_api_version => '2', :volume_api_version => '2', :identity_api_version => '3.1', :object_api_version => '1', } end it { is_expected.to contain_file('/path/to/file').with( :ensure => 'file', :owner => 'root', :group => 'root', :mode => '0700', :show_diff => false, :tag => ['openrc'], :content => < 'singlequote\'', :service_token => 'key\'stone' } end it { is_expected.to contain_file('/root/openrc').with( :ensure => 'file', :owner => 'root', :group => 'root', :mode => '0700', :show_diff => false, :tag => ['openrc'], :content => < 'secret', :path => '/tmp/openrc' } end it { should contain_file('/tmp/openrc')} end end on_supported_os({ :supported_os => OSDefaults.get_supported_os }).each do |os,facts| context "on #{os}" do let (:facts) do facts.merge!(OSDefaults.get_facts()) end it_behaves_like 'openstack_extras::auth_file' end end end