diff options
Diffstat (limited to 'features/step_definitions')
-rw-r--r-- | features/step_definitions/auth_steps.rb | 17 | ||||
-rw-r--r-- | features/step_definitions/config_steps.rb | 10 |
2 files changed, 26 insertions, 1 deletions
diff --git a/features/step_definitions/auth_steps.rb b/features/step_definitions/auth_steps.rb index 00d9004..e75455a 100644 --- a/features/step_definitions/auth_steps.rb +++ b/features/step_definitions/auth_steps.rb @@ -1,6 +1,21 @@ - Given /^I authenticated$/ do @user = FactoryGirl.create(:user) @my_auth_token = Token.create user_id: @user.id end +Given /^I am not logged in$/ do + @my_auth_token = nil +end + +When /^I send requests to these endpoints:$/ do |endpoints| + @endpoints = endpoints.rows_hash +end + +Then /^they should require authentication$/ do + @endpoints.each do |type, path| + opts = {method: type.downcase.to_sym} + request path, opts + assert_equal 401, last_response.status, + "Expected #{type} #{path} to require authentication." + end +end diff --git a/features/step_definitions/config_steps.rb b/features/step_definitions/config_steps.rb index 50ae829..70ff1aa 100644 --- a/features/step_definitions/config_steps.rb +++ b/features/step_definitions/config_steps.rb @@ -4,3 +4,13 @@ Given /the provider config is:$/ do |config| @tempfile.close StaticConfigController::PROVIDER_JSON = @tempfile.path end + +# use with @config tag so the config changes are reverted after the scenario +Given /^"([^"]*)" is (enabled|disabled|"[^"]") in the config$/ do |key, value| + value = case value + when 'disabled' then false + when 'enabled' then true + else value.gsub('"', '') + end + APP_CONFIG.merge! key => value +end |