deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [16/65] [partial] Core: Moved all API tests in server/tests into server/tests/deprecated directory
Date Fri, 20 Jul 2012 09:59:21 GMT
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/common.rb b/server/tests/common.rb
deleted file mode 100644
index 4e77797..0000000
--- a/server/tests/common.rb
+++ /dev/null
@@ -1,279 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance with the
-# License.  You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-ENV.delete 'API_VERBOSE'
-
-$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
-$top_srcdir = File::dirname(File::dirname(__FILE__))
-
-require 'rubygems'
-require 'yaml'
-require 'rspec/core'
-require 'rspec/matchers'
-require 'test/unit'
-require 'nokogiri'
-require 'json'
-require 'digest/sha1'
-require 'base64'
-require 'rack/test'
-
-load File.join(File.dirname(__FILE__), '..', 'lib', 'deltacloud_rack.rb')
-
-Deltacloud::configure do |server|
-  server.root_url '/api'
-  server.version '1.0.0'
-  server.klass 'Deltacloud::API'
-end.require_frontend!
-
-# Set proper environment variables for running test
-
-ENV['RACK_ENV']     = 'test'
-ENV['API_HOST']     = 'localhost'
-ENV['API_PORT']     = '4040'
-
-RSpec.configure do |conf|
-  conf.include Rack::Test::Methods
-  conf.expect_with :rspec
-end
-
-module DeltacloudTestCommon
-
-  def recording?
-    @use_recording
-  end
-
-  def record!
-    @use_recording = true
-  end
-
-
-  # Authentication helper for Basic HTTP authentication
-  # To change default user credentials stored in ENV['API_USER|PASSWORD'] you
-  # need to set opts[:credentials] = { :user => '...', :password => '...'}
-  #
-  def authenticate(opts={})
-    credentials = opts[:credentials] || { :user => ENV['API_USER'], :password => ENV['API_PASSWORD']}
-    return {
-      'HTTP_AUTHORIZATION' => "Basic " + Base64.encode64("#{credentials[:user]}:#{credentials[:password]}")
-    }
-  end
-
-  # HTTP Accept header helper.
-  # Will set appropriate value for this header.
-  # Available options for format are: :json, :html or :xml
-  # By default :xml is used
-  #
-  def accept(format=:xml)
-    case format
-      when :json then 'application/json;q=0.9'
-      when :html then 'text/html;q=0.9'
-      when :xml then 'application/xml;q=0.9'
-      else 'application/xml;q=0.9'
-    end
-  end
-
-  # This helper will execute GET operation on given URI.
-  # You can set additional parameters using params Hash, which will be passed to
-  # request.
-  # You can change format used for communication using opts[:format] = :xml | :html :json
-  # You can turn on recording (you need to configure it first in setup.rb) using
-  # opts[:record] (true/false)
-  # You can force authentication using opts[:auth] parameter or use
-  # 'get_auth_url' which will do it for you ;-)
-  #
-  def get_url(uri, params={}, opts={})
-    header 'Accept', accept(opts[:format] || :xml)
-    if DeltacloudTestCommon::recording?
-      VCR.use_cassette("get-" + Digest::SHA1.hexdigest("#{uri}-#{params}}")) do
-        get(uri, params || {}, opts[:auth] ? authenticate(opts) : {})
-      end
-    else
-      get(uri, params || {}, opts[:auth] ? authenticate(opts) : {})
-      if last_response.status.to_s =~ /5(\d{2})/
-        puts "============= [ ERROR ] ================"
-        puts last_response.body
-        puts "============= [ RESPONSE ] ================"
-        puts last_response.errors
-        puts "========================================"
-      end
-    end
-    last_response.status.should_not == 401
-  end
-
-  def get_auth_url(uri, params={}, opts={})
-    opts.merge!(:auth => true)
-    get_url(uri, params, opts)
-    if last_response.status.to_s =~ /5(\d{2})/
-      puts "============= [ ERROR ] ================"
-      puts last_response.body
-      puts "============= [ RESPONSE ] ================"
-      puts last_response.errors
-      puts "========================================"
-    end
-  end
-
-  def post_url(uri, params={}, opts={})
-    header 'Accept', accept(opts[:format] || :xml)
-    if DeltacloudTestCommon::recording?
-      if opts['vcr_cassette']
-        VCR.use_cassette(opts['vcr_cassette']) do
-          post(uri, params || {}, authenticate(opts))
-        end
-      else
-        VCR.use_cassette("post-" + Digest::SHA1.hexdigest("#{uri}-#{params}")) do
-          post(uri, params || {}, authenticate(opts))
-        end
-      end
-    else
-      post(uri, params || {}, authenticate(opts))
-      if last_response.status.to_s =~ /5(\d{2})/
-        puts "============= [ ERROR ] ================"
-        puts last_response.body
-        puts "============= [ RESPONSE ] ================"
-        puts last_response.errors
-        puts "========================================"
-      end
-    end
-  end
-
-  def delete_url(uri, params={}, opts={})
-    header 'Accept', accept(opts[:format] || :xml)
-    if DeltacloudTestCommon::recording?
-      VCR.use_cassette("delete-"+Digest::SHA1.hexdigest("#{uri}-#{params}")) do
-        delete(uri, params || {}, authenticate(opts))
-      end
-    else
-      delete(uri, params || {}, authenticate(opts))
-      if last_response.status.to_s =~ /5(\d{2})/
-        puts "============= [ ERROR ] ================"
-        puts last_response.body
-        puts "============= [ RESPONSE ] ================"
-        puts last_response.errors
-      end
-    end
-  end
-
-  def head_url(uri, params={}, opts={})
-    header 'Accept', accept(opts[:format] || :xml)
-    if DeltacloudTestCommon::recording?
-      VCR.use_cassette("head-"+Digest::SHA1.hexdigest("#{uri}-#{params}")) do
-        head(uri, params || {}, authenticate(opts))
-      end
-    else
-       head(uri, params || {}, authenticate(opts))
-      if last_response.status.to_s =~ /5(\d{2})/
-        puts "============= [ ERROR ] ================"
-        puts last_response.inspect
-        puts "========================================"
-      end
-    end
-  end
-
-  def put_url(uri, params={}, opts={})
-    header 'Accept', accept(opts[:format] || :xml)
-    if DeltacloudTestCommon::recording?
-      VCR.use_cassette("put-"+Digest::SHA1.hexdigest("#{uri}-#{params}-#{authenticate(opts)}")) do
-        put(uri, params || {}, authenticate(opts))
-      end
-    else
-       put(uri, params || {}, authenticate(opts))
-      if last_response.status.to_s =~ /5(\d{2})/
-        puts "============= [ ERROR ] ================"
-        puts last_response.body
-        puts "============= [ RESPONSE ] ================"
-        puts last_response.errors
-      end
-    end
-  end
-
-  # This helper will automatically convert output from method above to Nokogiri
-  # XML object
-  def last_xml_response
-    Nokogiri::XML(last_response.body) #if last_response.status.to_s =~ /2(\d+)/
-  end
-
-  # Check if given URI require authentication
-  def require_authentication?(uri)
-    # We need to make sure we don't have both API_USER and API_PASSWORD
-    # set in the environment; otherwise LazyAuth will use those instead
-    # of asking for credentials
-    api_user = ENV.delete("API_USER")
-    get uri, {}
-    ENV["API_USER"] = api_user
-    last_response.status == 401
-  end
-
-  def with_provider(new_provider, &block)
-    old_provider = ENV["API_PROVIDER"]
-    begin
-      ENV["API_PROVIDER"] = new_provider
-      yield
-    ensure
-      ENV["API_PROVIDER"] = old_provider
-    end
-  end
-
-  def add_created_instance(id)
-    $created_instances ||= []
-    $created_instances << id
-  end
-
- #common variables used by the bucket/blob unit tests across clouds
-  @@created_bucket_name="testbucki2rpux3wdelme"
-  @@created_blob_name="testblobk1ds91kVdelme"
-  @@created_blob_local_file="#{File.dirname(__FILE__)}/drivers/common_fixtures/deltacloud_blob_test.png"
-
-  def check_bucket_basics(bucket, cloud)
-    (bucket/'bucket/name').first.text.should == "#{@@created_bucket_name}#{cloud}"
-    (bucket/'bucket').attribute("id").text.should == "#{@@created_bucket_name}#{cloud}"
-    (bucket/'bucket').length.should > 0
-    (bucket/'bucket/name').first.text.should_not == nil
-    (bucket/'bucket').attribute("href").text.should_not == nil
-  end
-
-  def check_blob_basics(blob, cloud)
-    (blob/'blob').length.should == 1
-    (blob/'blob').attribute("id").text.should_not == nil
-    (blob/'blob').attribute("href").text.should_not==nil
-    (blob/'blob/bucket').text.should_not == nil
-    (blob/'blob/content_length').text.should_not == nil
-    (blob/'blob/content_type').text.should_not == nil
-    (blob/'blob').attribute("id").text.should == "#{@@created_blob_name}#{cloud}"
-    (blob/'blob/bucket').text.should == "#{@@created_bucket_name}#{cloud}"
-    (blob/'blob/content_length').text.to_i.should == File.size(@@created_blob_local_file)
-  end
-
-  def check_blob_metadata(blob, metadata_hash)
-    meta_from_blob = {}
-    #extract metadata from nokogiri blob xml
-    (0.. (((blob/'blob/user_metadata').first).elements.size - 1) ).each do |i|
-      meta_from_blob[(((blob/'blob/user_metadata').first).elements[i].attribute("key").value)] =
-                                  (((blob/'blob/user_metadata').first).elements[i].children[1].text)
-    end
-    #remove any 'x-goog-meta-' prefixes (problem for google blobs and vcr...)
-    meta_from_blob.gsub_keys(/x-.*-meta-/i, "")
-    meta_from_blob.eql?(metadata_hash).should == true
-  end
-
-  #hash ordering is unpredictable - sort the params hash
-  #so we get same vcr cassette name each time
-  def stable_vcr_cassette_name(method, uri, params)
-    digest = Digest::SHA1.hexdigest("#{uri}-#{params.sort_by {|k,v| k.to_s}}")
-    return "#{method}-#{digest}"
-  end
-
-end
-
-include DeltacloudTestCommon

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/core_ext/string.rb
----------------------------------------------------------------------
diff --git a/server/tests/core_ext/string.rb b/server/tests/core_ext/string.rb
deleted file mode 100644
index dfa57dc..0000000
--- a/server/tests/core_ext/string.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance with the
-# License.  You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-
-$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', '..')
-require 'tests/common'
-
-require 'deltacloud/drivers'
-require 'deltacloud/drivers/mock/mock_driver'
-
-module DeltacloudUnitTest
-
-  class StringTest < Test::Unit::TestCase
-    def test_camelize
-      "hello_camel".camelize.should == "helloCamel"
-      "hello_camel_lots_of_humps".camelize.should == "helloCamelLotsOfHumps"
-    end
-  end
-end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/api/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/api/common.rb b/server/tests/deprecated/api/common.rb
new file mode 100644
index 0000000..3554a81
--- /dev/null
+++ b/server/tests/deprecated/api/common.rb
@@ -0,0 +1 @@
+require 'minitest/autorun'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/api/driver_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/api/driver_test.rb b/server/tests/deprecated/api/driver_test.rb
new file mode 100644
index 0000000..c9facbf
--- /dev/null
+++ b/server/tests/deprecated/api/driver_test.rb
@@ -0,0 +1,79 @@
+require_relative './common'
+require_relative '../../lib/deltacloud/api'
+
+begin
+  require 'arguments'
+rescue LoadError
+  puts "You don't have 'rdp-arguments' gems installed. (gem install rdp-arguments)"
+  exit(1)
+end
+require 'pp'
+
+describe 'Deltacloud drivers API' do
+
+  before do
+    @stderr = $stderr.clone
+    $stderr = StringIO.new
+  end
+
+  after do
+    $stderr = @stderr
+  end
+
+  it 'should pass the known method to Deltacloud driver' do
+    Deltacloud.new(:mock).hardware_profiles.must_be_kind_of Array
+    Deltacloud.new(:mock).hardware_profiles.wont_be_empty
+  end
+
+  it 'should raise NoMethodError when driver does not respond to method' do
+    lambda { Deltacloud.new(:mock).non_existing_method }.must_raise NoMethodError
+  end
+
+  it 'should apply the credentials to methods that require them' do
+    Deltacloud.new(:mock).realms.must_be_kind_of Array
+    Deltacloud.new(:mock).realms.wont_be_empty
+  end
+
+  it 'should allow to use different drivers' do
+    Deltacloud.new(:ec2).backend.must_be_instance_of Deltacloud::Drivers::Ec2::Ec2Driver
+    Deltacloud.new(:mock).backend.must_be_instance_of Deltacloud::Drivers::Mock::MockDriver
+  end
+
+  it 'should support loading all supported drivers' do
+    Deltacloud.drivers.keys.each do |key|
+      Deltacloud.new(key).current_driver.must_equal key.to_s
+    end
+  end
+
+  METHODS = {
+    :firewalls => [[:credentials], [:opts, "{  }"]],
+    :firewall  => [[:credentials], [:opts, "{  }"]],
+    :keys    => [[:credentials], [:opts, "{  }"]],
+    :key     => [[:credentials], [:opts]],
+    :storage_snapshots => [[:credentials], [:opts, "{  }"]],
+    :storage_snapshot  => [[:credentials], [:opts]],
+    :storage_volumes => [[:credentials], [:opts, "{  }"]],
+    :storage_volume  => [[:credentials], [:opts]],
+    :realms    => [[:credentials], [:opts, "{  }"]],
+    :realm     => [[:credentials], [:opts]],
+    :images    => [[:credentials], [:opts, "{  }"]],
+    :image     => [[:credentials], [:opts]],
+    :instances => [[:credentials], [:opts, "{  }"]],
+    :instance  => [[:credentials], [:opts]],
+    :create_instance => [[:credentials], [:image_id], [:opts, "{  }"]],
+    :destroy_instance => [[:credentials], [:id]],
+    :stop_instance => [[:credentials], [:id]],
+    :start_instance => [[:credentials], [:id]],
+    :reboot_instance => [[:credentials], [:id]],
+  }
+
+  Deltacloud.drivers.keys.each do |key|
+    METHODS.each do |m, definition|
+      it "should have the correct parameters for the :#{m} method in #{key} driver" do
+        next unless Deltacloud.new(key).backend.respond_to? m
+        Arguments.names(Deltacloud.new(key).backend.class, m).must_equal definition
+      end
+    end
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/api/library_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/api/library_test.rb b/server/tests/deprecated/api/library_test.rb
new file mode 100644
index 0000000..025ece6
--- /dev/null
+++ b/server/tests/deprecated/api/library_test.rb
@@ -0,0 +1,48 @@
+require_relative './common'
+require_relative '../../lib/deltacloud/api'
+
+require 'pp'
+
+describe 'Deltacloud API Library' do
+
+  it 'should return the driver configuration' do
+    Deltacloud.must_respond_to :drivers
+    Deltacloud.drivers.wont_be_nil
+    Deltacloud.drivers.must_be_kind_of Hash
+  end
+
+  it 'should be constructed just using the driver parameter' do
+    Deltacloud.new(:mock).must_be_instance_of Deltacloud::Library
+    Deltacloud.new(:mock).current_provider.must_be_nil
+    Deltacloud.new(:mock).current_driver.must_equal 'mock'
+    Deltacloud.new(:mock).backend.must_be_instance_of Deltacloud::Drivers::Mock::MockDriver
+    Deltacloud.new(:mock).credentials.user.must_equal 'mockuser'
+    Deltacloud.new(:mock).credentials.password.must_equal 'mockpassword'
+  end
+
+  it 'should allow to set credentials' do
+    Deltacloud.new(:mock, :user => 'testuser', :password => 'testpassword').credentials.user.must_equal 'testuser'
+    Deltacloud.new(:mock, :user => 'testuser', :password => 'testpassword').credentials.password.must_equal 'testpassword'
+  end
+
+  it 'should allow to set the provider' do
+    Deltacloud.new(:mock, :provider => 'someprovider').current_provider.must_equal 'someprovider'
+    Deltacloud.new(:mock).current_provider.must_be_nil
+  end
+
+  it 'should return pre-defined providers for the driver' do
+    Deltacloud.new(:ec2).providers[:entrypoints].must_be_kind_of Hash
+  end
+
+  it 'should yield the backend driver' do
+    Deltacloud.new :mock do |mock|
+      mock.must_be_instance_of Deltacloud::Drivers::Mock::MockDriver
+    end
+  end
+
+  it 'should return the API version' do
+    Deltacloud::API_VERSION.wont_be_empty
+    Deltacloud::new(:mock).version.wont_be_empty
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/cimi/features/machine_images.feature
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/cimi/features/machine_images.feature b/server/tests/deprecated/cimi/features/machine_images.feature
new file mode 100644
index 0000000..8d1afcd
--- /dev/null
+++ b/server/tests/deprecated/cimi/features/machine_images.feature
@@ -0,0 +1,20 @@
+Feature: Managing Machines Images
+  In order to interact with the provider
+  We must first be provided a URL to the main entry point (CEP).
+
+Scenario: Listing Machine Images collection
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client lists Machine Images collection
+    Then client should get list of all Machine Images
+
+Scenario: Querying Machine Image
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client query for 'img1' Machine Image entity
+    Then client should verify that this Machine Image exists
+    And client should verify that this Machine Image has set
+      | *image_location | mock://img1 |
+      | description     | Fedora 10   |
+      | name            | img1        |
+      | id              | http://example.org/cimi/machine_images/img1 |

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/cimi/features/machines.feature
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/cimi/features/machines.feature b/server/tests/deprecated/cimi/features/machines.feature
new file mode 100644
index 0000000..08934ad
--- /dev/null
+++ b/server/tests/deprecated/cimi/features/machines.feature
@@ -0,0 +1,46 @@
+Feature: Managing Machines
+  In order to interact with the provider
+  We must first be provided a URL to the main entry point (CEP).
+
+  Scenario: Create a New Machine entity
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client specifies a Machine Image
+      | machineImage | http://example.com/cimi/machine_images/img1 |
+    And client specifies a Machine Configuration
+      |   machineConfig | http://example.com/cimi/machine_configurations/m1-small |
+    And client specifies a new Machine using
+      | name | sampleMachine1 |
+      | description | sampleMachine1Description |
+    Then client should be able to create this Machine
+
+  Scenario: Querying created Machine entity
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client query for created Machine entity
+    Then client should verify that this Machine exists
+    And client should verify that this Machine has been created properly
+      | cpu         | 1                         |
+      | memory      | 1740.8                    |
+      | state       | STARTED                   |
+
+  Scenario: Stopping created Machine entity
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client executes stop operation on created Machine
+    Then client query for created Machine entity
+    And client should verify that this machine is stopped
+
+  Scenario: Starting created Machine entity
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client executes start operation on created Machine
+    Then client query for created Machine entity
+    And client should verify that this machine is started
+
+  Scenario: Deleting created Machine entity
+    Given Cloud Entry Point URL is provided
+    And client retrieve the Cloud Entry Point
+    When client executes delete operation on created Machine
+    Then client query for created Machine entity
+    And client should verify that this machine is deleted

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/cimi/features/step_definitions/common_steps.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/cimi/features/step_definitions/common_steps.rb b/server/tests/deprecated/cimi/features/step_definitions/common_steps.rb
new file mode 100644
index 0000000..8fb3ff8
--- /dev/null
+++ b/server/tests/deprecated/cimi/features/step_definitions/common_steps.rb
@@ -0,0 +1,59 @@
+World(Rack::Test::Methods)
+
+Given /^Cloud Entry Point URL is provided$/ do
+  get '/cimi'
+  last_response.status.should == 301
+  last_response.location.should == "http://example.org/cimi/cloudEntryPoint"
+end
+
+Given /^client retrieve the Cloud Entry Point$/ do
+  get "/cimi/cloudEntryPoint"
+  header 'Accept', 'application/xml'
+  last_response.status.should == 200
+end
+
+When /^client lists ([\w ]+) collection$/ do |col_name|
+  authorize 'mockuser', 'mockpassword'
+  header 'Accept', 'application/xml'
+  get "/cimi/%s" % col_name.to_collection_uri
+  last_response.status.should == 200
+end
+
+Then /^client should get list of all ([\w ]+)$/ do |col_name|
+  root_name = "#{col_name.to_collection_name}Collection"
+  last_xml_response.root.name.should == root_name
+  (last_xml_response/"#{root_name}/name").size.should == 1
+  (last_xml_response/"#{root_name}/name").first.text.should == 'default'
+  (last_xml_response/"#{root_name}/id").size.should == 1
+  (last_xml_response/"#{root_name}/id").first.text.should == last_request.url
+  (last_xml_response/"#{root_name}/#{col_name.to_entity_name}").size.should == 3
+  (last_xml_response/"#{root_name}/#{col_name.to_entity_name}").each do |machine_img|
+    machine_img[:href].should_not be_nil
+    machine_img[:href].should =~ /http:\/\/example\.org\/cimi\/#{col_name.to_collection_uri}\/img(\d)/
+  end
+end
+
+When /^client( should be able to)? query for '(\w+)' ([\w ]+) entity$/ do |s, entity_id, entity_name|
+  authorize 'mockuser', 'mockpassword'
+  header 'Accept', 'application/xml'
+  get "/cimi/%s/%s" % [entity_name.to_entity_uri, entity_id]
+  last_response.status.should == 200
+  @entity_id = entity_id
+end
+
+Then /^client should verify that this ([\w ]+) exists$/ do |entity_name|
+  root_name = entity_name.to_class_name
+  last_xml_response.root.name.should == root_name
+  @entity = last_xml_response
+end
+
+Then /^client should verify that this ([\w ]+) has set$/ do |entity, attrs|
+  model = CIMI::Model.const_get(entity.to_class_name).from_xml(last_response.body)
+  attrs.rows_hash.each do |key, value|
+    if key =~ /^\*/
+      model.send(key.gsub(/^\*/, '').intern).href.should == value
+    else
+      model.send(key.intern).to_s.should == value
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/cimi/features/step_definitions/machine_images_steps.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/cimi/features/step_definitions/machine_images_steps.rb b/server/tests/deprecated/cimi/features/step_definitions/machine_images_steps.rb
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/cimi/features/step_definitions/machines_steps.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/cimi/features/step_definitions/machines_steps.rb b/server/tests/deprecated/cimi/features/step_definitions/machines_steps.rb
new file mode 100644
index 0000000..c11d535
--- /dev/null
+++ b/server/tests/deprecated/cimi/features/step_definitions/machines_steps.rb
@@ -0,0 +1,100 @@
+When /^client specifies a Machine Image$/ do |machine_image|
+  header 'Accept', 'application/xml'
+  authorize 'mockuser', 'mockpassword'
+  get machine_image.raw[0][1]
+  last_response.status.should == 200
+  @machine_image = CIMI::Model::MachineImage.from_xml(last_response.body)
+  @machine_image.should_not be_nil
+  @machine_image.id.should == machine_image.raw[0][1]
+end
+
+When /^client specifies a Machine Configuration$/ do |machine_conf|
+  header 'Accept', 'application/xml'
+  authorize 'mockuser', 'mockpassword'
+  get machine_conf.raw[0][1]
+  last_response.status.should == 200
+  @machine_configuration = CIMI::Model::MachineImage.from_xml(last_response.body)
+  @machine_configuration.should_not be_nil
+  @machine_configuration.id.should == machine_conf.raw[0][1]
+end
+
+When /^client specifies a new Machine using$/ do |machine|
+  @machine_image.should_not be_nil
+  @machine_configuration.should_not be_nil
+  @new_machine_name = machine.raw[0][1]
+  @builder = Nokogiri::XML::Builder.new do |xml|
+    xml.MachineCreate(:xmlns => CMWG_NAMESPACE) {
+      xml.name @new_machine_name
+      xml.description machine.raw[1][1]
+      xml.machineTemplate {
+        xml.machineConfig( :href => @machine_configuration.id )
+        xml.machineImage( :href => @machine_image.id )
+      }
+    }
+  end
+end
+
+Then /^client should be able to create this Machine$/ do
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  post '/cimi/machines', @builder.to_xml
+  if [500, 501, 502].include? last_response.status
+    puts last_response.body
+  end
+  last_response.status.should == 201
+  set_new_machine(CIMI::Model::Machine.from_xml(last_response.body))
+end
+
+Then /^client query for created Machine entity$/ do
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  get "/cimi/machines/%s" % new_machine.name
+  if [500, 501, 502].include? last_response.status
+    puts last_response.body
+  end
+  if @delete_operation
+    last_response.status.should == 404
+  else
+    last_response.status.should == 200
+    @machine = CIMI::Model::Machine.from_xml(last_response.body)
+    @machine.name.should == new_machine.name
+  end
+
+end
+
+Then /^client should verify that this Machine has been created properly$/ do |attrs|
+  attrs.rows_hash.each do |key, value|
+    if key == 'memory'
+      @machine.memory['quantity'].to_s.should == value
+    else
+      @machine.send(key.intern).to_s.should == value
+    end
+  end
+end
+
+When /^client executes (\w+) operation on created Machine$/ do |operation|
+  builder = Nokogiri::XML::Builder.new do |xml|
+    xml.Action(:xmlns => CMWG_NAMESPACE) {
+      xml.action "http://www.dmtf.org/cimi/action/#{operation}"
+    }
+  end
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  if operation == 'delete'
+    delete "/cimi/machines/%s" % new_machine.name
+    puts last_response.body
+    last_response.status.should == 200
+    last_response.body.should be_empty
+    @delete_operation = true
+  else
+    post "/cimi/machines/%s/%s" % [new_machine.name, operation], builder.to_xml
+    last_response.status.should == 202
+    last_response.body.should be_empty
+  end
+end
+
+Then /^client should verify that this machine is (\w+)$/ do |status|
+  unless @delete_operation
+    @machine.state.should == status.upcase
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb b/server/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb
new file mode 100644
index 0000000..fc93be0
--- /dev/null
+++ b/server/tests/deprecated/cimi/features/step_definitions/volumes_steps.rb
@@ -0,0 +1,115 @@
+When /^client specifies a Volume Configuration$/ do |volume_config|
+  header 'Accept', 'application/xml'
+  authorize 'mockuser', 'mockpassword'
+  get volume_config.raw[0][1]
+  last_response.status.should==200
+  @volume_config = CIMI::Model::VolumeConfiguration.from_xml(last_response.body)
+  @volume_config.class.should == CIMI::Model::VolumeConfiguration
+  @volume_config.attribute_values[:capacity].quantity.should == "2"
+  @volume_config.id.should == volume_config.raw[0][1]
+end
+
+When /^client specifies a new Volume using$/ do |volume|
+  @volume_config.should_not be_nil
+  volume_name = volume.raw[0][1]
+  volume_description = volume.raw[1][1]
+  @builder = Nokogiri::XML::Builder.new do |xml|
+    xml.Volume(:xmlns => CMWG_NAMESPACE) {
+      xml.name volume_name
+      xml.description volume_description
+      xml.volumeTemplate {
+        xml.volumeConfig( :href => @volume_config.id )
+      }
+    }
+  end
+end
+
+Then /^client should be able to create this Volume$/ do
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  post '/cimi/volumes', @builder.to_xml
+  last_response.status.should == 200
+  @@created_volume = CIMI::Model::Volume.from_xml(last_response.body)
+end
+
+When /^client GET the Volumes Collection$/ do
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  get "/cimi/volumes"
+  last_response.status.should == 200
+  @@volume_collection = CIMI::Model::VolumeCollection.from_xml(last_response.body)
+end
+
+Then /^client should get a list of volumes$/ do
+  @@volume_collection.id.end_with?("/cimi/volumes").should == true
+  @@volume_collection.attribute_values.has_key?(:volumes).should == true
+end
+
+Then /^list of volumes should contain newly created volume$/ do
+  volumes = @@volume_collection.attribute_values[:volumes].map{|v| v.href.split("/").last}
+  volumes.include?(@@created_volume.name).should == true
+end
+
+When /^client GET the newly created Volume in json format$/ do
+  authorize 'mockuser', 'mockpassword'
+  get "/cimi/volumes/#{@@created_volume.name}?format=json"
+  last_response.status.should == 200
+  @@retrieved_volume = CIMI::Model::Volume.from_json(last_response.body)
+end
+
+Then /^client should verify that this Volume was created correctly$/ do |capacity|
+  @@retrieved_volume.name.should == @@created_volume.name
+  @@retrieved_volume.id.should == @@created_volume.id
+  @@retrieved_volume.capacity[:quantity].should == capacity.raw[0][1]
+end
+
+When /^client specifies a running Machine using$/ do |machine|
+  @machine_id = machine.raw[0][1]
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/xml'
+  get "/cimi/machines/#{@machine_id}?format=xml"
+  last_response.status.should==200
+  @@machine = CIMI::Model::Machine.from_xml(last_response.body)
+  @@machine.name.should == @machine_id
+  @@machine.state.should == "STARTED"
+end
+
+When /^client specifies the new Volume with attachment point using$/ do |attach|
+  @builder = Nokogiri::XML::Builder.new do |xml|
+    xml.VolumeAttach {
+      xml.volume( :href => @@created_volume.id, :attachmentPoint=>attach.raw[0][1])
+    }
+  end
+end
+
+Then /^client should be able to attach the new volume to the Machine$/ do
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/CIMI-Machine+xml'
+  put "/cimi/machines/#{@@machine.name}/attach_volume?format=xml", @builder.to_xml
+  last_response.status.should == 200
+end
+
+When /^client should be able to detach the volume$/ do
+  authorize 'mockuser', 'mockpassword'
+  header 'Content-Type', 'application/CIMI-Machine+xml'
+  @builder = Nokogiri::XML::Builder.new do |xml|
+    xml.VolumeDetach {
+      xml.volume(:href => @@created_volume.id)
+    }
+  end
+  put "/cimi/machines/#{@@machine.name}/detach_volume", @builder.to_xml
+  last_response.status.should == 200
+end
+
+When /^client deletes the newly created Volume$/ do
+  authorize 'mockuser', 'mockpassword'
+  delete "/cimi/volumes/#{@@created_volume.name}"
+  last_response.status.should == 200
+end
+
+Then /^client should verify the volume was deleted$/ do
+  authorize 'mockuser', 'mockpassword'
+  get "/cimi/volumes/#{@@created_volume.name}"
+  last_response.status.should == 404
+end
+

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/cimi/features/support/env.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/cimi/features/support/env.rb b/server/tests/deprecated/cimi/features/support/env.rb
new file mode 100644
index 0000000..f8372bf
--- /dev/null
+++ b/server/tests/deprecated/cimi/features/support/env.rb
@@ -0,0 +1,75 @@
+require 'rubygems'
+require 'nokogiri'
+require 'rack/test'
+
+ENV['API_FRONTEND'] = 'cimi'
+
+load File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'deltacloud_rack.rb')
+
+Deltacloud::configure do |server|
+  server.root_url '/cimi'
+  server.version '1.0.0'
+  server.klass 'CIMI::API'
+end.require_frontend!
+
+def last_xml_response
+  Nokogiri::XML(last_response.body)
+end
+
+class IndexEntrypoint < Sinatra::Base
+  get "/" do
+    redirect Deltacloud[:root_url], 301
+  end
+end
+
+=begin
+def app
+  Rack::URLMap.new(
+    "/" => IndexEntrypoint.new,
+    Deltacloud[:root_url] => CIMI::API,
+    "/stylesheets" =>  Rack::Directory.new( "public/stylesheets" ),
+    "/javascripts" =>  Rack::Directory.new( "public/javascripts" )
+  )
+end
+=end
+
+def app
+  Rack::Builder.new {
+    map '/' do
+      use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public"
+      run Rack::Cascade.new([CIMI::API])
+    end
+  }
+end
+
+def new_machine
+  @@new_machine
+end
+
+def set_new_machine(machine)
+  @@new_machine = machine
+end
+
+class String
+
+  def to_class_name
+    to_collection_name
+  end
+
+  def to_entity_name
+    to_collection_name.uncapitalize
+  end
+
+  def to_collection_name
+    self.tr(' ', '').singularize
+  end
+
+  def to_collection_uri
+    self.tr(' ', '_').downcase
+  end
+
+  def to_entity_uri
+    to_collection_uri.pluralize
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/cimi/features/volumes.feature
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/cimi/features/volumes.feature b/server/tests/deprecated/cimi/features/volumes.feature
new file mode 100644
index 0000000..7835e2a
--- /dev/null
+++ b/server/tests/deprecated/cimi/features/volumes.feature
@@ -0,0 +1,46 @@
+Feature: CIMI Volumes Collection
+  The URI of the Volumes collection is given in the Cloud Entry Point.
+
+Scenario: Create a new Volume entity
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  When client specifies a Volume Configuration
+    | volumeConfig | http://example.com/cimi/volume_configurations/2 |
+  And client specifies a new Volume using
+    | name | cucumber_volume |
+    | description | created in a cucumber scenario |
+  Then client should be able to create this Volume
+
+Scenario: Query the Volume collection
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  When client GET the Volumes Collection
+  Then client should get a list of volumes
+  And list of volumes should contain newly created volume
+
+Scenario: Query the newly created Volume
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  When client GET the newly created Volume in json format
+  Then client should verify that this Volume was created correctly
+    | capacity | 2 |
+
+Scenario: Attach the newly created Volume to a Machine
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  When client specifies a running Machine using
+    | name | inst0 |
+  And client specifies the new Volume with attachment point using
+    | attachment_point | /dev/sdc |
+  Then client should be able to attach the new volume to the Machine
+
+Scenario: Detach the newly created Volume from the Machine
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  Then client should be able to detach the volume
+
+Scenario: Delete the newly created Volume
+  Given Cloud Entry Point URL is provided
+  And client retrieve the Cloud Entry Point
+  When client deletes the newly created Volume
+  Then client should verify the volume was deleted

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/common.rb b/server/tests/deprecated/common.rb
new file mode 100644
index 0000000..4e77797
--- /dev/null
+++ b/server/tests/deprecated/common.rb
@@ -0,0 +1,279 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+ENV.delete 'API_VERBOSE'
+
+$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+$top_srcdir = File::dirname(File::dirname(__FILE__))
+
+require 'rubygems'
+require 'yaml'
+require 'rspec/core'
+require 'rspec/matchers'
+require 'test/unit'
+require 'nokogiri'
+require 'json'
+require 'digest/sha1'
+require 'base64'
+require 'rack/test'
+
+load File.join(File.dirname(__FILE__), '..', 'lib', 'deltacloud_rack.rb')
+
+Deltacloud::configure do |server|
+  server.root_url '/api'
+  server.version '1.0.0'
+  server.klass 'Deltacloud::API'
+end.require_frontend!
+
+# Set proper environment variables for running test
+
+ENV['RACK_ENV']     = 'test'
+ENV['API_HOST']     = 'localhost'
+ENV['API_PORT']     = '4040'
+
+RSpec.configure do |conf|
+  conf.include Rack::Test::Methods
+  conf.expect_with :rspec
+end
+
+module DeltacloudTestCommon
+
+  def recording?
+    @use_recording
+  end
+
+  def record!
+    @use_recording = true
+  end
+
+
+  # Authentication helper for Basic HTTP authentication
+  # To change default user credentials stored in ENV['API_USER|PASSWORD'] you
+  # need to set opts[:credentials] = { :user => '...', :password => '...'}
+  #
+  def authenticate(opts={})
+    credentials = opts[:credentials] || { :user => ENV['API_USER'], :password => ENV['API_PASSWORD']}
+    return {
+      'HTTP_AUTHORIZATION' => "Basic " + Base64.encode64("#{credentials[:user]}:#{credentials[:password]}")
+    }
+  end
+
+  # HTTP Accept header helper.
+  # Will set appropriate value for this header.
+  # Available options for format are: :json, :html or :xml
+  # By default :xml is used
+  #
+  def accept(format=:xml)
+    case format
+      when :json then 'application/json;q=0.9'
+      when :html then 'text/html;q=0.9'
+      when :xml then 'application/xml;q=0.9'
+      else 'application/xml;q=0.9'
+    end
+  end
+
+  # This helper will execute GET operation on given URI.
+  # You can set additional parameters using params Hash, which will be passed to
+  # request.
+  # You can change format used for communication using opts[:format] = :xml | :html :json
+  # You can turn on recording (you need to configure it first in setup.rb) using
+  # opts[:record] (true/false)
+  # You can force authentication using opts[:auth] parameter or use
+  # 'get_auth_url' which will do it for you ;-)
+  #
+  def get_url(uri, params={}, opts={})
+    header 'Accept', accept(opts[:format] || :xml)
+    if DeltacloudTestCommon::recording?
+      VCR.use_cassette("get-" + Digest::SHA1.hexdigest("#{uri}-#{params}}")) do
+        get(uri, params || {}, opts[:auth] ? authenticate(opts) : {})
+      end
+    else
+      get(uri, params || {}, opts[:auth] ? authenticate(opts) : {})
+      if last_response.status.to_s =~ /5(\d{2})/
+        puts "============= [ ERROR ] ================"
+        puts last_response.body
+        puts "============= [ RESPONSE ] ================"
+        puts last_response.errors
+        puts "========================================"
+      end
+    end
+    last_response.status.should_not == 401
+  end
+
+  def get_auth_url(uri, params={}, opts={})
+    opts.merge!(:auth => true)
+    get_url(uri, params, opts)
+    if last_response.status.to_s =~ /5(\d{2})/
+      puts "============= [ ERROR ] ================"
+      puts last_response.body
+      puts "============= [ RESPONSE ] ================"
+      puts last_response.errors
+      puts "========================================"
+    end
+  end
+
+  def post_url(uri, params={}, opts={})
+    header 'Accept', accept(opts[:format] || :xml)
+    if DeltacloudTestCommon::recording?
+      if opts['vcr_cassette']
+        VCR.use_cassette(opts['vcr_cassette']) do
+          post(uri, params || {}, authenticate(opts))
+        end
+      else
+        VCR.use_cassette("post-" + Digest::SHA1.hexdigest("#{uri}-#{params}")) do
+          post(uri, params || {}, authenticate(opts))
+        end
+      end
+    else
+      post(uri, params || {}, authenticate(opts))
+      if last_response.status.to_s =~ /5(\d{2})/
+        puts "============= [ ERROR ] ================"
+        puts last_response.body
+        puts "============= [ RESPONSE ] ================"
+        puts last_response.errors
+        puts "========================================"
+      end
+    end
+  end
+
+  def delete_url(uri, params={}, opts={})
+    header 'Accept', accept(opts[:format] || :xml)
+    if DeltacloudTestCommon::recording?
+      VCR.use_cassette("delete-"+Digest::SHA1.hexdigest("#{uri}-#{params}")) do
+        delete(uri, params || {}, authenticate(opts))
+      end
+    else
+      delete(uri, params || {}, authenticate(opts))
+      if last_response.status.to_s =~ /5(\d{2})/
+        puts "============= [ ERROR ] ================"
+        puts last_response.body
+        puts "============= [ RESPONSE ] ================"
+        puts last_response.errors
+      end
+    end
+  end
+
+  def head_url(uri, params={}, opts={})
+    header 'Accept', accept(opts[:format] || :xml)
+    if DeltacloudTestCommon::recording?
+      VCR.use_cassette("head-"+Digest::SHA1.hexdigest("#{uri}-#{params}")) do
+        head(uri, params || {}, authenticate(opts))
+      end
+    else
+       head(uri, params || {}, authenticate(opts))
+      if last_response.status.to_s =~ /5(\d{2})/
+        puts "============= [ ERROR ] ================"
+        puts last_response.inspect
+        puts "========================================"
+      end
+    end
+  end
+
+  def put_url(uri, params={}, opts={})
+    header 'Accept', accept(opts[:format] || :xml)
+    if DeltacloudTestCommon::recording?
+      VCR.use_cassette("put-"+Digest::SHA1.hexdigest("#{uri}-#{params}-#{authenticate(opts)}")) do
+        put(uri, params || {}, authenticate(opts))
+      end
+    else
+       put(uri, params || {}, authenticate(opts))
+      if last_response.status.to_s =~ /5(\d{2})/
+        puts "============= [ ERROR ] ================"
+        puts last_response.body
+        puts "============= [ RESPONSE ] ================"
+        puts last_response.errors
+      end
+    end
+  end
+
+  # This helper will automatically convert output from method above to Nokogiri
+  # XML object
+  def last_xml_response
+    Nokogiri::XML(last_response.body) #if last_response.status.to_s =~ /2(\d+)/
+  end
+
+  # Check if given URI require authentication
+  def require_authentication?(uri)
+    # We need to make sure we don't have both API_USER and API_PASSWORD
+    # set in the environment; otherwise LazyAuth will use those instead
+    # of asking for credentials
+    api_user = ENV.delete("API_USER")
+    get uri, {}
+    ENV["API_USER"] = api_user
+    last_response.status == 401
+  end
+
+  def with_provider(new_provider, &block)
+    old_provider = ENV["API_PROVIDER"]
+    begin
+      ENV["API_PROVIDER"] = new_provider
+      yield
+    ensure
+      ENV["API_PROVIDER"] = old_provider
+    end
+  end
+
+  def add_created_instance(id)
+    $created_instances ||= []
+    $created_instances << id
+  end
+
+ #common variables used by the bucket/blob unit tests across clouds
+  @@created_bucket_name="testbucki2rpux3wdelme"
+  @@created_blob_name="testblobk1ds91kVdelme"
+  @@created_blob_local_file="#{File.dirname(__FILE__)}/drivers/common_fixtures/deltacloud_blob_test.png"
+
+  def check_bucket_basics(bucket, cloud)
+    (bucket/'bucket/name').first.text.should == "#{@@created_bucket_name}#{cloud}"
+    (bucket/'bucket').attribute("id").text.should == "#{@@created_bucket_name}#{cloud}"
+    (bucket/'bucket').length.should > 0
+    (bucket/'bucket/name').first.text.should_not == nil
+    (bucket/'bucket').attribute("href").text.should_not == nil
+  end
+
+  def check_blob_basics(blob, cloud)
+    (blob/'blob').length.should == 1
+    (blob/'blob').attribute("id").text.should_not == nil
+    (blob/'blob').attribute("href").text.should_not==nil
+    (blob/'blob/bucket').text.should_not == nil
+    (blob/'blob/content_length').text.should_not == nil
+    (blob/'blob/content_type').text.should_not == nil
+    (blob/'blob').attribute("id").text.should == "#{@@created_blob_name}#{cloud}"
+    (blob/'blob/bucket').text.should == "#{@@created_bucket_name}#{cloud}"
+    (blob/'blob/content_length').text.to_i.should == File.size(@@created_blob_local_file)
+  end
+
+  def check_blob_metadata(blob, metadata_hash)
+    meta_from_blob = {}
+    #extract metadata from nokogiri blob xml
+    (0.. (((blob/'blob/user_metadata').first).elements.size - 1) ).each do |i|
+      meta_from_blob[(((blob/'blob/user_metadata').first).elements[i].attribute("key").value)] =
+                                  (((blob/'blob/user_metadata').first).elements[i].children[1].text)
+    end
+    #remove any 'x-goog-meta-' prefixes (problem for google blobs and vcr...)
+    meta_from_blob.gsub_keys(/x-.*-meta-/i, "")
+    meta_from_blob.eql?(metadata_hash).should == true
+  end
+
+  #hash ordering is unpredictable - sort the params hash
+  #so we get same vcr cassette name each time
+  def stable_vcr_cassette_name(method, uri, params)
+    digest = Digest::SHA1.hexdigest("#{uri}-#{params.sort_by {|k,v| k.to_s}}")
+    return "#{method}-#{digest}"
+  end
+
+end
+
+include DeltacloudTestCommon

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/core_ext/string.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/core_ext/string.rb b/server/tests/deprecated/core_ext/string.rb
new file mode 100644
index 0000000..dfa57dc
--- /dev/null
+++ b/server/tests/deprecated/core_ext/string.rb
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', '..')
+require 'tests/common'
+
+require 'deltacloud/drivers'
+require 'deltacloud/drivers/mock/mock_driver'
+
+module DeltacloudUnitTest
+
+  class StringTest < Test::Unit::TestCase
+    def test_camelize
+      "hello_camel".camelize.should == "helloCamel"
+      "hello_camel_lots_of_humps".camelize.should == "helloCamelLotsOfHumps"
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/drivers/common_fixtures/deltacloud_blob_test.png
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/drivers/common_fixtures/deltacloud_blob_test.png b/server/tests/deprecated/drivers/common_fixtures/deltacloud_blob_test.png
new file mode 100644
index 0000000..bf1b766
Binary files /dev/null and b/server/tests/deprecated/drivers/common_fixtures/deltacloud_blob_test.png differ

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/drivers/ec2/api_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/drivers/ec2/api_test.rb b/server/tests/deprecated/drivers/ec2/api_test.rb
new file mode 100644
index 0000000..eefc40a
--- /dev/null
+++ b/server/tests/deprecated/drivers/ec2/api_test.rb
@@ -0,0 +1,19 @@
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
+require 'tests/drivers/ec2/common'
+
+describe 'Deltacloud API' do
+
+  before do
+    Timecop.freeze(FREEZED_TIME)
+    VCR.insert_cassette __name__
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  include Deltacloud::Test
+
+  eval File.read('tests/minitest_common_api_test.rb')
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/drivers/ec2/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/drivers/ec2/common.rb b/server/tests/deprecated/drivers/ec2/common.rb
new file mode 100644
index 0000000..3e1486c
--- /dev/null
+++ b/server/tests/deprecated/drivers/ec2/common.rb
@@ -0,0 +1,23 @@
+ENV['API_DRIVER']   = 'ec2'
+ENV['TESTS_API_USERNAME'] = 'AKIAIZ63KHGXIWDMBY6Q'
+ENV['TESTS_API_PASSWORD'] = 'zUfBCbML2S6pXKS44eEEXw0Cf/G8z9hMSxP2hcLV'
+ENV['RACK_ENV']     = 'test'
+
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
+require 'tests/minitest_common'
+
+require 'vcr'
+require 'timecop'
+
+VCR.configure do |c|
+  c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures')
+  c.hook_into :webmock
+  c.default_cassette_options = { :record => :new_episodes }
+  #c.default_cassette_options = { :record => :none }
+end
+
+# Let's set time that timecop will use to freeze
+# Time.now will then return this time instead of 'real' system time
+
+FREEZED_TIME = DateTime.parse("2012-05-31 12:58:00 +0200")
+Timecop.freeze(FREEZED_TIME)

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/570a9a04/server/tests/deprecated/drivers/ec2/drivers_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/deprecated/drivers/ec2/drivers_test.rb b/server/tests/deprecated/drivers/ec2/drivers_test.rb
new file mode 100644
index 0000000..dc702c0
--- /dev/null
+++ b/server/tests/deprecated/drivers/ec2/drivers_test.rb
@@ -0,0 +1,120 @@
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..')
+require 'tests/drivers/ec2/common'
+
+describe 'Deltacloud API drivers' do
+  include Deltacloud::Test
+  before do
+    Timecop.freeze(FREEZED_TIME)
+    VCR.insert_cassette __name__
+  end
+
+  after do
+    VCR.eject_cassette
+  end
+
+  it 'must advertise have the drivers collection in API entrypoint' do
+    get root_url
+    (xml_response/'api/link[@rel=drivers]').wont_be_empty
+  end
+
+  it 'must not require authentication to access the "driver" collection' do
+    get collection_url(:drivers)
+    last_response.status.must_equal 200
+  end
+
+  it 'should respond with HTTP_OK when accessing the :drivers collection with authentication' do
+    get collection_url(:drivers)
+    last_response.status.must_equal 200
+  end
+
+  it 'should support the JSON media type' do
+    header 'Accept', 'application/json'
+    get collection_url(:drivers)
+    last_response.status.must_equal 200
+    last_response.headers['Content-Type'].must_equal 'application/json'
+  end
+
+  it 'must include the ETag in HTTP headers' do
+    get collection_url(:drivers)
+    last_response.headers['ETag'].wont_be_nil
+  end
+
+  it 'must have the "drivers" element on top level' do
+    get collection_url(:drivers)
+    xml_response.root.name.must_equal 'drivers'
+  end
+
+  it 'must have some "driver" elements inside "drivers"' do
+    get collection_url(:drivers)
+    (xml_response/'drivers/driver').wont_be_empty
+  end
+
+  it 'must provide the :id attribute for each driver in collection' do
+    get collection_url(:drivers)
+    (xml_response/'drivers/driver').each do |r|
+      r[:id].wont_be_nil
+    end
+  end
+
+  it 'must include the :href attribute for each "driver" element in collection' do
+    get collection_url(:drivers)
+    (xml_response/'drivers/driver').each do |r|
+      r[:href].wont_be_nil
+    end
+  end
+
+  it 'must use the absolute URL in each :href attribute' do
+    get collection_url(:drivers)
+    (xml_response/'drivers/driver').each do |r|
+      r[:href].must_match /^http/
+    end
+  end
+
+  it 'must have the URL ending with the :id of the driver' do
+    get collection_url(:drivers)
+    (xml_response/'drivers/driver').each do |r|
+      r[:href].must_match /#{r[:id]}$/
+    end
+  end
+
+  it 'must return the list of valid parameters for the :index action' do
+    options collection_url(:drivers) + '/index'
+    last_response.headers['Allow'].wont_be_nil
+  end
+
+  it 'must have the "name" element defined for each driver in collection' do
+    get collection_url(:drivers)
+    (xml_response/'drivers/driver').each do |r|
+      (r/'name').wont_be_nil
+    end
+  end
+
+
+  it 'must return the full "driver" when following the URL in driver element' do
+    authenticate
+    get collection_url(:drivers)
+    (xml_response/'drivers/driver').each do |r|
+      get collection_url(:drivers) + '/' + r[:id]
+      last_response.status.must_equal 200
+    end
+  end
+
+  it 'must have the "name" element for the driver and it should match with the one in collection' do
+    authenticate
+    get collection_url(:drivers)
+    (xml_response/'drivers/driver').each do |r|
+      r[:id].wont_be_nil
+      get collection_url(:drivers) + '/' + r[:id]
+      (xml_response/'name').wont_be_empty
+      (xml_response/'name').first.text.must_equal((r/'name').first.text)
+    end
+  end
+
+  it 'should advertise available providers for some drivers' do
+    get collection_url(:drivers)
+    (xml_response/'drivers/driver/provider').each do |p|
+      p[:id].wont_be_nil
+    end
+  end
+
+end


Mime
View raw message