deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [10/11] git commit: CIMI: Added initial support for CIMI collections tests
Date Tue, 07 Aug 2012 17:17:48 GMT
CIMI: Added initial support for CIMI collections tests


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/ad770cfc
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/ad770cfc
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/ad770cfc

Branch: refs/heads/master
Commit: ad770cfc51df7d35b7cc46c34be9c26aa99f573a
Parents: d7afc2a
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Tue Jul 31 14:32:15 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Aug 7 19:14:02 2012 +0200

----------------------------------------------------------------------
 server/Rakefile                                    |    2 +
 .../cimi/collections/cloud_entry_point_test.rb     |   46 +++++++++++++++
 server/tests/cimi/collections/common.rb            |   26 ++++++++
 .../tests/cimi/collections/machine_images_test.rb  |   44 ++++++++++++++
 server/tests/cimi/collections/machines_test.rb     |   41 +++++++++++++
 .../cimi/spec/cimi/model/machine_admin_spec.rb     |    3 +
 .../spec/cimi/model/machine_configuration_spec.rb  |    3 +-
 .../cimi/spec/cimi/model/machine_image_spec.rb     |    2 +
 server/tests/cimi/spec/cimi/model/machine_spec.rb  |    2 +
 .../cimi/spec/cimi/model/machine_template_spec.rb  |    2 +
 server/tests/cimi/spec/cimi/model/schema_spec.rb   |    2 +
 .../spec/cimi/model/volume_configuration_spec.rb   |    2 +
 .../cimi/spec/cimi/model/volume_image_spec.rb      |    2 +
 server/tests/cimi/spec/cimi/model/volume_spec.rb   |    2 +
 .../cimi/spec/cimi/model/volume_template_spec.rb   |    2 +
 server/tests/cimi/spec/spec_helper.rb              |    1 +
 16 files changed, 181 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/Rakefile
----------------------------------------------------------------------
diff --git a/server/Rakefile b/server/Rakefile
index ec3984b..184fe6c 100644
--- a/server/Rakefile
+++ b/server/Rakefile
@@ -185,11 +185,13 @@ namespace :test do
   namespace :cimi do
     Rake::TestTask.new(:models) do |t|
       t.ruby_opts << '-r./tests/cimi/spec/spec_helper.rb'    # Load SimpleCov when
