On 06/04/12, [email protected] wrote: ACK.
> From: marios <[email protected]> > > > Signed-off-by: marios <[email protected]> > --- > server/tests/drivers/ec2/api_test.rb | 111 > +------------------- > server/tests/drivers/ec2/common.rb | 55 +--------- > server/tests/drivers/ec2/drivers_test.rb | 4 +- > server/tests/drivers/ec2/hardware_profiles_test.rb | 46 ++++---- > server/tests/drivers/ec2/images_test.rb | 42 ++++---- > server/tests/drivers/ec2/instances_test.rb | 50 +++++----- > server/tests/drivers/ec2/keys_test.rb | 34 +++--- > server/tests/drivers/ec2/realms_test.rb | 30 +++--- > 8 files changed, 108 insertions(+), 264 deletions(-) > > diff --git a/server/tests/drivers/ec2/api_test.rb > b/server/tests/drivers/ec2/api_test.rb > index a5b2333..eefc40a 100644 > --- a/server/tests/drivers/ec2/api_test.rb > +++ b/server/tests/drivers/ec2/api_test.rb > @@ -14,115 +14,6 @@ describe 'Deltacloud API' do > > include Deltacloud::Test > > - it 'return HTTP_OK when accessing API entrypoint' do > - get Deltacloud[:root_url] > - last_response.status.must_equal 200 > - end > - > - it 'advertise the current driver in API entrypoint' do > - get Deltacloud[:root_url] > - xml_response.root[:driver].must_equal ENV['API_DRIVER'] > - end > - > - it 'advertise the current API version in API entrypoint' do > - get Deltacloud[:root_url] > - xml_response.root[:version].must_equal Deltacloud[:version] > - end > - > - it 'advertise the current API version in HTTP headers' do > - get Deltacloud[:root_url] > - last_response.headers['Server'].must_equal > "Apache-Deltacloud/#{Deltacloud[:version]}" > - end > - > - it 'must include the ETag in HTTP headers' do > - get Deltacloud[:root_url] > - last_response.headers['ETag'].wont_be_nil > - end > - > - it 'advertise collections in API entrypoint' do > - get Deltacloud[:root_url] > - (xml_response/'api/link').wont_be_empty > - end > - > - it 'include the :href and :rel attribute for each collection in API > entrypoint' do > - get Deltacloud[:root_url] > - (xml_response/'api/link').each do |collection| > - collection[:href].wont_be_nil > - collection[:rel].wont_be_nil > - end > - end > - > - it 'uses the absolute URI in the :href attribute for each collection in > API entrypoint' do > - get Deltacloud[:root_url] > - (xml_response/'api/link').each do |collection| > - collection[:href].must_match /^http/ > - end > - end > - > - it 'advertise features for some collections in API entrypoint' do > - get Deltacloud[:root_url] > - (xml_response/'api/link/feature').wont_be_empty > - end > - > - it 'advertise the name of the feature for some collections in API > entrypoint' do > - get Deltacloud[:root_url] > - (xml_response/'api/link/feature').each do |f| > - f[:name].wont_be_nil > - end > - end > - > - it 'must change the media type from XML to JSON using Accept headers' do > - header 'Accept', 'application/json' > - get Deltacloud[:root_url] > - last_response.headers['Content-Type'].must_equal 'application/json' > - end > - > - it 'must change the media type to JSON using the "?format" parameter in > URL' do > - get Deltacloud[:root_url], { :format => 'json' } > - last_response.headers['Content-Type'].must_equal 'application/json' > - end > - > - it 'must change the driver when using X-Deltacloud-Driver HTTP header' do > - header 'X-Deltacloud-Driver', 'ec2' > - get Deltacloud[:root_url] > - xml_response.root[:driver].must_equal 'ec2' > - header 'X-Deltacloud-Driver', 'mock' > - get Deltacloud[:root_url] > - xml_response.root[:driver].must_equal 'mock' > - end > - > - it 'must change the features when driver is swapped using HTTP headers' do > - header 'X-Deltacloud-Driver', 'ec2' > - get Deltacloud[:root_url] > - # The 'user_name' feature is not supported currently for the EC2 driver > - (xml_response/'api/link/feature').map { |f| f[:name] }.wont_include > 'user_name' > - header 'X-Deltacloud-Driver', 'mock' > - get Deltacloud[:root_url] > - # But it's supported in Mock driver > - (xml_response/'api/link/feature').map { |f| f[:name] }.must_include > 'user_name' > - end > - > - it 'must re-validate the driver credentials when using "?force_auth" > parameter in URL' do > - get Deltacloud[:root_url], { :force_auth => '1' } > - last_response.status.must_equal 401 > - auth_as_mock > - get Deltacloud[:root_url], { :force_auth => '1' } > - last_response.status.must_equal 200 > - end > - > - it 'must change the API PROVIDER using the /api;provider matrix parameter > in URI' do > - get Deltacloud[:root_url] + ';provider=test1' > - xml_response.root[:provider].wont_be_nil > - xml_response.root[:provider].must_equal 'test1' > - get Deltacloud[:root_url] + ';provider=test2' > - xml_response.root[:provider].must_equal 'test2' > - end > - > - it 'must change the API DRIVER using the /api;driver matrix parameter in > URI' do > - get Deltacloud[:root_url] + ';driver=ec2' > - xml_response.root[:driver].must_equal 'ec2' > - get Deltacloud[:root_url] + ';driver=mock' > - xml_response.root[:driver].must_equal 'mock' > - end > + eval File.read('tests/minitest_common_api_test.rb') > > end > diff --git a/server/tests/drivers/ec2/common.rb > b/server/tests/drivers/ec2/common.rb > index 0d8d3bd..3e1486c 100644 > --- a/server/tests/drivers/ec2/common.rb > +++ b/server/tests/drivers/ec2/common.rb > @@ -1,21 +1,11 @@ > ENV['API_DRIVER'] = 'ec2' > -ENV['API_USERNAME'] = 'AKIAIZ63KHGXIWDMBY6Q' > -ENV['API_PASSWORD'] = 'zUfBCbML2S6pXKS44eEEXw0Cf/G8z9hMSxP2hcLV' > +ENV['TESTS_API_USERNAME'] = 'AKIAIZ63KHGXIWDMBY6Q' > +ENV['TESTS_API_PASSWORD'] = 'zUfBCbML2S6pXKS44eEEXw0Cf/G8z9hMSxP2hcLV' > ENV['RACK_ENV'] = 'test' > > -load File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', > 'deltacloud_rack.rb') > +$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..') > +require 'tests/minitest_common' > > -Deltacloud::configure do |server| > - server.root_url '/api' > - server.version '0.5.0' > - server.klass 'Deltacloud::API' > -end.require_frontend! > - > -require 'minitest/autorun' > -require 'rack/test' > -require 'nokogiri' > -require 'json' > -require 'pp' > require 'vcr' > require 'timecop' > > @@ -31,40 +21,3 @@ end > > FREEZED_TIME = DateTime.parse("2012-05-31 12:58:00 +0200") > Timecop.freeze(FREEZED_TIME) > - > -module Deltacloud > - module Test > - include Rack::Test::Methods > - > - def included?(sub) > - sub.class_eval do > - before do > - header 'Accept', 'application/xml' > - end > - end > - end > - > - def xml_response > - Nokogiri::XML(last_response.body) > - end > - > - def auth_as_mock > - authorize ENV['API_USERNAME'], ENV['API_PASSWORD'] > - end > - > - def collection_url(collection) > - [Deltacloud[:root_url], collection.to_s].join('/') > - end > - > - def app > - Rack::Builder.new { > - map '/' do > - Timecop.freeze(FREEZED_TIME) do > - use Rack::Static, :urls => ["/stylesheets", "/javascripts"], > :root => "public" > - run Rack::Cascade.new([Deltacloud::API]) > - end > - end > - } > - end > - end > -end > diff --git a/server/tests/drivers/ec2/drivers_test.rb > b/server/tests/drivers/ec2/drivers_test.rb > index 26adc7b..4521ca3 100644 > --- a/server/tests/drivers/ec2/drivers_test.rb > +++ b/server/tests/drivers/ec2/drivers_test.rb > @@ -91,7 +91,7 @@ describe 'Deltacloud API drivers' do > > > it 'must return the full "driver" when following the URL in driver > element' do > - auth_as_mock > + authenticate > get collection_url(:drivers) > (xml_response/'drivers/driver').each do |r| > get collection_url(:drivers) + '/' + r[:id] > @@ -100,7 +100,7 @@ describe 'Deltacloud API drivers' do > end > > it 'must have the "name" element for the driver and it should match with > the one in collection' do > - auth_as_mock > + authenticate > get collection_url(:drivers) > (xml_response/'drivers/driver').each do |r| > r[:id].wont_be_nil > diff --git a/server/tests/drivers/ec2/hardware_profiles_test.rb > b/server/tests/drivers/ec2/hardware_profiles_test.rb > index efafa72..1ec1664 100644 > --- a/server/tests/drivers/ec2/hardware_profiles_test.rb > +++ b/server/tests/drivers/ec2/hardware_profiles_test.rb > @@ -10,13 +10,13 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'should respond with HTTP_OK when accessing the :hardware_profiles > collection with authentication' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > last_response.status.must_equal 200 > end > > it 'should support the JSON media type' do > - auth_as_mock > + authenticate > header 'Accept', 'application/json' > get collection_url(:hardware_profiles) > last_response.status.must_equal 200 > @@ -24,25 +24,25 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must include the ETag in HTTP headers' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > last_response.headers['ETag'].wont_be_nil > end > > it 'must have the "hardware_profiles" element on top level' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > xml_response.root.name.must_equal 'hardware_profiles' > end > > it 'must have some "hardware_profile" elements inside "hardware_profiles"' > do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').wont_be_empty > end > > it 'must provide the :id attribute for each hardware_profile in > collection' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > r[:id].wont_be_nil > @@ -50,7 +50,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must include the :href attribute for each "hardware_profile" element > in collection' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > r[:href].wont_be_nil > @@ -58,7 +58,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must use the absolute URL in each :href attribute' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > r[:href].must_match /^http/ > @@ -66,7 +66,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must have the URL ending with the :id of the hardware_profile' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > r[:href].must_match /#{r[:id]}$/ > @@ -74,13 +74,13 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must return the list of valid parameters for the :index action' do > - auth_as_mock > + authenticate > options collection_url(:hardware_profiles) + '/index' > last_response.headers['Allow'].wont_be_nil > end > > it 'must have the "name" element defined for each hardware_profile in > collection' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > (r/'name').wont_be_empty > @@ -88,7 +88,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'should have the "property" element defined if not the opaque > hardware_profile' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -97,7 +97,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must define the :kind attribute for each "property" ' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -106,7 +106,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must define the :name attribute for each "property" ' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -115,7 +115,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must define the :unit attribute for each "property" ' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -124,7 +124,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must define the :value attribute for each "property" ' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -133,7 +133,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must define the "param" element if property kind is not "fixed"' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -151,7 +151,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must provide the list of valid values when the property is defined as > "enum"' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -164,7 +164,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must provide the range of valid values when the property is defined as > "range"' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -179,7 +179,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must provide the default value within the range if property defined as > "range"' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -191,7 +191,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must provide the default value that is included in enum list if > property defined as "enum"' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > next if r[:id] == 'opaque' > @@ -203,7 +203,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must return the full "hardware_profile" when following the URL in > hardware_profile element' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > get collection_url(:hardware_profiles) + '/' + r[:id] > @@ -212,7 +212,7 @@ describe 'Deltacloud API Hardware Profiles' do > end > > it 'must have the "name" element for the hardware_profile and it should > match with the one in collection' do > - auth_as_mock > + authenticate > get collection_url(:hardware_profiles) > (xml_response/'hardware_profiles/hardware_profile').each do |r| > get collection_url(:hardware_profiles) + '/' + r[:id] > diff --git a/server/tests/drivers/ec2/images_test.rb > b/server/tests/drivers/ec2/images_test.rb > index 34884fa..2529a01 100644 > --- a/server/tests/drivers/ec2/images_test.rb > +++ b/server/tests/drivers/ec2/images_test.rb > @@ -24,13 +24,13 @@ describe 'Deltacloud API Images' do > end > > it 'should respond with HTTP_OK when accessing the :images collection with > authentication' do > - auth_as_mock > + authenticate > get collection_url(:images) > last_response.status.must_equal 200 > end > > it 'should support the JSON media type' do > - auth_as_mock > + authenticate > header 'Accept', 'application/json' > get collection_url(:images) > last_response.status.must_equal 200 > @@ -38,25 +38,25 @@ describe 'Deltacloud API Images' do > end > > it 'must include the ETag in HTTP headers' do > - auth_as_mock > + authenticate > get collection_url(:images) > last_response.headers['ETag'].wont_be_nil > end > > it 'must have the "images" element on top level' do > - auth_as_mock > + authenticate > get collection_url(:images) > xml_response.root.name.must_equal 'images' > end > > it 'must have some "image" elements inside "images"' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').wont_be_empty > end > > it 'must provide the :id attribute for each image in collection' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').each do |r| > r[:id].wont_be_nil > @@ -64,7 +64,7 @@ describe 'Deltacloud API Images' do > end > > it 'must include the :href attribute for each "image" element in > collection' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').each do |r| > r[:href].wont_be_nil > @@ -72,7 +72,7 @@ describe 'Deltacloud API Images' do > end > > it 'must use the absolute URL in each :href attribute' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').each do |r| > r[:href].must_match /^http/ > @@ -80,7 +80,7 @@ describe 'Deltacloud API Images' do > end > > it 'must have the URL ending with the :id of the image' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').each do |r| > r[:href].must_match /#{r[:id]}$/ > @@ -88,13 +88,13 @@ describe 'Deltacloud API Images' do > end > > it 'must return the list of valid parameters for the :index action' do > - auth_as_mock > + authenticate > options collection_url(:images) + '/index' > last_response.headers['Allow'].wont_be_nil > end > > it 'must have the "name" element defined for each image in collection' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').each do |r| > (r/'name').wont_be_empty > @@ -102,7 +102,7 @@ describe 'Deltacloud API Images' do > end > > it 'must have the "state" element defined for each image in collection' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').each do |r| > (r/'state').wont_be_empty > @@ -110,7 +110,7 @@ describe 'Deltacloud API Images' do > end > > it 'must return the full "image" when following the URL in image element' > do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').wont_be_empty > (xml_response/'images/image')[0..10].each do |r| > @@ -122,7 +122,7 @@ describe 'Deltacloud API Images' do > end > > it 'must have the "name" element for the image and it should match with > the one in collection' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').wont_be_empty > (xml_response/'images/image')[0..10].each do |r| > @@ -135,7 +135,7 @@ describe 'Deltacloud API Images' do > end > > it 'must have the "name" element for the image and it should match with > the one in collection' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').wont_be_empty > (xml_response/'images/image')[0..10].each do |r| > @@ -148,7 +148,7 @@ describe 'Deltacloud API Images' do > end > > it 'should have the "owner_id" element for each image' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').wont_be_empty > (xml_response/'images/image')[0..10].each do |r| > @@ -160,7 +160,7 @@ describe 'Deltacloud API Images' do > end > > it 'should have the "description" element for each image' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').wont_be_empty > (xml_response/'images/image')[0..10].each do |r| > @@ -172,7 +172,7 @@ describe 'Deltacloud API Images' do > end > > it 'should have the "architecture" element for each image' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').wont_be_empty > (xml_response/'images/image')[0..10].each do |r| > @@ -184,7 +184,7 @@ describe 'Deltacloud API Images' do > end > > it 'should include the list of compatible hardware_profiles for each > image' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').wont_be_empty > (xml_response/'images/image')[0..10].each do |r| > @@ -203,7 +203,7 @@ describe 'Deltacloud API Images' do > end > > it 'should advertise the list of actions that can be executed for each > image' do > - auth_as_mock > + authenticate > get collection_url(:images) > (xml_response/'images/image').wont_be_empty > (xml_response/'images/image')[0..10].each do |r| > @@ -221,7 +221,7 @@ describe 'Deltacloud API Images' do > end > > it 'should give client HTML form to create new image' do > - auth_as_mock > + authenticate > header 'Accept', 'text/html' > get collection_url(:images) + '/new' > last_response.status.must_equal 200 > diff --git a/server/tests/drivers/ec2/instances_test.rb > b/server/tests/drivers/ec2/instances_test.rb > index e0388f0..c28fde6 100644 > --- a/server/tests/drivers/ec2/instances_test.rb > +++ b/server/tests/drivers/ec2/instances_test.rb > @@ -25,13 +25,13 @@ describe 'Deltacloud API instances' do > end > > it 'should respond with HTTP_OK when accessing the :instances collection > with authentication' do > - auth_as_mock > + authenticate > get collection_url(:instances) > last_response.status.must_equal 200 > end > > it 'should support the JSON media type' do > - auth_as_mock > + authenticate > header 'Accept', 'application/json' > get collection_url(:instances) > last_response.status.must_equal 200 > @@ -39,25 +39,25 @@ describe 'Deltacloud API instances' do > end > > it 'must include the ETag in HTTP headers' do > - auth_as_mock > + authenticate > get collection_url(:instances) > last_response.headers['ETag'].wont_be_nil > end > > it 'must have the "instances" element on top level' do > - auth_as_mock > + authenticate > get collection_url(:instances) > xml_response.root.name.must_equal 'instances' > end > > it 'must have some "instance" elements inside "instances"' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').wont_be_empty > end > > it 'must provide the :id attribute for each instance in collection' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > r[:id].wont_be_nil > @@ -65,7 +65,7 @@ describe 'Deltacloud API instances' do > end > > it 'must include the :href attribute for each "instance" element in > collection' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > r[:href].wont_be_nil > @@ -73,7 +73,7 @@ describe 'Deltacloud API instances' do > end > > it 'must use the absolute URL in each :href attribute' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > r[:href].must_match /^http/ > @@ -81,7 +81,7 @@ describe 'Deltacloud API instances' do > end > > it 'must have the URL ending with the :id of the instance' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > r[:href].must_match /#{r[:id]}$/ > @@ -89,13 +89,13 @@ describe 'Deltacloud API instances' do > end > > it 'must return the list of valid parameters for the :index action' do > - auth_as_mock > + authenticate > options collection_url(:instances) + '/index' > last_response.headers['Allow'].wont_be_nil > end > > it 'must have the "name" element defined for each instance in collection' > do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > (r/'name').wont_be_empty > @@ -103,7 +103,7 @@ describe 'Deltacloud API instances' do > end > > it 'must have the "state" element defined for each instance in collection' > do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > (r/'state').wont_be_empty > @@ -113,7 +113,7 @@ describe 'Deltacloud API instances' do > > > it 'must return the full "instance" when following the URL in instance > element' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -125,7 +125,7 @@ describe 'Deltacloud API instances' do > > > it 'must have the "name" element for the instance and it should match with > the one in collection' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -137,7 +137,7 @@ describe 'Deltacloud API instances' do > end > > it 'must have the "name" element for the instance and it should match with > the one in collection' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -149,7 +149,7 @@ describe 'Deltacloud API instances' do > end > > it 'must have the "owner_id" element for the instance and it should match > with the one in collection' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -161,7 +161,7 @@ describe 'Deltacloud API instances' do > end > > it 'must link to the realm that was used to during instance creation' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -176,7 +176,7 @@ describe 'Deltacloud API instances' do > end > > it 'must link to the image that was used to during instance creation' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -191,7 +191,7 @@ describe 'Deltacloud API instances' do > end > > it 'must link to the hardware_profile that was used to during instance > creation' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -206,7 +206,7 @@ describe 'Deltacloud API instances' do > end > > it 'should advertise the public and private addresses of the instance' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance[@state=RUNNING]').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -229,7 +229,7 @@ describe 'Deltacloud API instances' do > end > > it 'should advertise the storage volumes used by the instance' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -240,7 +240,7 @@ describe 'Deltacloud API instances' do > end > > it 'should advertise the list of actions that can be executed for each > instance' do > - auth_as_mock > + authenticate > get collection_url(:instances) > (xml_response/'instances/instance').each do |r| > VCR.use_cassette "#{__name__}_instance_#{r[:id]}" do > @@ -257,7 +257,7 @@ describe 'Deltacloud API instances' do > end > > it 'should allow to create and destroy new instance using the image > without realm' do > - auth_as_mock > + authenticate > image_id = 'ami-e565ba8c' > VCR.use_cassette "#{__name__}_create_instance" do > post collection_url(:instances), { :image_id => image_id } > @@ -288,7 +288,7 @@ describe 'Deltacloud API instances' do > end > > it 'should allow to create and destroy new instance using the image within > realm' do > - auth_as_mock > + authenticate > image_id = 'ami-e565ba8c' > realm_id = 'us-east-1c' > VCR.use_cassette "#{__name__}_create_instance" do > @@ -321,7 +321,7 @@ describe 'Deltacloud API instances' do > end > > it 'should allow to create and destroy new instance using the first > available image and first hardware_profile' do > - auth_as_mock > + authenticate > image_id = 'ami-e565ba8c' > hwp_id = 'm1.small' > VCR.use_cassette "#{__name__}_create_instance" do > diff --git a/server/tests/drivers/ec2/keys_test.rb > b/server/tests/drivers/ec2/keys_test.rb > index 814de38..efcdcc5 100644 > --- a/server/tests/drivers/ec2/keys_test.rb > +++ b/server/tests/drivers/ec2/keys_test.rb > @@ -25,13 +25,13 @@ describe 'Deltacloud API Keys' do > end > > it 'should respond with HTTP_OK when accessing the :keys collection with > authentication' do > - auth_as_mock > + authenticate > get collection_url(:keys) > last_response.status.must_equal 200 > end > > it 'should support the JSON media type' do > - auth_as_mock > + authenticate > header 'Accept', 'application/json' > get collection_url(:keys) > last_response.status.must_equal 200 > @@ -39,25 +39,25 @@ describe 'Deltacloud API Keys' do > end > > it 'must include the ETag in HTTP headers' do > - auth_as_mock > + authenticate > get collection_url(:keys) > last_response.headers['ETag'].wont_be_nil > end > > it 'must have the "keys" element on top level' do > - auth_as_mock > + authenticate > get collection_url(:keys) > xml_response.root.name.must_equal 'keys' > end > > it 'must have some "key" elements inside "keys"' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').wont_be_empty > end > > it 'must tell the kind of "key" elements inside "keys"' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |k| > k[:type].must_match /(key|password)/ > @@ -65,7 +65,7 @@ describe 'Deltacloud API Keys' do > end > > it 'must provide the :id attribute for each key in collection' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |r| > r[:id].wont_be_nil > @@ -73,7 +73,7 @@ describe 'Deltacloud API Keys' do > end > > it 'must include the :href attribute for each "key" element in collection' > do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |r| > r[:href].wont_be_nil > @@ -81,7 +81,7 @@ describe 'Deltacloud API Keys' do > end > > it 'must use the absolute URL in each :href attribute' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |r| > r[:href].must_match /^http/ > @@ -89,7 +89,7 @@ describe 'Deltacloud API Keys' do > end > > it 'must have the URL ending with the :id of the key' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |r| > r[:href].must_match /#{r[:id]}$/ > @@ -97,13 +97,13 @@ describe 'Deltacloud API Keys' do > end > > it 'must return the list of valid parameters for the :index action' do > - auth_as_mock > + authenticate > options collection_url(:keys) + '/index' > last_response.headers['Allow'].wont_be_nil > end > > it 'must have the "name" element defined for each key in collection' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |r| > (r/'name').wont_be_empty > @@ -112,7 +112,7 @@ describe 'Deltacloud API Keys' do > > > it 'must return the full "key" when following the URL in key element' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |r| > get collection_url(:keys) + '/' + r[:id] > @@ -121,7 +121,7 @@ describe 'Deltacloud API Keys' do > end > > it 'must have the "name" element for the key and it should match with the > one in collection' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |r| > VCR.use_cassette "#{__name__}_key_#{r[:id]}" do > @@ -133,7 +133,7 @@ describe 'Deltacloud API Keys' do > end > > it 'must have the "name" element for the key and it should match with the > one in collection' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |r| > VCR.use_cassette "#{__name__}_key_#{r[:id]}" do > @@ -145,7 +145,7 @@ describe 'Deltacloud API Keys' do > end > > it 'should advertise the list of actions that can be executed for each > key' do > - auth_as_mock > + authenticate > get collection_url(:keys) > (xml_response/'keys/key').each do |r| > VCR.use_cassette "#{__name__}_key_#{r[:id]}" do > @@ -162,7 +162,7 @@ describe 'Deltacloud API Keys' do > end > > it 'should allow to create a new key and then remove it' do > - auth_as_mock > + authenticate > key_name = Time.now.to_i.to_s > post collection_url(:keys), { > :name => 'test_key_'+key_name > diff --git a/server/tests/drivers/ec2/realms_test.rb > b/server/tests/drivers/ec2/realms_test.rb > index 8e8b325..9df854b 100644 > --- a/server/tests/drivers/ec2/realms_test.rb > +++ b/server/tests/drivers/ec2/realms_test.rb > @@ -24,13 +24,13 @@ describe 'Deltacloud API Realms' do > end > > it 'should respond with HTTP_OK when accessing the :realms collection with > authentication' do > - auth_as_mock > + authenticate > get collection_url(:realms) > last_response.status.must_equal 200 > end > > it 'should support the JSON media type' do > - auth_as_mock > + authenticate > header 'Accept', 'application/json' > get collection_url(:realms) > last_response.status.must_equal 200 > @@ -38,25 +38,25 @@ describe 'Deltacloud API Realms' do > end > > it 'must include the ETag in HTTP headers' do > - auth_as_mock > + authenticate > get collection_url(:realms) > last_response.headers['ETag'].wont_be_nil > end > > it 'must have the "realms" element on top level' do > - auth_as_mock > + authenticate > get collection_url(:realms) > xml_response.root.name.must_equal 'realms' > end > > it 'must have some "realm" elements inside "realms"' do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').wont_be_empty > end > > it 'must provide the :id attribute for each realm in collection' do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').each do |r| > r[:id].wont_be_nil > @@ -64,7 +64,7 @@ describe 'Deltacloud API Realms' do > end > > it 'must include the :href attribute for each "realm" element in > collection' do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').each do |r| > r[:href].wont_be_nil > @@ -72,7 +72,7 @@ describe 'Deltacloud API Realms' do > end > > it 'must use the absolute URL in each :href attribute' do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').each do |r| > r[:href].must_match /^http/ > @@ -80,7 +80,7 @@ describe 'Deltacloud API Realms' do > end > > it 'must have the URL ending with the :id of the realm' do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').each do |r| > r[:href].must_match /#{r[:id]}$/ > @@ -88,13 +88,13 @@ describe 'Deltacloud API Realms' do > end > > it 'must return the list of valid parameters for the :index action' do > - auth_as_mock > + authenticate > options collection_url(:realms) + '/index' > last_response.headers['Allow'].wont_be_nil > end > > it 'must have the "name" element defined for each realm in collection' do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').each do |r| > (r/'name').wont_be_empty > @@ -102,14 +102,14 @@ describe 'Deltacloud API Realms' do > end > > it 'must have the "state" element defined for each realm in collection' do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').each do |r| > (r/'state').wont_be_empty > end > end > it 'must return the full "realm" when following the URL in realm element' > do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').each do |r| > VCR.use_cassette "#{__name__}_realm_id" do > @@ -120,7 +120,7 @@ describe 'Deltacloud API Realms' do > end > > it 'must have the "name" element for the realm and it should match with > the one in collection' do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').each do |r| > VCR.use_cassette "#{__name__}_realm_#{r[:id]}" do > @@ -132,7 +132,7 @@ describe 'Deltacloud API Realms' do > end > > it 'must have the "state" element for the realm and it should match with > the one in collection' do > - auth_as_mock > + authenticate > get collection_url(:realms) > (xml_response/'realms/realm').each do |r| > VCR.use_cassette "#{__name__}_realm_r[:id]" do > -- > 1.7.6.5 > -- Michal Fojtik Sr. Software Engineer, Deltacloud API (http://deltacloud.org)
