Merge "Prevent dollar signs and single quotes in variables from being removed by shell"

This commit is contained in:
Jenkins 2013-10-30 00:53:37 +00:00 committed by Gerrit Code Review
commit b78839e718
2 changed files with 58 additions and 40 deletions

View File

@ -10,18 +10,18 @@ describe 'openstack::auth_file' do
it 'should create a openrc file' do
verify_contents(subject, '/root/openrc', [
'export OS_NO_CACHE=true',
'export OS_TENANT_NAME=openstack',
'export OS_USERNAME=admin',
'export OS_PASSWORD=admin',
'export OS_AUTH_URL=http://127.0.0.1:5000/v2.0/',
'export OS_AUTH_STRATEGY=keystone',
'export OS_REGION_NAME=RegionOne',
'export CINDER_ENDPOINT_TYPE=publicURL',
'export GLANCE_ENDPOINT_TYPE=publicURL',
'export KEYSTONE_ENDPOINT_TYPE=publicURL',
'export NOVA_ENDPOINT_TYPE=publicURL',
'export NEUTRON_ENDPOINT_TYPE=publicURL'
'export OS_NO_CACHE=\'true\'',
'export OS_TENANT_NAME=\'openstack\'',
'export OS_USERNAME=\'admin\'',
'export OS_PASSWORD=\'admin\'',
'export OS_AUTH_URL=\'http://127.0.0.1:5000/v2.0/\'',
'export OS_AUTH_STRATEGY=\'keystone\'',
'export OS_REGION_NAME=\'RegionOne\'',
'export CINDER_ENDPOINT_TYPE=\'publicURL\'',
'export GLANCE_ENDPOINT_TYPE=\'publicURL\'',
'export KEYSTONE_ENDPOINT_TYPE=\'publicURL\'',
'export NOVA_ENDPOINT_TYPE=\'publicURL\'',
'export NEUTRON_ENDPOINT_TYPE=\'publicURL\''
])
end
end
@ -44,21 +44,39 @@ describe 'openstack::auth_file' do
it 'should create a openrc file' do
verify_contents(subject, '/root/openrc', [
'export OS_SERVICE_TOKEN=keystone',
'export OS_SERVICE_ENDPOINT=http://127.0.0.2:35357/v2.0/',
'export OS_NO_CACHE=true',
'export OS_TENANT_NAME=admin',
'export OS_USERNAME=admin',
'export OS_PASSWORD=admin',
'export OS_AUTH_URL=http://127.0.0.2:5000/v2.0/',
'export OS_AUTH_STRATEGY=keystone',
'export OS_REGION_NAME=RegionOne',
'export CINDER_ENDPOINT_TYPE=privateURL',
'export GLANCE_ENDPOINT_TYPE=privateURL',
'export KEYSTONE_ENDPOINT_TYPE=privateURL',
'export NOVA_ENDPOINT_TYPE=privateURL',
'export NEUTRON_ENDPOINT_TYPE=privateURL'
'export OS_SERVICE_TOKEN=\'keystone\'',
'export OS_SERVICE_ENDPOINT=\'http://127.0.0.2:35357/v2.0/\'',
'export OS_NO_CACHE=\'true\'',
'export OS_TENANT_NAME=\'admin\'',
'export OS_USERNAME=\'admin\'',
'export OS_PASSWORD=\'admin\'',
'export OS_AUTH_URL=\'http://127.0.0.2:5000/v2.0/\'',
'export OS_AUTH_STRATEGY=\'keystone\'',
'export OS_REGION_NAME=\'RegionOne\'',
'export CINDER_ENDPOINT_TYPE=\'privateURL\'',
'export GLANCE_ENDPOINT_TYPE=\'privateURL\'',
'export KEYSTONE_ENDPOINT_TYPE=\'privateURL\'',
'export NOVA_ENDPOINT_TYPE=\'privateURL\'',
'export NEUTRON_ENDPOINT_TYPE=\'privateURL\''
])
end
end
describe "handle password and token with single quotes" do
let :params do
{
:admin_password => 'singlequote\'',
:keystone_admin_token => 'key\'stone'
}
end
it 'should create a openrc file' do
verify_contents(subject, '/root/openrc', [
'export OS_SERVICE_TOKEN=\'key\\\'stone\'',
'export OS_PASSWORD=\'singlequote\\\'\'',
])
end
end
end

View File

@ -1,17 +1,17 @@
#!/bin/sh
<% if @keystone_admin_token -%>
export OS_SERVICE_TOKEN=<%= @keystone_admin_token %>
export OS_SERVICE_ENDPOINT=http://<%= @controller_node %>:35357/v2.0/
export OS_SERVICE_TOKEN='<%= @keystone_admin_token.gsub(/'/){ %q(\') } %>'
export OS_SERVICE_ENDPOINT='http://<%= @controller_node %>:35357/v2.0/'
<% end -%>
export OS_NO_CACHE=<%= @use_no_cache %>
export OS_TENANT_NAME=<%= @admin_tenant %>
export OS_USERNAME=<%= @admin_user %>
export OS_PASSWORD=<%= @admin_password %>
export OS_AUTH_URL=http://<%= @controller_node %>:5000/v2.0/
export OS_AUTH_STRATEGY=keystone
export OS_REGION_NAME=<%= @region_name %>
export CINDER_ENDPOINT_TYPE=<%= @cinder_endpoint_type %>
export GLANCE_ENDPOINT_TYPE=<%= @glance_endpoint_type %>
export KEYSTONE_ENDPOINT_TYPE=<%= @keystone_endpoint_type %>
export NOVA_ENDPOINT_TYPE=<%= @nova_endpoint_type %>
export NEUTRON_ENDPOINT_TYPE=<%= @neutron_endpoint_type %>
export OS_NO_CACHE='<%= @use_no_cache %>'
export OS_TENANT_NAME='<%= @admin_tenant %>'
export OS_USERNAME='<%= @admin_user %>'
export OS_PASSWORD='<%= @admin_password.gsub(/'/){ %q(\') } %>'
export OS_AUTH_URL='http://<%= @controller_node %>:5000/v2.0/'
export OS_AUTH_STRATEGY='keystone'
export OS_REGION_NAME='<%= @region_name %>'
export CINDER_ENDPOINT_TYPE='<%= @cinder_endpoint_type %>'
export GLANCE_ENDPOINT_TYPE='<%= @glance_endpoint_type %>'
export KEYSTONE_ENDPOINT_TYPE='<%= @keystone_endpoint_type %>'
export NOVA_ENDPOINT_TYPE='<%= @nova_endpoint_type %>'
export NEUTRON_ENDPOINT_TYPE='<%= @neutron_endpoint_type %>'