You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2010/08/04 12:18:41 UTC
svn commit: r982190 - in /incubator/deltacloud/trunk:
server/lib/deltacloud/base_driver/mock_driver.rb
tests/ec2/instance_credentials.feature
tests/ec2/step_definitions/images_steps.rb
tests/ec2/step_definitions/instance_credentials_steps.rb
Author: mfojtik
Date: Wed Aug 4 10:18:41 2010
New Revision: 982190
URL: http://svn.apache.org/viewvc?rev=982190&view=rev
Log:
Added Cucumber features for instance_credentials
Added:
incubator/deltacloud/trunk/tests/ec2/instance_credentials.feature
incubator/deltacloud/trunk/tests/ec2/step_definitions/instance_credentials_steps.rb
Modified:
incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/mock_driver.rb
incubator/deltacloud/trunk/tests/ec2/step_definitions/images_steps.rb
Modified: incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/mock_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/mock_driver.rb?rev=982190&r1=982189&r2=982190&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/mock_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/mock_driver.rb Wed Aug 4 10:18:41 2010
@@ -11,10 +11,13 @@ module Mock
[
:describe_images,
:describe_availability_zones,
+ :describe_keypairs,
+ :create_keypair,
:run_instances,
:describe_instances,
:reboot_instances,
- :terminate_instances
+ :terminate_instances,
+ :delete_keypair
]
end
Added: incubator/deltacloud/trunk/tests/ec2/instance_credentials.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/ec2/instance_credentials.feature?rev=982190&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/ec2/instance_credentials.feature (added)
+++ incubator/deltacloud/trunk/tests/ec2/instance_credentials.feature Wed Aug 4 10:18:41 2010
@@ -0,0 +1,51 @@
+Feature: Managing instance credentials
+
+ Scenario: Basic instance credential creation
+ Given URI /api/instance_credentials exists
+ And authentification is required for this URI
+ When client want to create a new instance credential
+ Then client should choose name 'test01'
+ When client request for a new instance credential
+ Then new instance credential should be created
+ And this instance should have id attribute set to 'test01'
+ And this instance should have valid fingerprint
+ And this instance should have valid pem key
+ And this instance should have credential_type set to 'key'
+ And this instance should have destroy action
+
+ Scenario: Listing current instance credentials
+ Given URI /api/instance_credentials exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instance_credentials'
+ And this element contains some instance_credentials
+ And each instance should have:
+ | name |
+ | actions |
+ And each instance_credential should have 'href' attribute with valid URL
+ And this URI should be available in XML, JSON, HTML format
+
+ Scenario: Get details about last instance_credential
+ Given URI /api/instance_credentials exists
+ And authentification is required for this URI
+ When client access this URI
+ Then client should get root element 'instance_credentials'
+ And this element contains some instance_credentials
+ When client want to show first instance_credential
+ Then client follow href attribute in first instance_credential
+ Then client should get this instance_credential
+ And this instance should have:
+ | name |
+ | actions |
+ | credential_type |
+ | fingerprint |
+
+ @prefix-destroy
+ Scenario: Destroying created instance credential
+ Given URI /api/instances exists
+ And authentification is required for this URI
+ When client want to 'destroy' last instance_credential
+ And client follow destroy link in actions
+ Then client should get created instance_credential
+ And this instance_credential should be destroyed
+
Modified: incubator/deltacloud/trunk/tests/ec2/step_definitions/images_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/ec2/step_definitions/images_steps.rb?rev=982190&r1=982189&r2=982190&view=diff
==============================================================================
--- incubator/deltacloud/trunk/tests/ec2/step_definitions/images_steps.rb (original)
+++ incubator/deltacloud/trunk/tests/ec2/step_definitions/images_steps.rb Wed Aug 4 10:18:41 2010
@@ -34,11 +34,9 @@ When /^client want to show first (.+)$/
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'
+ path = '/hardware_profiles/hardware_profile'
+ when 'instance_credential':
+ path = '/instance_credentials/instance_credential'
end
@element = output_xml.xpath(path).first
@element.should_not be_nil
Added: incubator/deltacloud/trunk/tests/ec2/step_definitions/instance_credentials_steps.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/ec2/step_definitions/instance_credentials_steps.rb?rev=982190&view=auto
==============================================================================
--- incubator/deltacloud/trunk/tests/ec2/step_definitions/instance_credentials_steps.rb (added)
+++ incubator/deltacloud/trunk/tests/ec2/step_definitions/instance_credentials_steps.rb Wed Aug 4 10:18:41 2010
@@ -0,0 +1,57 @@
+When /^client want to create a new instance credential$/ do
+end
+
+Then /^client should choose name '(\w+)'$/ do |name|
+ @name = name
+end
+
+Then /^this instance should have id attribute set to '(\w+)'$/ do |name|
+ output_xml.xpath('/instance_credential/@id').text.should == name
+end
+
+Then /^this instance should have valid fingerprint$/ do
+ output_xml.xpath('/instance_credential/fingerprint').text.should_not == nil
+ output_xml.xpath('/instance_credential/fingerprint').text.size > 0
+end
+
+Then /^this instance should have valid pem key$/ do
+ output_xml.xpath('/instance_credential/pem').text.strip =~ /$-----BEGIN RSA PRIVATE KEY-----/
+end
+
+When /^client request for a new instance credential$/ do
+ params = {
+ :name => @name
+ }
+ post "/api/instance_credentials", params
+end
+
+Then /^new instance credential should be created$/ do
+ output_xml.xpath('/instance_credential').size.should == 1
+end
+
+Then /^this instance should have credential_type set to 'key'$/ do
+ output_xml.xpath('/instance_credential/credential_type').text == 'key'
+end
+
+Then /^this instance should have destroy action$/ do
+ output_xml.xpath('/instance_credential/actions/link[@rel="destroy"]').should_not == nil
+end
+
+When /^client want to 'destroy' last instance_credential$/ do
+ get "/api/instance_credentials"
+ @credential = output_xml.xpath('/instance_credentials/instance_credential').last
+end
+
+When /^client follow destroy link in actions$/ do
+ @link = output_xml.xpath('/instance_credentials/instance_credential/actions/link[@rel="destroy"]').last
+ delete @link['href'], {}
+end
+
+Then /^client should get created instance_credential$/ do
+ @credential[:id].should == @name
+end
+
+Then /^this instance_credential should be destroyed$/ do
+ get "/api/instance_credentials/test01"
+ last_response.status.should == 200
+end