[PATCH conductor 4/4] Adds tests for credentials in Provider Account XML

pblaho at redhat.com pblaho at redhat.com
Mon Jul 30 10:37:01 UTC 2012


From: Petr Blaho <pblaho at redhat.com>

https://www.aeolusproject.org/redmine/issues/3497

These spec only tests that all of the Credentials of Provider Account
will be in XML response.
---
 .../provider_accounts_controller_spec.rb           |   26 ++++++++++++++++++-
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/spec/controllers/provider_accounts_controller_spec.rb b/src/spec/controllers/provider_accounts_controller_spec.rb
index d1c8241..1f40c75 100644
--- a/src/spec/controllers/provider_accounts_controller_spec.rb
+++ b/src/spec/controllers/provider_accounts_controller_spec.rb
@@ -44,6 +44,16 @@ describe ProviderAccountsController do
     end
   end
 
+  shared_examples_for "having correct set of credentials" do
+    it "should be correct" do
+      provider_account.credentials.each do |credential|
+        label = credential.credential_definition.label
+        value = credential.value
+        xml_provider_account.xpath('//' + label).text.should be_eql(value)
+      end
+    end
+  end
+
   context "UI" do
 
     fixtures :all
@@ -264,6 +274,20 @@ describe ProviderAccountsController do
               it "should have correct provider account" do
                 xml_provider_account.xpath('@href').text.should be_eql(api_provider_account_url(provider_account))
               end
+              context "credentials" do
+
+                context "of mock provider" do
+                  let(:provider_account) { FactoryGirl.create(:mock_provider_account); ProviderAccount.last }
+
+                  it_behaves_like "having correct set of credentials"
+                end
+
+                context "of ec2 provider" do
+                  let(:provider_account) { FactoryGirl.create(:ec2_provider_account); ProviderAccount.last }
+
+                  it_behaves_like "having correct set of credentials"
+                end
+              end
             end
 
           end # when requested provider account exists
@@ -288,9 +312,7 @@ describe ProviderAccountsController do
                 subject.xpath('//error/code').text.should be_eql('RecordNotFound')
                 subject.xpath('//error/message').text.should be_eql("Couldn't find ProviderAccount with ID=1")
               }
-
             end
-
           end
         end # #show
       end
-- 
1.7.7.6




More information about the aeolus-devel mailing list