diff --git a/source/lib/vagrant-openstack-provider/config.rb b/source/lib/vagrant-openstack-provider/config.rb index c59dc10..48f2e43 100644 --- a/source/lib/vagrant-openstack-provider/config.rb +++ b/source/lib/vagrant-openstack-provider/config.rb @@ -320,8 +320,9 @@ def rsync_include(inc) def validate(machine) errors = _detected_errors - errors << I18n.t('vagrant_openstack.config.password_required') unless @password - errors << I18n.t('vagrant_openstack.config.username_required') unless @username + errors << I18n.t('vagrant_openstack.config.password_required') if @password.nil? || @password.empty? + errors << I18n.t('vagrant_openstack.config.username_required') if @username.nil? || @username.empty? + errors << I18n.t('vagrant_openstack.config.tenant_name_required') if @tenant_name.nil? || @tenant_name.empty? errors << I18n.t('vagrant_openstack.config.invalid_endpoint_type') unless %w(publicURL adminURL internalURL).include?(@endpoint_type) validate_ssh_username(machine, errors) diff --git a/source/locales/en.yml b/source/locales/en.yml index bee4331..bbda65d 100644 --- a/source/locales/en.yml +++ b/source/locales/en.yml @@ -89,6 +89,8 @@ en: A password is required. username_required: |- A username is required. + tenant_name_required: |- + A tenant name is required. invalid_uri: |- The value for %{key} is not a valid URI: %{uri} invalid_stack: |- diff --git a/source/spec/vagrant-openstack-provider/config_spec.rb b/source/spec/vagrant-openstack-provider/config_spec.rb index 06bb0e1..a191a20 100644 --- a/source/spec/vagrant-openstack-provider/config_spec.rb +++ b/source/spec/vagrant-openstack-provider/config_spec.rb @@ -222,6 +222,7 @@ machine.stub(:config) { config } subject.username = 'foo' subject.password = 'bar' + subject.tenant_name = 'tenant' subject.keypair_name = 'keypair' end @@ -299,7 +300,7 @@ end end - context 'the API key' do + context 'the password' do it 'should error if not given' do subject.password = nil I18n.should_receive(:t).with('vagrant_openstack.config.password_required').and_return error_message @@ -315,6 +316,14 @@ end end + context 'the tenant name' do + it 'should error if not given' do + subject.tenant_name = nil + I18n.should_receive(:t).with('vagrant_openstack.config.tenant_name_required').and_return error_message + validation_errors.first.should == error_message + end + end + context 'the ssh_timeout' do it 'should error if do not represent an integer' do subject.ssh_timeout = 'timeout'