https://www.aeolusproject.org/redmine/issues/3234
This commit contains only cucumber feature and step definitions
---
src/features/provider_api.feature | 73 ++++++++++++++++++++
.../step_definitions/provider_api_steps.rb | 16 ++++
src/features/step_definitions/provider_steps.rb | 6 ++
3 files changed, 95 insertions(+), 0 deletions(-)
create mode 100644 src/features/provider_api.feature
create mode 100644 src/features/step_definitions/provider_api_steps.rb
diff --git a/src/features/provider_api.feature b/src/features/provider_api.feature
new file mode 100644
index 0000000..eb2af2b
--- /dev/null
+++ b/src/features/provider_api.feature
@@ -0,0 +1,73 @@
+#
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+@api
+Feature: Manage Providers via API
+ As a client of conductor,
+ In order to manage the full life cycle of providers in the system
+ I want to be able to Create, Update and Delete providers via a RESTful API
+
+ Background:
+ Given I am an authorised user
+ And I use my authentication credentials in each request
+
+ Scenario: Get list of providers as XML
+ Given there are some providers
+ When I request a list of providers returned as XML
+ Then I should receive list of providers as XML
+
+# Scenario: Get details for provider as XML
+# Given there is a provider
+# When I ask for details of that provider as XML
+# Then I should recieve details of that provider as XML
+#
+# Scenario: Get details for non existing provider
+# When I ask for details of non existing provider
+# Then I should recieve Not Found error
+#
+# Scenario: Create a new provider
+# When I create provider with correct data
+# Then I should recieve OK message
+# And the provider should be created
+#
+# Scenario: Create a new provider with bad request
+# When I create provider with incorrect data
+# Then I should recieve Bad Request message
+# And the provider should not be created
+#
+# Scenario: Update a provider
+# Given there is a provider
+# When I update that provider with correct data
+# Then I should recieve OK message
+# And the provider should be updated
+#
+# Scenario: Update a provider with bad request
+# Given there is a provider
+# When I update that provider with incorrect data
+# Then I should recieve Bad Request message
+# And the provider should not be updated
+#
+# Scenario: Delete Provider
+# Given there is a provider
+# When I delete that provider
+# Then I should received an OK message
+# And the provider should be deleted
+#
+# Scenario: Attempt to delete non-existant provider
+# Given the specified provider does not exist in the system
+# When I attempt to delete the provider
+# Then I should receive a Provider Not Found error
+# And the provider should not be deleted
diff --git a/src/features/step_definitions/provider_api_steps.rb
b/src/features/step_definitions/provider_api_steps.rb
new file mode 100644
index 0000000..71ffb47
--- /dev/null
+++ b/src/features/step_definitions/provider_api_steps.rb
@@ -0,0 +1,16 @@
+World(Rack::Test::Methods)
+
+Given /^I use my authentication credentials in each request$/ do
+ authorize((a)user.login, 'secret')
+end
+
+When /^I request a list of providers returned as XML$/ do
+ header 'Accept', 'application/xml'
+ get providers_path
+end
+
+# TODO: complete tests for list of providers
+Then /^I should receive list of providers as XML$/ do
+ response = last_response
+ response.headers['Content-Type'].should include('application/xml')
+end
diff --git a/src/features/step_definitions/provider_steps.rb
b/src/features/step_definitions/provider_steps.rb
index 605f49c..a521ffe 100644
--- a/src/features/step_definitions/provider_steps.rb
+++ b/src/features/step_definitions/provider_steps.rb
@@ -74,6 +74,12 @@ When /^(?:|I )check "([^"]*)" provider$/ do
|provider_name|
check("provider_checkbox_#{provider.id}")
end
+Given /^there are some providers$/ do
+ 3.times do
+ FactoryGirl.create :provider
+ end
+end
+
Given /^there are these providers:$/ do |table|
table.hashes.each do |hash|
hash['url'].nil? ? FactoryGirl.create(:mock_provider, :name =>
hash['name']) : FactoryGirl.create(:mock_provider, :name =>
hash['name'], :url => hash['url'])
--
1.7.7.6