Permalink
Browse files

first cucumber tests! (access restrictions)

  • Loading branch information...
1 parent bf27af0 commit e7b099e86c626bde4abb238f42f90ac76a9ee4dd @khustochka committed Jan 2, 2010
Showing with 67 additions and 6 deletions.
  1. +43 −0 features/access_restriction.feature
  2. +12 −0 features/step_definitions/web_steps.rb
  3. +12 −6 features/support/paths.rb
View
43 features/access_restriction.feature
@@ -0,0 +1,43 @@
+Feature: Restricted access to administration parts for external users
+ # Will fail if CONFIG[:open_access] == true
+
+ Scenario: Unauthorized user should not see Admin root
+
+ When I go to '/admin'
+ Then I should see 404 status page
+
+ Scenario: Unauthorized user should not see Admin dashboard
+
+ When I go to Admin dashboard
+ Then I should get "401 Unauthorized" response status
+
+ Scenario: User with invalid credentials should not see Admin dashboard
+
+ Given logged as "someuser" with password "any4passwd"
+ When I go to Admin dashboard
+ Then I should get "401 Unauthorized" response status
+
+ Scenario: Unauthorized user should not see Ordines Index
+
+ When I go to Ordines Index
+ Then I should see 404 status page
+
+ Scenario: Unauthorized user should not see Familiae Index
+
+ When I go to Familiae Index
+ Then I should see 404 status page
+
+ Scenario: Unauthorized user should not see New Ordo page
+
+ When I go to New Ordo page
+ Then I should see 404 status page
+
+ Scenario: Unauthorized user should not see New Familia page
+
+ When I go to New Familia page
+ Then I should see 404 status page
+
+ Scenario: Unauthorized user should not see New Species page
+
+ When I go to New Species page
+ Then I should see 404 status page
View
12 features/step_definitions/web_steps.rb
@@ -10,6 +10,10 @@
# Commonly used webrat steps
# http://github.com/brynary/webrat
+Given /^logged as "([^"]*)" with password "(.*)"$/ do |user_name, password|
+ basic_auth(user_name, password)
+end
+
Given /^(?:|I )am on (.+)$/ do |page_name|
visit path_to(page_name)
end
@@ -254,6 +258,14 @@
end
end
+Then /^I should see 404 status page$/ do
+ Then 'I should get "404 Not Found" response status'
+end
+
+Then /^I should get "([^"]*)" response status$/ do |status_string|
+ response.status.should == status_string
+end
+
Then /^show me the page$/ do
save_and_open_page
end
View
18 features/support/paths.rb
@@ -10,12 +10,18 @@ def path_to(page_name)
when /the home\s?page/
'/'
-
- # Add more mappings here.
- # Here is an example that pulls values out of the Regexp:
- #
- # when /^(.*)'s profile page$/i
- # user_profile_path(User.find_by_login($1))
+
+ when /Admin dashboard/
+ "/admin/#{CONFIG[:admin_dashboard]}"
+
+ when /(Ordines|Familiae) Index/
+ "/admin/#{$1.downcase}"
+
+ when /New (Ordo|Familia|Species) page/
+ "/admin/#{$1.downcase}/new"
+
+ when /'([^']*)'/
+ $1
else
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +

0 comments on commit e7b099e

Please sign in to comment.