From: Jan Provaznik jprovazn@redhat.com
--- src/features/provider.feature | 54 +++++++++++++++++++++++ src/features/step_definitions/pool_steps.rb | 2 +- src/features/step_definitions/provider_steps.rb | 28 ++++++++++++ src/features/support/custom.rb | 15 ++++++- src/features/support/paths.rb | 17 +++++-- 5 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 src/features/provider.feature create mode 100644 src/features/step_definitions/provider_steps.rb
diff --git a/src/features/provider.feature b/src/features/provider.feature new file mode 100644 index 0000000..9c4aa52 --- /dev/null +++ b/src/features/provider.feature @@ -0,0 +1,54 @@ +Feature: Manage Providers + In order to manage my cloud infrastructure + As a user + I want to manage cloud providers + + Background: + Given I am an authorised user + And I am logged in + + Scenario: List providers + Given I am on the homepage + And there are these providers: + | name | + | provider1 | + | provider2 | + | provider3 | + When I follow "Settings" + Then I should see the following: + | provider1 | + | provider2 | + | provider3 | + + Scenario: Show provider details + Given there is a provider named "testprovider" + And I am on the settings page + When I follow "testprovider" + Then I should see "Accounts" + And I should see "Realms" + And I should see "User access" + And I should see "Settings" + + Scenario: Create a new Provider + Given I am on the settings page + And there is not a provider named "testprovider" + When I follow "Add a provider" + Then I should be on the new provider page + And I should see "Add a cloud provider" + When I fill in "provider[name]" with "testprovider" + And I fill in "provider[url]" with "http://localhost:3001/api" + And I press "Save" + Then I should be on the show provider page + And I should see "Provider added" + And I should have a provider named "testprovider" + + Scenario: Delete a provider + Given there is a provider named "testprovider" + And I am on the settings page + Then I should see "testprovider" + When I follow "testprovider" + Then I should be on the show provider page + When I follow provider settings link + Then I should be on the provider settings page + When I delete provider + Then I should be on the providers page diff --git a/src/features/step_definitions/pool_steps.rb b/src/features/step_definitions/pool_steps.rb index af0cba1..75de2e2 100644 --- a/src/features/step_definitions/pool_steps.rb +++ b/src/features/step_definitions/pool_steps.rb @@ -67,4 +67,4 @@ Given /^the Pool has a quota with following capacities:$/ do |table| @quota = Factory(:quota, quota_hash) @pool.quota_id = @quota.id @pool.save -end \ No newline at end of file +end diff --git a/src/features/step_definitions/provider_steps.rb b/src/features/step_definitions/provider_steps.rb new file mode 100644 index 0000000..e593d43 --- /dev/null +++ b/src/features/step_definitions/provider_steps.rb @@ -0,0 +1,28 @@ +Given /^there is not a provider named "([^"]*)"$/ do |name| + Provider.find_by_name(name).should be_nil +end + +Given /^there is a provider named "([^"]*)"$/ do |name| + @provider = Factory(:mock_provider, :name => name) +end + +Then /^I should have a provider named "([^"]*)"$/ do |name| + Provider.find_by_name(name).should_not be_nil +end + +When /^I follow provider settings link$/ do + within '#provider-tabs' do |scope| + scope.click_link "Settings" + end +end + +When /^I delete provider$/ do + click_button "Delete provider" +end + + +Given /^there are these providers:$/ do |table| + table.hashes.each do |hash| + Factory(:mock_provider, :name => hash['name']) + end +end diff --git a/src/features/support/custom.rb b/src/features/support/custom.rb index e8801ba..446aa89 100644 --- a/src/features/support/custom.rb +++ b/src/features/support/custom.rb @@ -11,10 +11,23 @@ Provider.class_eval do def valid_framework? true end + + def set_cloud_type + self.cloud_type = Factory(:mock_provider).cloud_type + end + + def populate_hardware_profiles + [[:mock_hwp1, :agg_hwp1], [:mock_hwp2, :agg_hwp2]].each do |mp_name, ap_name| + mock = Factory(mp_name, :provider_id => self.id) + agg_mock = Factory(ap_name, :external_key => self.name + Realm::AGGREGATOR_REALM_ACCOUNT_DELIMITER + mock.name) + agg_mock.provider_hardware_profiles << mock + end + return true + end end
CloudAccount.class_eval do def valid_credentials? true end -end \ No newline at end of file +end diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb index db20948..b7adf16 100644 --- a/src/features/support/paths.rb +++ b/src/features/support/paths.rb @@ -14,9 +14,6 @@ module NavigationHelpers when /the new account page/ register_path
- when /the provider list page/ - '/' - when /the login page/ login_path
@@ -29,8 +26,17 @@ module NavigationHelpers when /the login error page/ user_session_path
+ when /the providers page/ + url_for :controller => 'provider', :action => 'index', :only_path => true + when /the new provider page/ - new_provider_path + url_for :controller => 'provider', :action => 'new', :only_path => true + + when /the show provider page/ + url_for :controller => 'provider', :action => 'show', :only_path => true + + when /the provider settings page/ + url_for :controller => 'provider', :action => 'settings', :only_path => true
when /the new pool page/ new_pool_path @@ -50,6 +56,9 @@ module NavigationHelpers when /the pool hardware profiles page/ hardware_profiles_pool_path
+ when /the settings page/ + settings_path + # Add more mappings here. # Here is an example that pulls values out of the Regexp: #
deltacloud-devel@lists.fedorahosted.org