From: Jan Provaznik <jprovazn(a)redhat.com>
---
src/features/instance.feature | 6 +-
src/features/realm.feature | 58 +++++++++++++++++++++++
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, 94 insertions(+), 5 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 ad22025..82867f0 100644
--- a/src/features/instance.feature
+++ b/src/features/instance.feature
@@ -39,7 +39,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" aggregator hardware profile
- And there is "mock_realm" aggregator realm
+ And there is "mock_realm" frontend realm
And there is "mock_pool" pool
When I press "Create"
Then I should see "Show Templates"
@@ -48,7 +48,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"
@@ -109,4 +109,4 @@ Feature: Mange Instances
And I press "Search"
Then I should not see "mock"
And I should see "test"
- And I should not see "other"
\ No newline at end of file
+ And I should not see "other"
diff --git a/src/features/realm.feature b/src/features/realm.feature
new file mode 100644
index 0000000..53d4e91
--- /dev/null
+++ b/src/features/realm.feature
@@ -0,0 +1,58 @@
+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
+ And I am using new UI
+
+ 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 b843af2..f7b7e67 100644
--- a/src/features/step_definitions/instance_steps.rb
+++ b/src/features/step_definitions/instance_steps.rb
@@ -55,8 +55,8 @@ Given /^there is "([^"]*)" aggregator hardware profile$/
do |name|
Factory :mock_hwp2, :name => name
end
-Given /^there is "([^"]*)" aggregator 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 4bc7ba4..9c407a1 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
--
1.7.3.5