COVERAGE=1 is set
+      t.ruby_opts << '-r./tests/test_helper.rb'    # Load SimpleCov when COVERAGE=1
is set
       unless RUBY_VERSION < '1.9.0'
         t.loader = :testrb
       end
       t.test_files = FileList[
         'tests/cimi/spec/cimi/model/*spec.rb',        # CIMI frontend serialization API tests
+        'tests/cimi/collections/*test.rb',        # CIMI frontend API tests
       ]
     end
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/collections/cloud_entry_point_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/collections/cloud_entry_point_test.rb b/server/tests/cimi/collections/cloud_entry_point_test.rb
new file mode 100644
index 0000000..95b09c1
--- /dev/null
+++ b/server/tests/cimi/collections/cloud_entry_point_test.rb
@@ -0,0 +1,46 @@
+require 'rubygems'
+require 'require_relative'
+
+require 'minitest/autorun'
+require_relative './common.rb'
+
+describe CIMI::Collections::CloudEntryPoint do
+
+  before do
+    def app; CIMI::API; end
+    @collection = CIMI::Collections.collection(:cloudEntryPoint)
+  end
+
+  it 'has index operation' do
+    @collection.operation(:index).must_equal Sinatra::Rabbit::CloudentrypointCollection::IndexOperation
+  end
+
+  it 'set the CIMI-Version header' do
+    get root_url
+    headers['X-CIMI-Specification-Version'].wont_be_nil
+    headers['X-CIMI-Specification-Version'].must_equal '1.0.0'
+  end
+
+  it 'advertise CIMI collections in XML format' do
+    get root_url + '/cloudEntryPoint'
+    xml.root.name.must_equal 'CloudEntryPoint'
+    (xml.root/'description').first.text.wont_be_empty
+    (xml.root/'id').first.text.wont_be_empty
+  end
+
+  it 'advertise CIMI collections in JSON format' do
+    get root_url + '/cloudEntryPoint?format=json'
+    json.wont_be_empty
+    json['description'].wont_be_empty
+    json['id'].wont_be_empty
+  end
+
+  it 'allow to force authentication using force_auth parameter in URI' do
+    get root_url + '/cloudEntryPoint?force_auth=1'
+    status.must_equal 401
+    authorize 'mockuser', 'mockpassword'
+    get root_url + '/cloudEntryPoint?force_auth=1'
+    status.must_equal 200
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/collections/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/collections/common.rb b/server/tests/cimi/collections/common.rb
new file mode 100644
index 0000000..0706dc4
--- /dev/null
+++ b/server/tests/cimi/collections/common.rb
@@ -0,0 +1,26 @@
+require_relative File.join('..', '..', '..', 'lib', 'deltacloud_rack.rb')
+
+unless Time.respond_to? :be
+  require_relative '../../test_helper.rb'
+end
+
+# Set the default driver used for server API tests
+#
+ENV['API_DRIVER'] = 'mock'
+
+# Setup Deltacloud::API Sinatra instance
+#
+unless Deltacloud::config[:cimi]
+  Deltacloud::configure(:cimi) do |server|
+    server.root_url '/cimi'
+    server.version '1.0.0'
+    server.klass 'CIMI::API'
+    server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
+  end
+
+  Deltacloud.require_frontend!(:cimi)
+end
+
+def root_url(url=''); Deltacloud.config[:cimi].root_url + url; end
+def formats; [ 'application/xml', 'application/json' ]; end
+def json; JSON::parse(response_body); end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/collections/machine_images_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/collections/machine_images_test.rb b/server/tests/cimi/collections/machine_images_test.rb
new file mode 100644
index 0000000..c5367a3
--- /dev/null
+++ b/server/tests/cimi/collections/machine_images_test.rb
@@ -0,0 +1,44 @@
+require 'rubygems'
+require 'require_relative'
+require 'minitest/autorun'
+require_relative './common.rb'
+
+describe CIMI::Collections::MachineImages do
+
+  before do
+    def app; CIMI::API; end
+    authorize 'mockuser', 'mockpassword'
+    @collection = CIMI::Collections.collection(:machine_images)
+  end
+
+  it 'has index operation' do
+    @collection.operation(:index).must_equal Sinatra::Rabbit::MachineImagesCollection::IndexOperation
+  end
+
+  it 'has show operation' do
+    @collection.operation(:show).must_equal Sinatra::Rabbit::MachineImagesCollection::ShowOperation
+  end
+
+  it 'returns list of images in various formats with index operation' do
+    formats.each do |format|
+      header 'Accept', format
+      get root_url + '/machine_images'
+      status.must_equal 200
+    end
+  end
+
+  it 'should allow to retrieve the single image' do
+    get root_url '/machine_images/img1'
+    status.must_equal 200
+    xml.root.name.must_equal 'MachineImage'
+  end
+
+  it 'should allow to filter using CIMISelect' do
+    get root_url '/machine_images?CIMISelect=description'
+    status.must_equal 200
+    xml.root.name.must_equal 'MachineImageCollection'
+    (xml/'description').wont_be_empty
+    (xml/'id').must_be_empty
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/collections/machines_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/collections/machines_test.rb b/server/tests/cimi/collections/machines_test.rb
new file mode 100644
index 0000000..328b712
--- /dev/null
+++ b/server/tests/cimi/collections/machines_test.rb
@@ -0,0 +1,41 @@
+require 'rubygems'
+require 'require_relative'
+require 'minitest/autorun'
+require_relative './common.rb'
+
+describe CIMI::Collections::Machines do
+
+  before do
+    def app; CIMI::API; end
+    authorize 'mockuser', 'mockpassword'
+    @collection = CIMI::Collections.collection(:machines)
+  end
+
+  it 'has index operation' do
+    @collection.operation(:index).must_equal Sinatra::Rabbit::MachinesCollection::IndexOperation
+  end
+
+  it 'has show operation' do
+    @collection.operation(:show).must_equal Sinatra::Rabbit::MachinesCollection::ShowOperation
+  end
+
+  it 'returns list of machines in various formats with index operation' do
+    formats.each do |format|
+      header 'Accept', format
+      get root_url + '/machines'
+      status.must_equal 200
+    end
+  end
+
+  it 'should allow to retrieve the single machine' do
+    get root_url '/machines/inst1'
+    status.must_equal 200
+    xml.root.name.must_equal 'Machine'
+  end
+
+  it 'should not return non-existing machine' do
+    get root_url '/machines/unknown-machine'
+    status.must_equal 404
+  end
+
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/machine_admin_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/machine_admin_spec.rb b/server/tests/cimi/spec/cimi/model/machine_admin_spec.rb
index 132272d..3fc272c 100644
--- a/server/tests/cimi/spec/cimi/model/machine_admin_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/machine_admin_spec.rb
@@ -14,6 +14,9 @@
 # under the License.
 #
 
