You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2012/06/01 13:24:00 UTC

[PATCH 1/7] Refactor mock tests to use common api_test

From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/tests/drivers/mock/api_test.rb              |  112 +-------------------
 server/tests/drivers/mock/buckets_test.rb          |   36 +++---
 server/tests/drivers/mock/common.rb                |   49 +--------
 .../tests/drivers/mock/hardware_profiles_test.rb   |   46 ++++----
 server/tests/drivers/mock/images_test.rb           |   42 ++++----
 server/tests/drivers/mock/instances_test.rb        |   52 +++++-----
 server/tests/drivers/mock/keys_test.rb             |   34 +++---
 server/tests/drivers/mock/realms_test.rb           |   30 +++---
 .../tests/drivers/mock/storage_snapshots_test.rb   |   26 +++---
 server/tests/drivers/mock/storage_volumes_test.rb  |   28 +++---
 server/tests/minitest_common.rb                    |   48 ++++++++
 server/tests/minitest_common_api_test.rb           |  115 ++++++++++++++++++++
 12 files changed, 314 insertions(+), 304 deletions(-)
 create mode 100644 server/tests/minitest_common.rb
 create mode 100644 server/tests/minitest_common_api_test.rb

diff --git a/server/tests/drivers/mock/api_test.rb b/server/tests/drivers/mock/api_test.rb
index f8174b7..860c6d5 100644
--- a/server/tests/drivers/mock/api_test.rb
+++ b/server/tests/drivers/mock/api_test.rb
@@ -2,117 +2,9 @@ $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
 require 'tests/drivers/mock/common'
 
 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
+  include Deltacloud::Test
 
-  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/mock/buckets_test.rb b/server/tests/drivers/mock/buckets_test.rb
index d05a5fe..be30c18 100644
--- a/server/tests/drivers/mock/buckets_test.rb
+++ b/server/tests/drivers/mock/buckets_test.rb
@@ -15,13 +15,13 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'should respond with HTTP_OK when accessing the :buckets collection with authentication' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     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(:buckets)
     last_response.status.must_equal 200
@@ -29,25 +29,25 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must include the ETag in HTTP headers' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     last_response.headers['ETag'].wont_be_nil
   end
 
   it 'must have the "buckets" element on top level' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     xml_response.root.name.must_equal 'buckets'
   end
 
   it 'must have some "bucket" elements inside "buckets"' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').wont_be_empty
   end
 
   it 'must provide the :id attribute for each bucket in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       r[:id].wont_be_nil
@@ -55,7 +55,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must include the :href attribute for each "bucket" element in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       r[:href].wont_be_nil
@@ -63,7 +63,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must use the absolute URL in each :href attribute' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       r[:href].must_match /^http/
@@ -71,7 +71,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must have the URL ending with the :id of the bucket' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       r[:href].must_match /#{r[:id]}$/
@@ -79,13 +79,13 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must return the list of valid parameters for the :index action' do
-    auth_as_mock
+    authenticate
     options collection_url(:buckets) + '/index'
     last_response.headers['Allow'].wont_be_nil
   end
 
   it 'must have the "name" element defined for each bucket in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       (r/'name').wont_be_nil
@@ -93,7 +93,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must have the "state" element defined for each bucket in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       (r/'state').wont_be_nil
@@ -101,7 +101,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must return the full "bucket" when following the URL in bucket element' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       get collection_url(:buckets) + '/' + r[:id]
@@ -110,7 +110,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must have the "name" element for the bucket and it should match with the one in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       get collection_url(:buckets) + '/' + r[:id]
@@ -120,7 +120,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must have the "size" element for the bucket and it should match with the one in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       get collection_url(:buckets) + '/' + r[:id]
@@ -130,7 +130,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must have the "blob" elements for the bucket and it should match with the ones in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       get collection_url(:buckets) + '/' + r[:id]
@@ -145,7 +145,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must have the "blob" elements for the bucket and it should match with the ones in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       get collection_url(:buckets) + '/' + r[:id]
@@ -160,7 +160,7 @@ describe 'Deltacloud API buckets' do
   end
 
   it 'must allow to get all blobs details and the details should be set correctly' do
-    auth_as_mock
+    authenticate
     get collection_url(:buckets)
     (xml_response/'buckets/bucket').each do |r|
       get collection_url(:buckets) + '/' + r[:id]
diff --git a/server/tests/drivers/mock/common.rb b/server/tests/drivers/mock/common.rb
index a55c44f..a89e699 100644
--- a/server/tests/drivers/mock/common.rb
+++ b/server/tests/drivers/mock/common.rb
@@ -2,51 +2,6 @@ ENV['API_DRIVER']   = 'mock'
 ENV['API_USERNAME'] = 'mockuser'
 ENV['API_PASSWORD'] = 'mockpassword'
 
