deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Lutterkort <lut...@redhat.com>
Subject Re: [PATCH 3/3] Common API (black box) collections tests for CIMI collections
Date Wed, 07 Nov 2012 00:47:30 GMT
On Mon, 2012-11-05 at 17:12 +0200, marios@redhat.com wrote:
> diff --git a/tests/cimi/common_tests_cimi_collections.rb b/tests/cimi/common_tests_cimi_collections.rb
> new file mode 100644
> index 0000000..db8b927
> --- /dev/null
> +++ b/tests/cimi/common_tests_cimi_collections.rb
> @@ -0,0 +1,94 @@
> +#
> +# Licensee 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.
> +
> +module CommonCIMICollectionsTest
> +
> +  #tests for only the collection, i.e. for 'Networks' but
> +  #not for each 'Network' element
> +  def self.run_collection_tests_for(test_collection)
> +    describe "CIMI common tests for #{test_collection.camelize.singularize} Collection"
do
> +
> +      it "should respond with HTTP_OK when accessing the #{test_collection} collection
with authentication" do
> +        res = get(test_collection)
> +        res.code.must_equal 200
> +      end
> +
> +      it 'should support the JSON media type' do
> +        res = get(test_collection, :accept=>:json)
> +        res.code.must_equal 200
> +        res.headers[:content_type].must_equal 'application/json'
> +        assert_silent {JSON.parse(res)}
> +      end

This is already done by the test harness when you use the 'model'
construct (for both XML and JSON)

> +      it "must require authentication to access the #{test_collection} collection" do
> +        proc {  get(test_collection, :noauth => true) }.must_raise RestClient::Request::Unauthorized
> +      end

We can not test anything around authorization, since the CIMI spec is
silent on the subject. In particular, it would be perfectly valid fora
provider to not require any auth (or require auth even for the CEP)

We'll have to hide auth details in the test harness, and feed it from
the config.yaml

> +      it "must have the #{test_collection.camelize.singularize} Collection element on
top level" do
> +        res = get(test_collection)
> +        res.xml.root.name.must_equal "Collection"
> +      end
> +
> +      it "must have the \"id\" and \"count\" attributes for the #{test_collection.camelize.singularize}
Collection" do
> +        res = get(test_collection)
> +        res.xml.at_xpath("/xmlns:Collection/xmlns:count").text.wont_be_empty
> +        res.xml.at_xpath("/xmlns:Collection/xmlns:id").text.wont_be_empty
> +      end

In general, the CIMI tests should test at the level of model objects,
not serializations so that we can run the same test against JSON and XML

David



Mime
View raw message