+require 'rubygems'
+require 'require_relative'
+
 if require 'minitest/autorun'
   require_relative '../../spec_helper.rb'
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/machine_configuration_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/machine_configuration_spec.rb b/server/tests/cimi/spec/cimi/model/machine_configuration_spec.rb
index e59fcc0..f990871 100644
--- a/server/tests/cimi/spec/cimi/model/machine_configuration_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/machine_configuration_spec.rb
@@ -13,7 +13,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 #
-
+require 'rubygems'
+require 'require_relative'
 require_relative '../../spec_helper.rb' if require 'minitest/autorun'
 
 describe "MachineConfiguration model" do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/machine_image_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/machine_image_spec.rb b/server/tests/cimi/spec/cimi/model/machine_image_spec.rb
index 7eef29a..dd5ddbe 100644
--- a/server/tests/cimi/spec/cimi/model/machine_image_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/machine_image_spec.rb
@@ -13,6 +13,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 #
+require 'rubygems'
+require 'require_relative'
 
 require_relative '../../spec_helper.rb' if require 'minitest/autorun'
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/machine_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/machine_spec.rb b/server/tests/cimi/spec/cimi/model/machine_spec.rb
index b10ecfe..ad9f11e 100644
--- a/server/tests/cimi/spec/cimi/model/machine_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/machine_spec.rb
@@ -13,6 +13,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 #
+require 'rubygems'
+require 'require_relative'
 
 require_relative '../../spec_helper.rb' if require 'minitest/autorun'
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/machine_template_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/machine_template_spec.rb b/server/tests/cimi/spec/cimi/model/machine_template_spec.rb
index 7210c92..97bdce9 100644
--- a/server/tests/cimi/spec/cimi/model/machine_template_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/machine_template_spec.rb
@@ -13,6 +13,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 #
+require 'rubygems'
+require 'require_relative'
 
 require_relative '../../spec_helper.rb' if require 'minitest/autorun'
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/schema_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/schema_spec.rb b/server/tests/cimi/spec/cimi/model/schema_spec.rb
index c5619b1..8b6de48 100644
--- a/server/tests/cimi/spec/cimi/model/schema_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/schema_spec.rb
@@ -13,6 +13,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 #
+require 'rubygems'
+require 'require_relative'
 
 require_relative '../../spec_helper.rb' if require 'minitest/autorun'
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/volume_configuration_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/volume_configuration_spec.rb b/server/tests/cimi/spec/cimi/model/volume_configuration_spec.rb
index c12ac05..0f26edc 100644
--- a/server/tests/cimi/spec/cimi/model/volume_configuration_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/volume_configuration_spec.rb
@@ -14,6 +14,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 #
+require 'rubygems'
+require 'require_relative'
 
 require_relative '../../spec_helper.rb' if require 'minitest/autorun'
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/volume_image_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/volume_image_spec.rb b/server/tests/cimi/spec/cimi/model/volume_image_spec.rb
index a6c4a20..10509da 100644
--- a/server/tests/cimi/spec/cimi/model/volume_image_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/volume_image_spec.rb
@@ -13,6 +13,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 #
+require 'rubygems'
+require 'require_relative'
 
 require_relative '../../spec_helper.rb' if require 'minitest/autorun'
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/volume_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/volume_spec.rb b/server/tests/cimi/spec/cimi/model/volume_spec.rb
index 1176add..c3bad88 100644
--- a/server/tests/cimi/spec/cimi/model/volume_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/volume_spec.rb
@@ -13,6 +13,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 #
+require 'rubygems'
+require 'require_relative'
 
 require_relative '../../spec_helper.rb' if require 'minitest/autorun'
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/cimi/model/volume_template_spec.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/cimi/model/volume_template_spec.rb b/server/tests/cimi/spec/cimi/model/volume_template_spec.rb
index 444baa7..4bf969c 100644
--- a/server/tests/cimi/spec/cimi/model/volume_template_spec.rb
+++ b/server/tests/cimi/spec/cimi/model/volume_template_spec.rb
@@ -13,6 +13,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 #
+require 'rubygems'
+require 'require_relative'
 
 require_relative '../../spec_helper.rb' if require 'minitest/autorun'
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ad770cfc/server/tests/cimi/spec/spec_helper.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/spec/spec_helper.rb b/server/tests/cimi/spec/spec_helper.rb
index 3cde6cf..c2ea2d1 100644
--- a/server/tests/cimi/spec/spec_helper.rb
+++ b/server/tests/cimi/spec/spec_helper.rb
@@ -14,6 +14,7 @@
 # under the License.
 #
 
+require 'rubygems'
 require 'minitest/autorun'
 require 'minitest/spec'
 require 'xmlsimple'


Mime
View raw message