You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:45:37 UTC
svn commit: r962313 - in /incubator/deltacloud/trunk/server/features: ./
step_definitions/ support/ support/ec2/ support/ec2/fixtures/
support/gogrid/ support/gogrid/fixtures/ support/mock/
Author: lutter
Date: Thu Jul 8 23:45:36 2010
New Revision: 962313
URL: http://svn.apache.org/viewvc?rev=962313&view=rev
Log:
Reworked Cucumber features
Added:
incubator/deltacloud/trunk/server/features/99_rake.feature
incubator/deltacloud/trunk/server/features/step_definitions/rake_steps.rb
Removed:
incubator/deltacloud/trunk/server/features/step_definitions/common_steps.rb
incubator/deltacloud/trunk/server/features/step_definitions/realms_steps.rb
incubator/deltacloud/trunk/server/features/step_definitions/storage_snapshots_steps.rb
incubator/deltacloud/trunk/server/features/step_definitions/storage_volumes.rb
incubator/deltacloud/trunk/server/features/support/ec2/config.yaml
incubator/deltacloud/trunk/server/features/support/ec2/fixtures/flavors.yaml
incubator/deltacloud/trunk/server/features/support/ec2/fixtures/images.yaml
incubator/deltacloud/trunk/server/features/support/ec2/fixtures/instances.yaml
incubator/deltacloud/trunk/server/features/support/ec2/fixtures/realms.yaml
incubator/deltacloud/trunk/server/features/support/ec2/fixtures/storage_snapshot.yaml
incubator/deltacloud/trunk/server/features/support/ec2/fixtures/storage_volume.yaml
incubator/deltacloud/trunk/server/features/support/gogrid/config.yaml
incubator/deltacloud/trunk/server/features/support/gogrid/fixtures/flavors.yaml
incubator/deltacloud/trunk/server/features/support/gogrid/fixtures/images.yaml
incubator/deltacloud/trunk/server/features/support/gogrid/fixtures/instances.yaml
incubator/deltacloud/trunk/server/features/support/gogrid/fixtures/ips.yaml
incubator/deltacloud/trunk/server/features/support/gogrid/servers.yaml
incubator/deltacloud/trunk/server/features/support/mock/config.yaml
Modified:
incubator/deltacloud/trunk/server/features/api.feature
incubator/deltacloud/trunk/server/features/hardware_profiles.feature
incubator/deltacloud/trunk/server/features/images.feature
incubator/deltacloud/trunk/server/features/instance_states.feature
incubator/deltacloud/trunk/server/features/instances.feature
incubator/deltacloud/trunk/server/features/realms.feature
incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb
incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb
incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb
incubator/deltacloud/trunk/server/features/step_definitions/instance_states_steps.rb
incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb
incubator/deltacloud/trunk/server/features/storage_snapshots.feature
incubator/deltacloud/trunk/server/features/storage_volumes.feature
incubator/deltacloud/trunk/server/features/support/env.rb
Added: incubator/deltacloud/trunk/server/features/99_rake.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/99_rake.feature?rev=962313&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/features/99_rake.feature (added)
+++ incubator/deltacloud/trunk/server/features/99_rake.feature Thu Jul 8 23:45:36 2010
@@ -0,0 +1,7 @@
+Feature: Running rake tasks
+
+ Scenario: I want to build Deltacloud API gem
+ Given I have a clean /pkg directory
+ When I run a 'package' task
+ Then I should see a gem file inside pkg directory
+ And I should see a tgz file inside pkg directory
Modified: incubator/deltacloud/trunk/server/features/api.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/api.feature?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/api.feature (original)
+++ incubator/deltacloud/trunk/server/features/api.feature Thu Jul 8 23:45:36 2010
@@ -1,23 +1,18 @@
-Feature: Working with API
- In order to work with API
+Feature: Accessing API entry points
- Scenario: I want to get list of entry points in XML
- Given I want to get XML
- When I request for entry points
- Then I should see these entry points:
- | realms |
- | instances |
- | images |
- | instance_states |
- | hardware_profiles |
- | storage_snapshots |
- | storage_volumes |
+ Scenario: API driver and version
+ Given URI /api exists
+ And authentification is not required for this URI
+ When client access this URI
+ Then client should get root element 'api'
+ And this element should have attribute 'driver' with value 'mock'
+ And this element should have attribute 'version' with value '1.0'
- Scenario: I want to get list of entry points in HTML
- Given I want to get HTML
- When I request for entry points
- Then I should get valid HTML response
- And I should see these entry points in page:
+ Scenario: List of entry points
+ Given URI /api exists
+ And authentification is not required for this URI
+ When client access this URI
+ Then client should get list of valid entry points:
| realms |
| instances |
| images |
@@ -25,6 +20,22 @@ Feature: Working with API
| hardware_profiles |
| storage_snapshots |
| storage_volumes |
- When I follow this entry points
- Then I should get valid HTML response for each
- And each entry points should have documentation
+ And this URI should be available in XML, JSON, HTML format
+
+ Scenario: Following entry points
+ Given URI /api exists
+ And authentification is not required for this URI
+ When client access this URI
+ Then client should get list of valid entry points
+ And each link should have 'rel' attribute with valid name
+ And each link should have 'href' attribute with valid URL
+ When client follow this attribute
+ Then client should get a valid response
+
+ Scenario: Instance features
+ Given URI /api exists
+ And authentification is not required for this URI
+ When client access this URI
+ Then client should get list of features inside 'instances':
+ | hardware_profiles |
+ | user_name |
Modified: incubator/deltacloud/trunk/server/features/hardware_profiles.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/hardware_profiles.feature?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/hardware_profiles.feature (original)
+++ incubator/deltacloud/trunk/server/features/hardware_profiles.feature Thu Jul 8 23:45:36 2010
@@ -1,23 +1,29 @@
-Feature: Working with hardware profiles
- In order to work with hardware profiles
-
- Background:
- Given I want to get XML
+Feature: Accessing hardware profiles
Scenario: I want to get list of all hardware profiles
- When I follow hardware profiles link in entry points
- Then I should see <HARDWARE_PROFILE_COUNT> hardware profile inside hardware profiles
- And each link in hardware profiles should point me to valid hardware profile
+ Given URI /api/hardware_profiles exists
+ And authentification is not required for this URI
+ When client access this URI
+ Then client should get root element 'hardware-profiles'
+ And this URI should be available in XML, HTML, JSON format
Scenario: I want to show hardware profile details
- When I request for '<HARDWARE_PROFILE_ID>' hardware profile
- Then I should get this hardware profile
+ Given URI /api/hardware_profiles exists
+ And authentification is not required for this URI
+ When client access this URI
+ Then client should get root element 'hardware-profiles'
+ When client want to show 'm1-large' hardware-profile
+ And client should get this hardware-profile
And it should have a href attribute
- And hardware profile should include id parameter
And it should have a fixed property 'cpu'
And it should have a range property 'memory'
And it should have a enum property 'storage'
+ And this URI should be available in XML, HTML, JSON format
- Scenario: I want filter hardware profiles by architecture
- When I want hardware profiles with '<HARDWARE_PROFILE_ARCH>' architecture
- Then the returned hardware profiles should have architecture '<HARDWARE_PROFILE_ARCH>'
+ Scenario: Filtering images by architecture
+ Given URI /api/hardware_profiles exists
+ And authentification is required for this URI
+ When client access this URI with parameters:
+ | architecture | i386 |
+ Then client should get some hardware-profiles
+ And each hardware-profile should have 'architecture' attribute set to 'i386'
Modified: incubator/deltacloud/trunk/server/features/images.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/images.feature?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/images.feature (original)
+++ incubator/deltacloud/trunk/server/features/images.feature Thu Jul 8 23:45:36 2010
@@ -1,38 +1,59 @@
-Feature: Working with images
- In order to work with images
+Feature: Listing and showing images
- Background:
- Given I want to get XML
-
- Scenario: I want to get list of all images
- When I follow images link in entry points
- Then I in order to see list of images I need to be authorized
- When I enter correct username and password
- And I follow images link in entry points
- Then I should see <IMAGE_COUNT> image inside images
- And each link in images should point me to valid image
-
- Scenario: I want to show image details
- Given I am authorized to show image '<IMAGE_ID>'
- When I request for '<IMAGE_ID>' image
- Then I should get this image
- And image should have valid href parameter
- And image should include id parameter
- And image should include name parameter
- And image should include owner_id parameter
- And image should include description parameter
- And image should include architecture parameter
-
- Scenario: I want filter images by owner_id
- When I want images with '<IMAGE_OWNER>' owner_id
- Then I should get only images with owner_id '<IMAGE_OWNER>'
-
- Scenario: I want filter images by architecture
- When I want images with '<IMAGE_ARCH>' architecture
- Then I should get only images with architecture '<IMAGE_ARCH>'
-
- Scenario: I want filter images by architecture
- When I want images with '<IMAGE_ARCH>' architecture
- And images with '<IMAGE_OWNER>' owner_id
- Then I should get only images with architecture '<IMAGE_ARCH>'
- And this images should also have owner_id '<IMAGE_OWNER>'
+ Scenario: Listing available images
+ Given URI /api/images exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'images'
+ And this element contains some images
+ And each image should have:
+ | id |
+ | name |
+ | description |
+ | architecture |
+ | owner_id |
+ And each image should have 'href' attribute with valid URL
+ And this URI should be available in XML, JSON, HTML format
+
+ Scenario: Following image href attribute
+ Given URI /api/images exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'images'
+ And this element contains some images
+ When client want to show first image
+ Then client should follow href attribute in image
+ And client should get valid response with requested image
+ And this image should have:
+ | id |
+ | name |
+ | description |
+ | architecture |
+ | owner_id |
+ And this URI should be available in XML, JSON, HTML format
+
+ Scenario: Filtering images by owner_id
+ Given URI /api/images exists
+ And authentification is required for this URI
+ When client access this URI with parameters:
+ | owner_id | fedoraproject |
+ Then client should get some images
+ And each image should have 'owner_id' attribute set to 'fedoraproject'
+
+ Scenario: Filtering images by architecture
+ Given URI /api/images exists
+ And authentification is required for this URI
+ When client access this URI with parameters:
+ | architecture | i386 |
+ Then client should get some images
+ And each image should have 'architecture' attribute set to 'i386'
+
+ Scenario: Filtering images by architecture and owner_id
+ Given URI /api/images exists
+ And authentification is required for this URI
+ When client access this URI with parameters:
+ | architecture | i386 |
+ | owner_id | fedoraproject |
+ Then client should get some images
+ And each image should have 'architecture' attribute set to 'i386'
+ And each image should have 'owner_id' attribute set to 'fedoraproject'
Modified: incubator/deltacloud/trunk/server/features/instance_states.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/instance_states.feature?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/instance_states.feature (original)
+++ incubator/deltacloud/trunk/server/features/instance_states.feature Thu Jul 8 23:45:36 2010
@@ -1,7 +1,36 @@
-Feature: Get possible instance states
- In order to get possible instance states
+Feature: Instance states and transitions
- Scenario:
- Given I want to get XML
- When I follow instance states link in entry points
- Then I should see list of instance states
+ Scenario: Getting list of states
+ Given URI /api/instance_states exists
+ And authentification is not required for this URI
+ When client access this URI
+ Then client should get root element 'states'
+ And this element contains some states
+ And this URI should be available in XML, JSON, HTML format
+
+
+ Scenario: State names
+ Given URI /api/instance_states exists
+ And authentification is not required for this URI
+ When client access this URI
+ Then client should get root element 'states'
+ And states element contains some states
+ And each state should have 'name' attribute
+ And first state should have 'name' attribute set to 'start'
+ And last state should have 'name' attribute set to 'finish'
+
+ Scenario: Transitions
+ Given URI /api/instance_states exists
+ And authentification is not required for this URI
+ When client access this URI
+ Then client should get root element 'states'
+ And states element contains some states
+ And some states should have transitions
+ And each transitions should have 'to' attribute
+
+ Scenario: State diagram
+ Given URI /api/instance_states exists
+ And authentification is not required for this URI
+ When client access this URI
+ And client wants PNG format
+ Then client should get PNG image
Modified: incubator/deltacloud/trunk/server/features/instances.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/instances.feature?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/instances.feature (original)
+++ incubator/deltacloud/trunk/server/features/instances.feature Thu Jul 8 23:45:36 2010
@@ -1,99 +1,164 @@
Feature: Managing instances
- In order to manage instances
- Background:
- Given I want to get XML
-
- Scenario: I want to get list of all instances
- Given I am authorized to list instances
- When I follow instances link in entry points
- Then I should see some instance inside instances
- And each link in instances should point me to valid instance
-
- Scenario: I want to create a new instance
- Given I am authorized to create instance
- When I request create new instance with:
- | name | <INSTANCE_1_NAME> |
- | image_id | <INSTANCE_IMAGE_ID> |
- Then I should request this instance
- And this instance should be 'RUNNING' or 'PENDING'
- And this instance should have name '<INSTANCE_1_NAME>'
- And this instance should be image '<INSTANCE_IMAGE_ID>'
-
- Scenario: I want to create a new instance using realm
- Given I am authorized to create instance
- When I request create new instance with:
- | name | <INSTANCE_2_NAME> |
- | image_id | <INSTANCE_IMAGE_ID> |
- | realm | <INSTANCE_REALM> |
- Then I should request this instance
- And this instance should be 'RUNNING' or 'PENDING'
- And this instance should have name '<INSTANCE_2_NAME>'
- And this instance should be image '<INSTANCE_IMAGE_ID>'
- And this instance should have realm '<INSTANCE_REALM>'
-
- Scenario: I want to show instance details
- Given I am authorized to show instance '<INSTANCE_1_ID>'
- When I request for '<INSTANCE_1_ID>' instance
- Then I should get this instance
- And instance should include id parameter
- And instance should include name parameter
- #And instance should include owner_id parameter
- And instance should include state parameter
- And this instance state should be 'RUNNING' or 'PENDING'
- When instance state is RUNNING
- Then instance should have one public address
- And instance should have one private address
- When instance state is RUNNING
- Then instance should include link to 'reboot' action
- And instance should include link to 'stop' action
-
- Scenario: I want to get instance image
- Given I am authorized to show instance '<INSTANCE_1_ID>'
- Given I request for '<INSTANCE_1_ID>' instance
- When I want to get details about instance image
- Then I could follow image href attribute
- And this attribute should point me to valid image
-
- Scenario: I want to get instance hardware profile
- Given I am authorized to show instance '<INSTANCE_1_ID>'
- Given I request for '<INSTANCE_1_ID>' instance
- When I want to get details about instance hardware profile
- Then I could follow hardware profile href attribute
- And this attribute should point me to valid hardware profile
-
- Scenario: I want to get instance realm
- Given I am authorized to show instance '<INSTANCE_1_ID>'
- Given I request for '<INSTANCE_1_ID>' instance
- When I want to get details about instance realm
- Then I could follow realm href attribute
- And this attribute should point me to valid realm
-
- Scenario: I want to stop instance
- Given I am authorized to show instance '<INSTANCE_1_ID>'
- Given I request for '<INSTANCE_1_ID>' instance
- When I want to stop this instance
- And this instance state is 'RUNNING' or 'PENDING'
- Then I could follow stop action in actions
- And this instance state should be 'STOPPED' or 'STOPPING'
-
- Scenario: I want to start instance
- Given I am authorized to show instance '<INSTANCE_1_ID>'
- Given I request for '<INSTANCE_1_ID>' instance
- When I want to stop this instance
- Then I could follow start action in actions
- And this instance state should be 'RUNNING'
-
- Scenario: I want to reboot instance
- Given I am authorized to show instance '<INSTANCE_1_ID>'
- Given I request for '<INSTANCE_1_ID>' instance
- When I want to reboot this instance
- Then I could follow reboot action in actions
- And this instance state should be 'RUNNING'
-
- Scenario: I want to destroy instance
- Given I am authorized to show instance '<INSTANCE_1_ID>'
- Given I request for '<INSTANCE_1_ID>' instance
- When I want to stop this instance
- Then I could follow stop action in actions
- And this instance state should be 'STOPPED'
+ Scenario: Listing current instances
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instances'
+ And this element contains some instances
+ And each instance should have:
+ | id |
+ | name |
+ | owner_id |
+ | image |
+ | realm |
+ | state |
+ | hardware-profile |
+ | actions |
+ | public-addresses |
+ | private-addresses |
+ And each instance should have 'href' attribute with valid URL
+ And this URI should be available in XML, JSON, HTML format
+
+ Scenario: Filtering instances by state
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI with parameters:
+ | state | RUNNING |
+ Then client should get some instances
+ And each instance should have 'state' attribute set to 'RUNNING'
+
+ Scenario: Get details about first instance
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instances'
+ And this element contains some instances
+ When client want to show first instance
+ Then client follow href attribute in first instance
+ Then client should get this instance
+ And this instance should have:
+ | id |
+ | name |
+ | owner_id |
+ | image |
+ | realm |
+ | state |
+ | hardware-profile |
+ | actions |
+ | public-addresses |
+ | private-addresses |
+
+ Scenario: Following image href in instance
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instances'
+ And this element contains some instances
+ When client follow image href attribute in first instance
+ Then client should get valid image
+
+ Scenario: Following realm href in instance
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instances'
+ And this element contains some instances
+ When client follow realm href attribute in first instance
+ Then client should get valid realm
+
+ Scenario: Following hardware profile href in instance
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instances'
+ And this element contains some instances
+ When client follow hardware-profile href attribute in first instance
+ Then client should get valid hardware-profile
+
+ Scenario: Instance actions
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instances'
+ And this element contains some instances
+ And each instance should have actions
+ And each actions should have some links
+ And each link should have valid href attribute
+ And each link should have valid rel attribute
+
+ Scenario: Reboot instance
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instances'
+ And this element contains some instances
+ When client want to 'reboot' first instance
+ And client follow link in actions
+ Then client should get first instance
+ And this instance should be in 'RUNNING' state
+
+ Scenario: Stop instance
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instances'
+ And this element contains some instances
+ When client want to 'stop' first instance
+ And client follow link in actions
+ Then client should get first instance
+ And this instance should be in 'STOPPED' state
+
+ Scenario: Start instance
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instances'
+ And this element contains some instances
+ When client want to 'start' first instance
+ And client follow link in actions
+ Then client should get first instance
+ And this instance should be in 'RUNNING' state
+
+ Scenario: Basic instance creation
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client want to create a new instance
+ Then client should choose first image
+ When client request for a new instance
+ Then new instance should be created
+ And this instance should have chosed image
+ And this instance should be in 'RUNNING' state
+ And this instance should have valid id
+ And this instance should have name
+
+ Scenario: Choosing hardware profile for instance
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client want to create a new instance
+ Then client should choose first image
+ And client choose last hardware profile
+ When client request for a new instance
+ Then new instance should be created
+ And this instance should have chosed image
+ And this instance should be in 'RUNNING' state
+ And this instance should have valid id
+ And this instance should have last hardware profile
+ And this instance should have name
+
+ Scenario: Create instance using HTML form
+ Given URI /api/instances/new exists in HTML format
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get HTML form
+
+ Scenario: Destroying created instance
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client want to 'stop' created instance
+ And client follow link in actions
+ Then client should get created instance
+ And this instance should be in 'STOPPED' state
+ When client want to 'destroy' created instance
+ And client follow link in actions
+ And this instance should be destroyed
Modified: incubator/deltacloud/trunk/server/features/realms.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/realms.feature?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/realms.feature (original)
+++ incubator/deltacloud/trunk/server/features/realms.feature Thu Jul 8 23:45:36 2010
@@ -1,25 +1,31 @@
-Feature: Working with realms
- In order to work with realms
+Feature: Accessing realms
- Background:
- Given I want to get XML
+ Scenario: Getting list of available realms
+ Given URI /api/realms exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'realms'
+ And this element contains some realms
+ And each realm should have:
+ | id |
+ | name |
+ | state |
+ | limit |
+ And each realm should have 'href' attribute with valid URL
+ And this URI should be available in XML, JSON, HTML format
- Scenario: I want to get list of all realms
- When I follow realms link in entry points
- Then I in order to see list of realms I need to be authorized
- When I enter correct username and password
- And I follow realms link in entry points
- Then I should see <REALM_COUNT> realm inside realms
- And each link in realms should point me to valid realm
-
- Scenario: I want to show realm details
- When I request for '<REALM_ID>' realm
- Then I should get this realm
- And realm should have valid href parameter
- And realm should include id parameter
- And realm should include name parameter
- And realm should include state parameter
-
- Scenario: I want filter realms by state
- When I want realms with '<REALM_STATE>' state
- Then I should get only realms with state '<REALM_STATE>'
+ Scenario: Following realm href attribute
+ Given URI /api/realms exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'realms'
+ And this element contains some realms
+ When client want to show first realm
+ Then client should follow href attribute in realm
+ And client should get valid response with requested realm
+ And this realm should have:
+ | id |
+ | name |
+ | state |
+ | limit |
+ And this URI should be available in XML, JSON, HTML format
Modified: incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/api_steps.rb Thu Jul 8 23:45:36 2010
@@ -1,45 +1,103 @@
-When /^I request for entry points$/ do
- get "/api", { }
- last_response.status.should == 200
+Given /^URI ([\w\/\-_]+) exists$/ do |uri|
+ get uri, {}
+ last_response.status.should_not == 404
+ last_response.status.should_not == 500
+ @uri = uri
end
-Then /^I should see these entry points:$/ do |table|
- Nokogiri::XML(last_response.body).xpath('/api/link').each do |entry_point|
- table.raw.flatten.include?(entry_point[:rel]).should == true
+Given /^URI ([\w\/\-_]+) exists in (.+) format$/ do |uri, format|
+ @uri = "#{uri}.#{format.downcase}"
+ get @uri, {}
+ last_response.status.should_not == 404
+ last_response.status.should_not == 500
+end
+
+Given /^authentification is not required for this URI$/ do
+ last_response.status.should_not == 401
+end
+
+When /^client access this URI$/ do
+ get @uri, {}
+ last_response.status.should_not == 404
+end
+
+Then /^client should get root element '(.+)'$/ do |element|
+ @last_element = output_xml.xpath('/'+element).first
+ @last_element.should_not be_nil
+ @last_element.name.should == element
+end
+
+Then /^this element should have attribute '(.+)' with value '(.+)'$/ do |atr, val|
+ @last_element[atr.to_sym].should == val
+end
+
+Then /^client should get list of valid entry points:$/ do |table|
+ @entry_points = table.raw.flatten.sort
+ links = []
+ output_xml.xpath('/api/link').each do |entry_point|
+ links << entry_point['rel']
end
+ @entry_points.should == links.sort
end
-Then /^I should get valid HTML response$/ do
- Nokogiri::HTML(last_response.body).root.name.should == 'html'
+Then /^this URI should be available in (.+) format$/ do |formats|
+ @no_header = true
+ formats.split(',').each do |format|
+ get "#{@uri}.#{format.strip.downcase}", {}
+ last_response.status.should == 200
+ end
+ @no_header = false
+end
+
+Then /^client should get list of valid entry points$/ do
+ links = []
+ output_xml.xpath('/api/link').each do |entry_point|
+ links << entry_point['rel']
+ end
+ @entry_points.should == links.sort
end
-Then /^I should see these entry points in page:$/ do |table|
- @links = []
- Nokogiri::HTML(last_response.body).css('div#content ul li a').each do |link|
- @links << link[:href]
+Then /^each (\w+) should have '(.+)' attribute with valid (.+)$/ do |el, attr, t|
+ case el
+ when 'link':
+ path = '/api/link'
+ when 'image':
+ path = '/images/image'
end
- table.raw.flatten.each do |link|
- @links.include?("/api/#{link}").should == true
+ output_xml.xpath(path).each do |entry_point|
+ @entry_points.include?(entry_point[attr]).should == true if t=='name'
+ if t=='URL'
+ entry_point[:href].should_not be_nil
+ end
end
+ @last_attribute = attr
end
-When /^I follow this entry points$/ do
- @responses = []
- authorize CONFIG[:username], CONFIG[:password]
- @links.each do |link|
- get link, {}
- @responses << last_response.status
+Then /^each ([\w\-]+) should have '(.+)' attribute set to '(.+)'$/ do |el, attr, v|
+ case el
+ when 'image':
+ path = "/image/images"
+ end
+ output_xml.xpath(path).each do |element|
+ element[attr].should == v
end
end
-Then /^I should get valid HTML response for each$/ do
- @responses.uniq.should == [200]
+When /^client follow this attribute$/ do
+ output_xml.xpath('/api/link').each do |entry_point|
+ get entry_point[@last_attribute], {}
+ end
end
-Then /^each entry points should have documentation$/ do
- @links.each do |link|
- next if link.eql?('/api/docs')
- get link.to_s.gsub(/\/api\//, '/api/docs/'), {}
- last_response.status.should == 200
+Then /^client should get a valid response$/ do
+ last_response.status.should_not == 500
+end
+
+Then /^client should get list of features inside '(.+)':$/ do |element,table|
+ features = table.raw.flatten.sort
+ instance_features = []
+ output_xml.xpath('/api/link[@rel="'+element+'"]/feature').each do |feature|
+ instance_features << feature[:name]
end
+ features.should == instance_features.sort
end
Modified: incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/hardware_profiles_steps.rb Thu Jul 8 23:45:36 2010
@@ -1,13 +1,10 @@
Then /^it should have a (\w+) attribute$/ do |name|
- attr = Nokogiri::XML(last_response.body).xpath('/hardware-profile').first[name]
+ attr = output_xml.xpath('/hardware-profile').first[name]
attr.should_not be_nil
- if (name == 'href')
- attr.should == "http://example.org/api/hardware_profiles/#{CONFIG[:hardware_profile_id]}"
- end
end
Then /^it should have a (\w+) property '(.+)'$/ do |kind, name|
- props = Nokogiri::XML(last_response.body).xpath("/hardware-profile/property[@name = '#{name}']")
+ props = output_xml.xpath("/hardware-profile/property[@name = '#{name}']")
props.size.should == 1
prop = props.first
prop['kind'].should == kind
@@ -26,16 +23,3 @@ Then /^it should have a (\w+) property '
end
end
-Then /^the returned hardware profiles should have (.+) '(.+)'$/ do |parameter, value|
- params = {}
- value = replace_variables(value)
- @tested_params.collect { |param| params[:"#{param[0]}"] = param[1] }
- get '/api/hardware_profiles', params, {}
- last_response.status.should == 200
- parameters = []
- Nokogiri::XML(last_response.body).xpath("/hardware-profiles/hardware-profile/property[@name = '#{parameter}']").each do |elt|
- parameters << elt['value']
- end
- parameters.uniq.size.should == 1
- parameters.uniq.first.should == value
-end
Modified: incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/images_steps.rb Thu Jul 8 23:45:36 2010
@@ -1,5 +1,83 @@
-Then /^image should have valid href parameter$/ do
- href=Nokogiri::XML(last_response.body).xpath('/image').first[:href]
- href.should == "http://example.org/api/images/#{CONFIG[:image_id]}"
+Given /^authentification is required for this URI$/ do
+ authorize CONFIG[:username], CONFIG[:password]
+ get @uri, {}
+ last_response.status.should == 200
end
+Then /^this element contains some (.+)$/ do |items|
+ item = items.singularize
+ output_xml.xpath("/#{@last_element.name}/#{item}").size.should > 0
+end
+
+Then /^each ([\w\-]+) should have:$/ do |item, table|
+ properties = table.raw.flatten.sort
+ output_xml.xpath("/#{@last_element.name}/#{item}").each do |element|
+ childrens = (element > '*').collect { |c| c.name }
+ childrens.sort.should == properties
+ end
+end
+
+Then /^this ([\w\-]+) should have:$/ do |item, table|
+ properties = table.raw.flatten.sort
+ output_xml.xpath("/#{item}").each do |element|
+ childrens = (element > '*').collect { |c| c.name }
+ childrens.sort.should == properties
+ end
+end
+
+When /^client want to show first (.+)$/ do |element|
+ case element
+ when 'image':
+ path = '/images/image'
+ when 'instance':
+ path = '/instances/instance'
+ when 'realm':
+ path = '/realms/realm'
+ when 'hardware-profile'
+ path = '/hardware-profiles/hardware-profile'
+ when 'storage-volume':
+ path = '/storage-volumes/storage-volume'
+ when 'storage-snapshot':
+ path = '/storage-snapshots/storage-snapshot'
+ end
+ @element = output_xml.xpath(path).first
+ @element.should_not be_nil
+end
+
+When /^client want to show '(.+)' (.+)$/ do |id, el|
+ @uri = "/api/#{el.pluralize.tr('-', '_')}/#{id}"
+ get @uri, {}
+ @element = output_xml.xpath("/#{el}").first
+ @element.should_not be_nil
+end
+
+Then /^client follow (\w+) attribute in first (.+)$/ do |attr, el|
+ url = output_xml.xpath("/#{el.pluralize}/#{el}").first[:href]
+ url.should_not be_nil
+ get url, {}
+end
+
+Then /^client should get this (.+)$/ do |el|
+ last_response.status.should == 200
+end
+
+
+Then /^client should follow href attribute in (\w+)$/ do |element|
+ get @element[:href], {}
+end
+
+Then /^client should get valid response with requested (\w+)$/ do |element|
+ last_response.status.should == 200
+ output_xml.xpath('/'+element+'/id').first.text.should == @element.xpath('id').text
+end
+
+When /^client access this URI with parameters:$/ do |table|
+ params = {}
+ table.raw.each { |i| params[i[0]]=i[1] }
+ get @uri, params
+end
+
+Then /^client should get some ([\w\-]+)$/ do |elements|
+ last_response.status.should == 200
+ output_xml.xpath('/'+elements+'/'+elements.singularize).size.should > 0
+end
Modified: incubator/deltacloud/trunk/server/features/step_definitions/instance_states_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/instance_states_steps.rb?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/instance_states_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/instance_states_steps.rb Thu Jul 8 23:45:36 2010
@@ -1,3 +1,34 @@
-Then /^I should see list of instance states$/ do
- Nokogiri::XML(last_response.body).root.name.should == 'states'
+Then /^states element contains some states$/ do
+ output_xml.xpath('/states/state').size.should > 0
+end
+
+Then /^each state should have '(.+)' attribute$/ do |attr|
+ output_xml.xpath('/states/state').each do |state|
+ state[attr].should_not be_nil
+ end
+end
+
+Then /^(\w+) state should have '(.+)' attribute set to '(\w+)'$/ do |pos, attr, value|
+ output_xml.xpath('/states/state').first[attr].should==value if pos=='first'
+ output_xml.xpath('/states/state').last[attr].should==value if pos=='last'
+end
+
+Then /^some states should have transitions$/ do
+ @transitions = output_xml.xpath('/states/state/transition')
+ @transitions.size.should > 0
+end
+
+Then /^each transitions should have 'to' attribute$/ do
+ @transitions.each do |t|
+ t[:to].should_not be_nil
+ end
+end
+
+When /^client wants (\w+) format$/ do |format|
+ get "#{@uri}.#{format.downcase}", {}
+end
+
+Then /^client should get PNG image$/ do
+ last_response.status.should == 200
+ last_response.headers['Content-Type'].should == 'image/png'
end
Modified: incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb (original)
+++ incubator/deltacloud/trunk/server/features/step_definitions/instances_steps.rb Thu Jul 8 23:45:36 2010
@@ -1,124 +1,121 @@
-Then /^instance state should be (.+)$/ do |state|
- Nokogiri::XML(last_response.body).xpath("/instance/state").first.text.should == state
+When /^client follow ([\w\-]+) href attribute in first instance$/ do |element|
+ get output_xml.xpath('/instances/instance[1]/'+element).first[:href], {}
end
-When /^instance state is (.+)$/ do |state|
- Nokogiri::XML(last_response.body).xpath("/instance/state").first.text.should == state
+Then /^client should get valid ([\w\-]+)$/ do |element|
+ last_response.status.should == 200
+ output_xml.xpath("/#{element}").first.should_not be_nil
end
-Then /^instance should have one (public|private) address$/ do |type|
- adr = Nokogiri::XML(last_response.body).xpath("/instance/#{type}-addresses/address").first
- adr.text.to_s.should_not == nil
- adr.text.to_s.should_not == ''
+Then /^each instance should have actions$/ do
+ output_xml.xpath('/instances/instance').each do |instance|
+ instance.xpath('actions').first.should_not be_nil
+ end
end
-Then /^instance should include link to '(.+)' action$/ do |action|
- links = Nokogiri::XML(last_response.body).xpath("/instance/actions/link")
- actions = []
- links.each do |link|
- actions << link[:rel]
+Then /^each actions should have some links$/ do
+ output_xml.xpath('/instances/instance').each do |instance|
+ instance.xpath('actions/link').first.should_not be_nil
end
- actions.include?(action).should == true
end
-When /^I want to get details about instance (.+)$/ do |model|
+Then /^each link should have valid (\w+) attribute$/ do |attr|
+ output_xml.xpath('/instances/instance').each do |instance|
+ instance.xpath('actions/link').first[attr].should_not be_nil
+ end
end
-Then /^I could follow (image|realm|hardware profile) href attribute$/ do |model|
- model.tr!(' ', '-')
- m = Nokogiri::XML(last_response.body).xpath("/instance/#{model}").first
- model_url = URI.parse(m[:href]).path
- get model_url, {}
- last_response.status.should == 200
+When /^client want to '(\w+)' first instance$/ do |action|
+ @action = action
+ @instance = output_xml.xpath('/instances/instance[1]').first
end
-Then /^this attribute should point me to valid (image|realm|hardware profile)$/ do |model|
- model_tag = model.tr(' ', '-')
- model.tr!(' ', '_')
- attribute = Nokogiri::XML(last_response.body).xpath("/#{model_tag}").first
- attribute.should_not == nil
- attribute.name.should == model_tag
+When /^client follow link in actions$/ do
+ unless @instance_url
+ l = output_xml.xpath("/instances/instance[1]/actions/link[@rel = '#{@action}']").first
+ else
+ l = @instance.xpath('actions/link[@rel="'+@action+'"]').first
+ end
+ l.should_not be_nil
+ unless @action=='destroy'
+ post l[:href], { :id => @instance.xpath('id').first.text }
+ else
+ delete l[:href], { :id => @instance.xpath('id').first.text }
+ end
+ last_response.status.should_not == 500
end
-When /^I want to (.+) this instance$/ do |action|
+Then /^client should get first instance$/ do
+ output_xml.xpath('/instance/id').first.should_not be_nil
+ output_xml.xpath('/instance/id').first.text.should == @instance.xpath('id').first.text
end
-Given /^I am authorized to create instance$/ do
- last_response.status.should_not == 401
+Then /^this instance should be in '(.+)' state$/ do |state|
+ output_xml.xpath('/instance/state').first.text.should == state
end
-Then /^I could follow (.+) action in actions$/ do |action|
- link = Nokogiri::XML(last_response.body).xpath("/instance/actions/link[@rel='#{action}']").first
- link.should_not == nil
- post URI.parse(link[:href]).path, {}
- last_response.status.should == 200
+When /^client want to create a new instance$/ do
+end
+
+Then /^client should choose first image$/ do
+ get '/api/images', {}
+ @image = output_xml.xpath('/images/image').first
+ @image.should_not be_nil
end
-Then /^this instance state should be '(\w+)'$/ do |state|
- Nokogiri::XML(last_response.body).xpath("/instance/state").first.text.should == state
+When /^client request for a new instance$/ do
+ params = {
+ :image_id => @image.xpath('id').first.text
+ }
+ params[:hwp_id] = @hwp_id if @hwp_id
+ post "#{@uri}", params
+ last_response.status.should == 201
+ @instance_url = last_response.headers['Location']
end
-Then /^this instance state should be '(\w+)' or '(\w+)'$/ do |state, state_2|
- instance_state = Nokogiri::XML(last_response.body).xpath("/instance/state").first
- instance_state.should_not == nil
- [state, state_2].include?(instance_state.text).should == true
+Then /^new instance should be created$/ do
+ get @instance_url, {}
+ last_response.status.should == 200
end
-When /^I request create new instance with:$/ do |table|
- params = {}
- table.raw.map { |a,b| params[:"#{a}"] = replace_variables(b) }
- post '/api/instances', params
- @instance_id = Nokogiri::XML(last_response.body).xpath("/instance/id").first.text
- @instance_id.should_not == nil
- CONFIG[:instance_1_id] = @instance_id unless CONFIG[:instance_1_id]
+Then /^this instance should have chosed image$/ do
+ output_xml.xpath('/instance/image').first[:href].should == @image[:href]
end
-Then /^I should request this instance$/ do
- get URI.encode('/api/instances/'+@instance_id), {}
- last_response.status.should == 200
- Nokogiri::XML(last_response.body).xpath("/instance").first.should_not == nil
+Then /^this instance should have valid id$/ do
+ output_xml.xpath('instance/id').first.should_not be_nil
end
-Then /^this instance should be '(RUNNING|PENDING|STOPPED)'$/ do |state|
- get URI.encode('/api/instances/'+@instance_id), {}
- last_response.status.should == 200
- Nokogiri::XML(last_response.body).xpath("/instance/state").first.text.should == state
+Then /^this instance should have name$/ do
+ output_xml.xpath('instance/name').first.should_not be_nil
end
-Then /^this instance should be '(RUNNING|PENDING|STOPPED)' or '(RUNNING|PENDING|STOPPED)'$/ do |state, second_state|
- get URI.encode('/api/instances/'+@instance_id), {}
+When /^client want to '(\w+)' created instance$/ do |action|
+ get @instance_url, {}
last_response.status.should == 200
- [state, second_state].include?(Nokogiri::XML(last_response.body).xpath("/instance/state").first.text).should == true
+ @action = action
+ @instance = output_xml.xpath('/instance')
end
-Then /^this instance should have name '(.+)'$/ do |name|
- get URI.encode('/api/instances/'+@instance_id), {}
- last_response.status.should == 200
- Nokogiri::XML(last_response.body).xpath("/instance/name").first.text.should == replace_variables(name)
+Then /^client should get created instance$/ do
+ get @instance_url
end
-Then /^this instance should be image '(.+)'$/ do |image|
- get URI.encode('/api/instances/'+@instance_id), {}
- last_response.status.should == 200
- get URI.parse(Nokogiri::XML(last_response.body).xpath("/instance/image").first[:href]).path, {}
- last_response.status.should == 200
- Nokogiri::XML(last_response.body).xpath("/image/id").first.text.should == replace_variables(image)
+When /^this instance should be destroyed$/ do
+ get @instance_url, {}
+ last_response.status.should == 404
end
-Then /^this instance should have realm '(.+)'$/ do |realm|
- get URI.encode('/api/instances/'+@instance_id), {}
- last_response.status.should == 200
- get URI.parse(Nokogiri::XML(last_response.body).xpath("/instance/realm").first[:href]).path, {}
+Then /^client should get HTML form$/ do
last_response.status.should == 200
- Nokogiri::XML(last_response.body).xpath("/realm/id").first.text.should == replace_variables(realm)
+ (last_response.body.strip =~ /^<!DOCTYPE html/).should be_true
end
-When /^this instance state is '(\w+)'$/ do |given_state|
- state = Nokogiri::XML(last_response.body).xpath("/instance/state").first.text
- state.should == given_state
+When /^client choose last hardware profile$/ do
+ get '/api/hardware_profiles', {}
+ @hwp_id = output_xml.xpath('/hardware-profiles/hardware-profile/id').last.text
end
-When /^this instance state is '(\w+)' or '(\w+)'$/ do |given_state, given_state_2|
- state = Nokogiri::XML(last_response.body).xpath("/instance/state").first.text
- [given_state, given_state_2].include?(state).should == true
+Then /^this instance should have last hardware profile$/ do
+ output_xml.xpath('instance/hardware-profile/id').first.text.should == @hwp_id
end
Added: incubator/deltacloud/trunk/server/features/step_definitions/rake_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/step_definitions/rake_steps.rb?rev=962313&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/features/step_definitions/rake_steps.rb (added)
+++ incubator/deltacloud/trunk/server/features/step_definitions/rake_steps.rb Thu Jul 8 23:45:36 2010
@@ -0,0 +1,19 @@
+require 'fileutils'
+require 'rake'
+require 'find'
+
+Given /^I have a clean (.+) directory$/ do |dir|
+ FileUtils.rm_rf dir
+end
+
+When /^I run a '(\w+)' task$/ do |task|
+ @rake = Rake::Application.new
+ Rake.application = @rake
+ load "Rakefile"
+ @task = Rake::Task[task]
+ @task.invoke
+end
+
+Then /^I should see a (\w+) file inside (\w+) directory$/ do |ext, dir|
+ Dir["#{dir}/deltacloud-*.#{ext}"].size.should == 1
+end
Modified: incubator/deltacloud/trunk/server/features/storage_snapshots.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/storage_snapshots.feature?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/storage_snapshots.feature (original)
+++ incubator/deltacloud/trunk/server/features/storage_snapshots.feature Thu Jul 8 23:45:36 2010
@@ -1,29 +1,29 @@
-Feature: Working with storage snapshots
- In order to work with storage snapshots
+Feature: Accessing storage snapshots
- Background:
- Given I want to get XML
+ Scenario: Listing available storage snapshots
+ Given URI /api/storage_snapshots exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'storage-snapshots'
+ And this element contains some storage-snapshots
+ And each storage-volume should have:
+ | id |
+ | created |
+ | storage-volume |
+ And each image should have 'href' attribute with valid URL
+ And this URI should be available in XML, JSON, HTML format
- Scenario: I want to get list of all storage snapshots
- Given I am authorized to list storage snapshots
- When I follow storage snapshots link in entry points
- Then I should see <STORAGE_SNAPSHOT_COUNT> storage snapshot inside storage snapshots
- And each link in storage snapshots should point me to valid storage snapshot
-
- Scenario: I want to show storage snapshot details
- Given I am authorized to show storage snapshot '<STORAGE_SNAPSHOT_ID>'
- When I request for '<STORAGE_SNAPSHOT_ID>' storage snapshot
- Then I should get this storage snapshot
- And storage snapshot should have valid href parameter
- And storage snapshot should include id parameter
- And storage snapshot should include created parameter
- And storage snapshot should include state parameter
- And storage snapshot should have storage-volume with valid href attribute
- When I want to get details about storage volume
- Then I could follow storage volume href attribute
- And this attribute should point me to valid storage volume
-
- Scenario: I want filter storage snapshots by state
- Given I am authorized to list storage snapshots
- When I want storage snapshots with '<STORAGE_SNAPSHOT_STATE>' state
- Then I should get only realms with state '<STORAGE_SNAPSHOT_STATE>'
+ Scenario: Get details about first volume
+ Given URI /api/storage_snapshots exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'storage-snapshots'
+ And this element contains some storage-snapshots
+ When client want to show first storage-snapshot
+ Then client follow href attribute in first storage-snapshot
+ Then client should get this storage-snapshot
+ And this storage-snapshot should have:
+ | id |
+ | created |
+ | state |
+ | storage-volume |
Modified: incubator/deltacloud/trunk/server/features/storage_volumes.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/storage_volumes.feature?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/storage_volumes.feature (original)
+++ incubator/deltacloud/trunk/server/features/storage_volumes.feature Thu Jul 8 23:45:36 2010
@@ -1,32 +1,33 @@
-Feature: Working with storage volumes
- In order to work with storage volumes
+Feature: Accessing storage volumes
- Background:
- Given I want to get XML
+ Scenario: Listing available storage volumes
+ Given URI /api/storage_volumes exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'storage-volumes'
+ And this element contains some storage-volumes
+ And each storage-volume should have:
+ | id |
+ | created |
+ | capacity |
+ | device |
+ | instance |
+ And each image should have 'href' attribute with valid URL
+ And this URI should be available in XML, JSON, HTML format
- Scenario: I want to get list of all storage volumes
- Given I am authorized to list storage volumes
- When I follow storage volumes link in entry points
- Then I should see <STORAGE_VOLUME_COUNT> storage volume inside storage volumes
- And each link in storage volumes should point me to valid storage volume
-
- Scenario: I want to show storage volume details
- Given I am authorized to show storage volume '<STORAGE_VOLUME_ID>'
- When I request for '<STORAGE_VOLUME_ID>' storage volume
- Then I should get this storage volume
- And storage volume should have valid href parameter
- And storage volume should include id parameter
- And storage volume should include created parameter
- And storage volume should include state parameter
- And storage volume should include capacity parameter
- And storage volume should include device parameter
-
- Scenario: I want to get storage volume instance
- Given I am authorized to show storage volume '<STORAGE_VOLUME_ID>'
- When I request for '<STORAGE_VOLUME_ID>' storage volume
- Then I should get this storage volume
-
- Scenario: I want filter storage volumes by state
- Given I am authorized to list storage volumes
- When I want storage volumes with '<STORAGE_VOLUME_STATE>' state
- Then I should get only realms with state '<STORAGE_VOLUME_STATE>'
+ Scenario: Get details about first volume
+ Given URI /api/storage_volumes exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'storage-volumes'
+ And this element contains some storage-volumes
+ When client want to show first storage-volume
+ Then client follow href attribute in first storage-volume
+ Then client should get this storage-volume
+ And this storage-volume should have:
+ | id |
+ | created |
+ | capacity |
+ | device |
+ | instance |
+ | state |
Modified: incubator/deltacloud/trunk/server/features/support/env.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/features/support/env.rb?rev=962313&r1=962312&r2=962313&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/features/support/env.rb (original)
+++ incubator/deltacloud/trunk/server/features/support/env.rb Thu Jul 8 23:45:36 2010
@@ -1,34 +1,39 @@
require 'sinatra'
require 'server'
require 'rack/test'
+require 'nokogiri'
SERVER_DIR = File::expand_path(File::join(File::dirname(__FILE__), "../.."))
-
Sinatra::Application.set :environment, :test
Sinatra::Application.set :root, SERVER_DIR
ENV['API_DRIVER'] = "mock" unless ENV['API_DRIVER']
-CONFIG = YAML::load_file(File::join('features', 'support', ENV['API_DRIVER'], 'config.yaml'))
+
+CONFIG = {
+ :username => 'mockuser',
+ :password => 'mockpassword'
+}
World do
+
def app
@app = Rack::Builder.new do
set :logging, true
set :raise_errors, true
run Sinatra::Application
end
- end
+ end
- def replace_variables(str)
- CONFIG.keys.collect { |k| str.gsub!(/\<#{k.to_s.upcase}\>/, "#{CONFIG[k]}") }
- return str
+ def output_xml
+ Nokogiri::XML(last_response.body)
end
Before do
- header 'Accept', 'application/xml'
+ unless @no_header
+ header 'Accept', 'application/xml'
+ end
end
include Rack::Test::Methods
-
end