blob: f61d9f8911a28324de3bdf7ba692a80aae8274b4 [file] [log] [blame]
Joe H. Rahme836da3f2013-10-09 15:47:16 +02001# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
2#
Joe H. Rahme836da3f2013-10-09 15:47:16 +02003# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tempest.api.object_storage import base
Daisuke Moritad206d3b2013-12-06 15:18:04 +090016from tempest.common import custom_matchers
Andrea Frittolicd368412017-08-14 21:37:56 +010017from tempest.common import utils
Ken'ichi Ohmichib7bc1de2017-01-27 18:12:22 -080018from tempest.lib import decorators
Sean Dague86bd8422013-12-20 09:56:44 -050019
Joe H. Rahme836da3f2013-10-09 15:47:16 +020020
21class CrossdomainTest(base.BaseObjectTest):
Joe H. Rahme836da3f2013-10-09 15:47:16 +020022
23 @classmethod
Andrea Frittoli5f13f712014-09-15 13:14:54 +010024 def resource_setup(cls):
25 super(CrossdomainTest, cls).resource_setup()
Joe H. Rahme836da3f2013-10-09 15:47:16 +020026
27 cls.xml_start = '<?xml version="1.0"?>\n' \
28 '<!DOCTYPE cross-domain-policy SYSTEM ' \
29 '"http://www.adobe.com/xml/dtds/cross-domain-policy.' \
30 'dtd" >\n<cross-domain-policy>\n'
31
32 cls.xml_end = "</cross-domain-policy>"
33
Joe H. Rahme836da3f2013-10-09 15:47:16 +020034 def setUp(self):
35 super(CrossdomainTest, self).setUp()
36
Joe H. Rahme836da3f2013-10-09 15:47:16 +020037 # Turning http://.../v1/foobar into http://.../
Daisuke Morita41a5cf42014-08-26 19:39:15 +090038 self.account_client.skip_path()
Joe H. Rahme836da3f2013-10-09 15:47:16 +020039
Ken'ichi Ohmichib7bc1de2017-01-27 18:12:22 -080040 @decorators.idempotent_id('d1b8b031-b622-4010-82f9-ff78a9e915c7')
Andrea Frittolicd368412017-08-14 21:37:56 +010041 @utils.requires_ext(extension='crossdomain', service='object')
Joe H. Rahme836da3f2013-10-09 15:47:16 +020042 def test_get_crossdomain_policy(self):
Daisuke Morita41a5cf42014-08-26 19:39:15 +090043 resp, body = self.account_client.get("crossdomain.xml", {})
Jordan Pittierb84f2d42016-12-21 19:02:15 +010044 body = body.decode()
Joe H. Rahme836da3f2013-10-09 15:47:16 +020045
Joe H. Rahme836da3f2013-10-09 15:47:16 +020046 self.assertTrue(body.startswith(self.xml_start) and
47 body.endswith(self.xml_end))
Daisuke Moritad206d3b2013-12-06 15:18:04 +090048
49 # The target of the request is not any Swift resource. Therefore, the
50 # existence of response header is checked without a custom matcher.
51 self.assertIn('content-length', resp)
52 self.assertIn('content-type', resp)
53 self.assertIn('x-trans-id', resp)
54 self.assertIn('date', resp)
55 # Check only the format of common headers with custom matcher
56 self.assertThat(resp, custom_matchers.AreAllWellFormatted())