-load File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'deltacloud_rack.rb')
 
-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'
-
-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
-          use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
-          run Rack::Cascade.new([Deltacloud::API])
-        end
-      }
-    end
-  end
-end
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
+require 'tests/minitest_common'
diff --git a/server/tests/drivers/mock/hardware_profiles_test.rb b/server/tests/drivers/mock/hardware_profiles_test.rb
index 1af59ef..91c7c34 100644
--- a/server/tests/drivers/mock/hardware_profiles_test.rb
+++ b/server/tests/drivers/mock/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/mock/images_test.rb b/server/tests/drivers/mock/images_test.rb
index 0ab8db1..df866a0 100644
--- a/server/tests/drivers/mock/images_test.rb
+++ b/server/tests/drivers/mock/images_test.rb
@@ -15,13 +15,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
@@ -29,25 +29,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
@@ -55,7 +55,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
@@ -63,7 +63,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/
@@ -71,7 +71,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]}$/
@@ -79,13 +79,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
@@ -93,7 +93,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
@@ -101,7 +101,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').each do |r|
       get collection_url(:images) + '/' + r[:id]
@@ -110,7 +110,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').each do |r|
       get collection_url(:images) + '/' + r[:id]
@@ -120,7 +120,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').each do |r|
       get collection_url(:images) + '/' + r[:id]
@@ -130,7 +130,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').each do |r|
       get collection_url(:images) + '/' + r[:id]
@@ -139,7 +139,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').each do |r|
       get collection_url(:images) + '/' + r[:id]
@@ -148,7 +148,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').each do |r|
       get collection_url(:images) + '/' + r[:id]
@@ -157,7 +157,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').each do |r|
       get collection_url(:images) + '/' + r[:id]
@@ -173,7 +173,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').each do |r|
       get collection_url(:images) + '/' + r[:id]
@@ -188,7 +188,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/mock/instances_test.rb b/server/tests/drivers/mock/instances_test.rb
index d44fac5..f7c8550 100644
--- a/server/tests/drivers/mock/instances_test.rb
+++ b/server/tests/drivers/mock/instances_test.rb
@@ -15,13 +15,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
@@ -29,25 +29,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
@@ -55,7 +55,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
@@ -63,7 +63,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/
@@ -71,7 +71,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]}$/
@@ -79,13 +79,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
@@ -93,7 +93,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
@@ -102,7 +102,7 @@ describe 'Deltacloud API instances' do
   end
 
   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|
       get collection_url(:instances) + '/' + r[:id]
@@ -111,7 +111,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|
       get collection_url(:instances) + '/' + r[:id]
@@ -121,7 +121,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|
       get collection_url(:instances) + '/' + r[:id]
@@ -131,7 +131,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|
       get collection_url(:instances) + '/' + r[:id]
@@ -141,7 +141,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|
       get collection_url(:instances) + '/' + r[:id]
@@ -154,7 +154,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|
       get collection_url(:instances) + '/' + r[:id]
@@ -167,7 +167,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|
       get collection_url(:instances) + '/' + r[:id]
@@ -180,7 +180,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').each do |r|
       get collection_url(:instances) + '/' + r[:id]
@@ -200,7 +200,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|
       get collection_url(:instances) + '/' + r[:id]
@@ -209,7 +209,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|
       get collection_url(:instances) + '/' + r[:id]
@@ -224,7 +224,7 @@ describe 'Deltacloud API instances' do
   end
 
   it 'should allow to create and destroy new instance using the first available image without realm' do
-    auth_as_mock
+    authenticate
     get collection_url(:images)
     image_id = (xml_response/'images/image').first[:id]
     image_id.wont_be_nil
@@ -250,7 +250,7 @@ describe 'Deltacloud API instances' do
   end
 
   it 'should allow to create and destroy new instance using the first available image within first realm' do
-    auth_as_mock
+    authenticate
     get collection_url(:images)
     image_id = (xml_response/'images/image').first[:id]
     get collection_url(:realms)
@@ -281,7 +281,7 @@ describe 'Deltacloud API instances' do
   end
 
   it 'should allow to create and destroy new instance using the first available image with user defined name' do
-    auth_as_mock
+    authenticate
     get collection_url(:images)
     image_id = (xml_response/'images/image').first[:id]
     image_id.wont_be_nil
@@ -310,7 +310,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
     get collection_url(:images)
     image_id = (xml_response/'images/image').first[:id]
     get collection_url(:hardware_profiles)
