[PATCH conductor] Bug 678390 - some failed provider acct field checks return blank page
by Richard Su
Check username and password are not blank before calling deltacloud validation.
---
src/app/models/provider_account.rb | 3 +++
src/spec/models/provider_account_spec.rb | 12 ++++++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/app/models/provider_account.rb b/src/app/models/provider_account.rb
index 33c7d2e..9858219 100644
--- a/src/app/models/provider_account.rb
+++ b/src/app/models/provider_account.rb
@@ -163,6 +163,9 @@ class ProviderAccount < ActiveRecord::Base
end
def valid_credentials?
+ if credentials_hash['username'].blank? || credentials_hash['password'].blank?
+ return false
+ end
DeltaCloud::valid_credentials?(credentials_hash['username'].to_s, credentials_hash['password'].to_s, provider.url)
end
diff --git a/src/spec/models/provider_account_spec.rb b/src/spec/models/provider_account_spec.rb
index 6845ed2..77ccb1e 100644
--- a/src/spec/models/provider_account_spec.rb
+++ b/src/spec/models/provider_account_spec.rb
@@ -23,6 +23,12 @@ describe ProviderAccount do
invalid_provider_account.credentials_hash = {'username' => "wrong_username", 'password' => "wrong_password"}
invalid_provider_account.should_not be_valid
+ ec2_provider = Factory :ec2_provider
+ invalid_ec2_provider_account = Factory.build(:ec2_provider_account, :provider => ec2_provider)
+ invalid_ec2_provider_account.credentials_hash = {'username' => "", 'password' => nil}
+ invalid_ec2_provider_account.valid_credentials?.should == false
+ invalid_ec2_provider_account.should_not be_valid
+
valid_provider_account = Factory.build(:mock_provider_account, :provider => mock_provider)
valid_provider_account.should be_valid
end
@@ -33,6 +39,12 @@ describe ProviderAccount do
provider_account.save.should == false
end
+ it "should fail to create a cloud account if the provider credentials are missing" do
+ provider_account = Factory.build(:mock_provider_account)
+ provider_account.credentials_hash = {'password' => nil}
+ provider_account.valid_credentials?.should == false
+ end
+
it "should create an instance_key if provider is EC2" do
@client = mock('Conductor', :null_object => true)
@provider = Factory.build :ec2_provider
--
1.7.4
13 years
Bugfox for 500 errors in connector log
by Jason Guiditta
If you are not seeing something to the effect of:
Error Received: #<Qmf2::Data:0x7f77ced19028 @schema=nil, @impl=#<Cqmf2::Data:0x7f77ced19078>>
in your connector log right after the logged debug message that starts with
"build method called with", this may be difficult to test. Everyone should be getting
this error right now, but that does not seem to be the case. If you get that error,
this fixes it, and tests that it works by removing a console method stub and running
the real call against factory. The stub is apparently why I did not see the error before.
[PATCH conductor] Bugfix: build and push always throw 500 errors
13 years