From: Jan Provaznik jprovazn@redhat.com
--- src/features/instance.feature | 4 +- src/features/realm.feature | 57 +++++++++++++++++++++++ src/features/step_definitions/instance_steps.rb | 4 +- src/features/step_definitions/realm_steps.rb | 28 +++++++++++ src/features/support/paths.rb | 3 + 5 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 src/features/realm.feature create mode 100644 src/features/step_definitions/realm_steps.rb
diff --git a/src/features/instance.feature b/src/features/instance.feature index 46081d5..cb561f4 100644 --- a/src/features/instance.feature +++ b/src/features/instance.feature @@ -38,7 +38,7 @@ Feature: Mange Instances Given there is an uploaded image for a template And I am on the instances page And there is "mock_profile" conductor hardware profile - And there is "mock_realm" conductor realm + And there is "mock_realm" frontend realm And there is "mock_pool" pool When I press "Create" Then I should see "Show Templates" @@ -47,7 +47,7 @@ Feature: Mange Instances When I fill in "instance_name" with "mock1" And I select "mock_profile" from "instance_hardware_profile_id" And I select "mock_pool" from "instance_pool_id" - And I select "mock_realm" from "instance_realm_id" + And I select "mock_realm" from "instance_frontend_realm_id" And I press "Launch" Then I should be on the instances page And I should see "mock1" diff --git a/src/features/realm.feature b/src/features/realm.feature new file mode 100644 index 0000000..fb807ac --- /dev/null +++ b/src/features/realm.feature @@ -0,0 +1,57 @@ +Feature: Manage Realms + In order to manage realms + As an admin + I want to add/edit/remove realms + + Background: + Given I am an authorised user + And I am logged in + And there's no realm + And a realm "testrealm1" exists + + Scenario: Create new frontend realm + Given I am on the admin realms page + When I follow "Create" + Then I should see "Create a new Realm" + When I fill in "frontend_realm[name]" with "testrealm2" + And I press "Save" + Then I should see "Realm was added." + + Scenario: Add realm mapping + Given I am on the admin realms page + And there is a realm "testrealm1" + And a provider "provider1" exists + When I follow "testrealm1" + And I follow "Mapping" + And I follow "Add mapping to provider" + Then I should see "Create a new Realm Mapping" + When I press "Save" + Then I should see "Realm mapping was added." + + Scenario: Change the name + Given I am on the admin realms page + And there is a realm "testrealm1" + When I follow "testrealm1" + And I follow "Edit" + Then I should see "Editing Realm:" + When I fill in "frontend_realm[name]" with "testrealm2" + And I press "Save" + Then I should see "Realm updated successfully!" + + Scenario: Show realm detials + Given a realm "testrealm2" exists + And I am on the admin realms page + When I follow "testrealm2" + Then I should be on testrealm2's realm page + + Scenario: Delete realms + Given a realm "testrealm2" exists + And I am on the admin realms page + And there are 2 realms + When I check "testrealm2" realm + And I check "testrealm1" realm + And I press "Delete" + Then there should be only 0 realms + And I should be on the admin realms page + And I should not see "testrealm1" + And I should not see "testrealm2" diff --git a/src/features/step_definitions/instance_steps.rb b/src/features/step_definitions/instance_steps.rb index 47f6eea..6e757ea 100644 --- a/src/features/step_definitions/instance_steps.rb +++ b/src/features/step_definitions/instance_steps.rb @@ -55,8 +55,8 @@ Given /^there is "([^"]*)" conductor hardware profile$/ do |name| Factory :mock_hwp2, :name => name end
-Given /^there is "([^"]*)" conductor realm$/ do |name| - Factory :frontend_realm, :backend_realm => Factory(:provider), :name => name +Given /^there is "([^"]*)" frontend realm$/ do |name| + Factory :frontend_realm, :name => name end
Given /^there is "([^"]*)" pool$/ do |arg1| diff --git a/src/features/step_definitions/realm_steps.rb b/src/features/step_definitions/realm_steps.rb new file mode 100644 index 0000000..5462c2c --- /dev/null +++ b/src/features/step_definitions/realm_steps.rb @@ -0,0 +1,28 @@ +Given /there's no realm/ do + FrontendRealm.destroy_all +end + +Given /^a realm "([^"]*)" exists$/ do |realm_name| + FrontendRealm.create(:name => realm_name) +end + +Given /^a provider "([^"]*)" exists$/ do |name| + Factory(:mock_provider, :name => name) +end + +Given /^there is a realm "([^"]*)"$/ do |name| + FrontendRealm.find_by_name(name).should_not == nil +end + +Given /^there are (\d+) realms$/ do |number| + FrontendRealm.count.should == number.to_i +end + +When /^(?:|I )check "([^"]*)" realm$/ do |realm_name| + realm = FrontendRealm.find_by_name(realm_name) + check("realm_id_#{realm.id}") +end + +Then /^there should be only (\d+) realms$/ do |number| + FrontendRealm.count.should == number.to_i +end diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb index 0633aca..c123cba 100644 --- a/src/features/support/paths.rb +++ b/src/features/support/paths.rb @@ -23,6 +23,9 @@ module NavigationHelpers when /^(.*)'s role page$/i admin_role_path(Role.find_by_name($1))
+ when /^(.*)'s realm page$/i + admin_realm_path(FrontendRealm.find_by_name($1)) + when /the account page/ account_path