diff --git a/server/tests/drivers/mock/keys_test.rb b/server/tests/drivers/mock/keys_test.rb
index 51d385b..ef358a5 100644
--- a/server/tests/drivers/mock/keys_test.rb
+++ b/server/tests/drivers/mock/keys_test.rb
@@ -15,13 +15,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
@@ -29,25 +29,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)/
@@ -55,7 +55,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
@@ -63,7 +63,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
@@ -71,7 +71,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/
@@ -79,7 +79,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]}$/
@@ -87,13 +87,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
@@ -102,7 +102,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]
@@ -111,7 +111,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|
       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|
       get collection_url(:keys) + '/' + r[:id]
@@ -131,7 +131,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|
       get collection_url(:keys) + '/' + r[:id]
@@ -146,7 +146,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/mock/realms_test.rb b/server/tests/drivers/mock/realms_test.rb
index 1540252..fe6094e 100644
--- a/server/tests/drivers/mock/realms_test.rb
+++ b/server/tests/drivers/mock/realms_test.rb
@@ -15,13 +15,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
@@ -29,25 +29,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
@@ -55,7 +55,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
@@ -63,7 +63,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/
@@ -71,7 +71,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]}$/
@@ -79,13 +79,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
@@ -93,7 +93,7 @@ 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
@@ -101,7 +101,7 @@ describe 'Deltacloud API Realms' do
   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|
       get collection_url(:realms) + '/' + r[:id]
@@ -110,7 +110,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|
       get collection_url(:realms) + '/' + r[:id]
@@ -120,7 +120,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|
       get collection_url(:realms) + '/' + r[:id]
diff --git a/server/tests/drivers/mock/storage_snapshots_test.rb b/server/tests/drivers/mock/storage_snapshots_test.rb
index 2df56cb..8676d14 100644
--- a/server/tests/drivers/mock/storage_snapshots_test.rb
+++ b/server/tests/drivers/mock/storage_snapshots_test.rb
@@ -15,13 +15,13 @@ describe 'Deltacloud API storage_snapshots' do
   end
 
   it 'should respond with HTTP_OK when accessing the :storage_snapshots collection with authentication' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     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(:storage_snapshots)
     last_response.status.must_equal 200
@@ -29,25 +29,25 @@ describe 'Deltacloud API storage_snapshots' do
   end
 
   it 'must include the ETag in HTTP headers' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     last_response.headers['ETag'].wont_be_nil
   end
 
   it 'must have the "storage_snapshots" element on top level' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     xml_response.root.name.must_equal 'storage_snapshots'
   end
 
   it 'must have some "storage_snapshot" elements inside "storage_snapshots"' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     (xml_response/'storage_snapshots/storage_snapshot').wont_be_empty
   end
 
   it 'must provide the :id attribute for each storage_snapshot in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     (xml_response/'storage_snapshots/storage_snapshot').each do |r|
       r[:id].wont_be_nil
@@ -55,7 +55,7 @@ describe 'Deltacloud API storage_snapshots' do
   end
 
   it 'must include the :href attribute for each "storage_snapshot" element in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     (xml_response/'storage_snapshots/storage_snapshot').each do |r|
       r[:href].wont_be_nil
@@ -63,7 +63,7 @@ describe 'Deltacloud API storage_snapshots' do
   end
 
   it 'must use the absolute URL in each :href attribute' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     (xml_response/'storage_snapshots/storage_snapshot').each do |r|
       r[:href].must_match /^http/
@@ -71,7 +71,7 @@ describe 'Deltacloud API storage_snapshots' do
   end
 
   it 'must have the URL ending with the :id of the storage_snapshot' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     (xml_response/'storage_snapshots/storage_snapshot').each do |r|
       r[:href].must_match /#{r[:id]}$/
@@ -79,13 +79,13 @@ describe 'Deltacloud API storage_snapshots' do
   end
 
   it 'must return the list of valid parameters for the :index action' do
-    auth_as_mock
+    authenticate
     options collection_url(:storage_snapshots) + '/index'
     last_response.headers['Allow'].wont_be_nil
   end
 
   it 'must have the "name" element defined for each storage_snapshot in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     (xml_response/'storage_snapshots/storage_snapshot').each do |r|
       (r/'name').wont_be_empty
@@ -93,7 +93,7 @@ describe 'Deltacloud API storage_snapshots' do
   end
 
   it 'must return the full "storage_snapshot" when following the URL in storage_snapshot element' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     (xml_response/'storage_snapshots/storage_snapshot').each do |r|
       get collection_url(:storage_snapshots) + '/' + r[:id]
