blob: f6d1fb9bc35708cc9a2828b6e3464b903597dbaa [file] [log] [blame]
Joe H. Rahme836da3f2013-10-09 15:47:16 +02001# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
2#
3# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17from tempest.api.object_storage import base
Daisuke Moritad206d3b2013-12-06 15:18:04 +090018from tempest.common import custom_matchers
Matthew Treinish20345382013-12-13 17:04:23 +000019from tempest import test
Sean Dague86bd8422013-12-20 09:56:44 -050020
Joe H. Rahme836da3f2013-10-09 15:47:16 +020021
22class CrossdomainTest(base.BaseObjectTest):
Joe H. Rahme836da3f2013-10-09 15:47:16 +020023
24 @classmethod
Andrea Frittoli5f13f712014-09-15 13:14:54 +010025 def resource_setup(cls):
26 super(CrossdomainTest, cls).resource_setup()
Joe H. Rahme836da3f2013-10-09 15:47:16 +020027
28 cls.xml_start = '<?xml version="1.0"?>\n' \
29 '<!DOCTYPE cross-domain-policy SYSTEM ' \
30 '"http://www.adobe.com/xml/dtds/cross-domain-policy.' \
31 'dtd" >\n<cross-domain-policy>\n'
32
33 cls.xml_end = "</cross-domain-policy>"
34
Joe H. Rahme836da3f2013-10-09 15:47:16 +020035 def setUp(self):
36 super(CrossdomainTest, self).setUp()
37
Joe H. Rahme836da3f2013-10-09 15:47:16 +020038 # Turning http://.../v1/foobar into http://.../
Daisuke Morita41a5cf42014-08-26 19:39:15 +090039 self.account_client.skip_path()
Joe H. Rahme836da3f2013-10-09 15:47:16 +020040
Matthew Treinish20345382013-12-13 17:04:23 +000041 @test.attr('gate')
42 @test.requires_ext(extension='crossdomain', service='object')
Joe H. Rahme836da3f2013-10-09 15:47:16 +020043 def test_get_crossdomain_policy(self):
Daisuke Morita41a5cf42014-08-26 19:39:15 +090044 resp, body = self.account_client.get("crossdomain.xml", {})
Joe H. Rahme836da3f2013-10-09 15:47:16 +020045
Matthew Treinish20345382013-12-13 17:04:23 +000046 self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
Joe H. Rahme836da3f2013-10-09 15:47:16 +020047 self.assertTrue(body.startswith(self.xml_start) and
48 body.endswith(self.xml_end))
Daisuke Moritad206d3b2013-12-06 15:18:04 +090049
50 # The target of the request is not any Swift resource. Therefore, the
51 # existence of response header is checked without a custom matcher.
52 self.assertIn('content-length', resp)
53 self.assertIn('content-type', resp)
54 self.assertIn('x-trans-id', resp)
55 self.assertIn('date', resp)
56 # Check only the format of common headers with custom matcher
57 self.assertThat(resp, custom_matchers.AreAllWellFormatted())