@@ -102,7 +102,7 @@ describe 'Deltacloud API storage_snapshots' do
   end
 
   it 'must have the "name" element for the storage_snapshot and it should match with the one in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_snapshots)
     (xml_response/'storage_snapshots/storage_snapshot').each do |r|
       get collection_url(:storage_snapshots) + '/' + r[:id]
diff --git a/server/tests/drivers/mock/storage_volumes_test.rb b/server/tests/drivers/mock/storage_volumes_test.rb
index 7c41d38..62c9159 100644
--- a/server/tests/drivers/mock/storage_volumes_test.rb
+++ b/server/tests/drivers/mock/storage_volumes_test.rb
@@ -15,13 +15,13 @@ describe 'Deltacloud API storage_volumes' do
   end
 
   it 'should respond with HTTP_OK when accessing the :storage_volumes collection with authentication' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     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(:storage_volumes)
     last_response.status.must_equal 200
@@ -29,25 +29,25 @@ describe 'Deltacloud API storage_volumes' do
   end
 
   it 'must include the ETag in HTTP headers' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     last_response.headers['ETag'].wont_be_nil
   end
 
   it 'must have the "storage_volumes" element on top level' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     xml_response.root.name.must_equal 'storage_volumes'
   end
 
   it 'must have some "storage_volume" elements inside "storage_volumes"' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     (xml_response/'storage_volumes/storage_volume').wont_be_empty
   end
 
   it 'must provide the :id attribute for each storage_volume in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     (xml_response/'storage_volumes/storage_volume').each do |r|
       r[:id].wont_be_nil
@@ -55,7 +55,7 @@ describe 'Deltacloud API storage_volumes' do
   end
 
   it 'must include the :href attribute for each "storage_volume" element in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     (xml_response/'storage_volumes/storage_volume').each do |r|
       r[:href].wont_be_nil
@@ -63,7 +63,7 @@ describe 'Deltacloud API storage_volumes' do
   end
 
   it 'must use the absolute URL in each :href attribute' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     (xml_response/'storage_volumes/storage_volume').each do |r|
       r[:href].must_match /^http/
@@ -71,7 +71,7 @@ describe 'Deltacloud API storage_volumes' do
   end
 
   it 'must have the URL ending with the :id of the storage_volume' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     (xml_response/'storage_volumes/storage_volume').each do |r|
       r[:href].must_match /#{r[:id]}$/
@@ -79,13 +79,13 @@ describe 'Deltacloud API storage_volumes' do
   end
 
   it 'must return the list of valid parameters for the :index action' do
-    auth_as_mock
+    authenticate
     options collection_url(:storage_volumes) + '/index'
     last_response.headers['Allow'].wont_be_nil
   end
 
   it 'must have the "name" element defined for each storage_volume in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     (xml_response/'storage_volumes/storage_volume').each do |r|
       (r/'name').wont_be_empty
@@ -93,7 +93,7 @@ describe 'Deltacloud API storage_volumes' do
   end
 
   it 'must have the "state" element defined for each storage_volume in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     (xml_response/'storage_volumes/storage_volume').each do |r|
       (r/'state').wont_be_empty
@@ -101,7 +101,7 @@ describe 'Deltacloud API storage_volumes' do
   end
 
   it 'must return the full "storage_volume" when following the URL in storage_volume element' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     (xml_response/'storage_volumes/storage_volume').each do |r|
       get collection_url(:storage_volumes) + '/' + r[:id]
@@ -110,7 +110,7 @@ describe 'Deltacloud API storage_volumes' do
   end
 
   it 'must have the "name" element for the storage_volume and it should match with the one in collection' do
-    auth_as_mock
+    authenticate
     get collection_url(:storage_volumes)
     (xml_response/'storage_volumes/storage_volume').each do |r|
       get collection_url(:storage_volumes) + '/' + r[:id]
diff --git a/server/tests/minitest_common.rb b/server/tests/minitest_common.rb
new file mode 100644
index 0000000..8f54f2d
--- /dev/null
+++ b/server/tests/minitest_common.rb
@@ -0,0 +1,48 @@
+load File.join(File.dirname(__FILE__), '..', 'lib', 'deltacloud_rack.rb')
+
+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'
+
+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 authenticate
+      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
+          use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
+          run Rack::Cascade.new([Deltacloud::API])
+        end
+      }
+    end
+  end
+end
diff --git a/server/tests/minitest_common_api_test.rb b/server/tests/minitest_common_api_test.rb
new file mode 100644
index 0000000..21d18f7
--- /dev/null
+++ b/server/tests/minitest_common_api_test.rb
@@ -0,0 +1,115 @@
+#these are common MiniTest::Spec assertions
+#used across all drivers. See /drivers/*/api_test.rb
+
+  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
+    authenticate
+    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
+
+
-- 
1.7.6.5