blob: 1567e0640c3cf267cf6bc128bd07378be5924509 [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
Ken'ichi Ohmichib7bc1de2017-01-27 18:12:22 -080037 @decorators.idempotent_id('d1b8b031-b622-4010-82f9-ff78a9e915c7')
Andrea Frittolicd368412017-08-14 21:37:56 +010038 @utils.requires_ext(extension='crossdomain', service='object')
Joe H. Rahme836da3f2013-10-09 15:47:16 +020039 def test_get_crossdomain_policy(self):
Martin Kopec1d500e72019-10-31 13:56:42 +000040 url = self.account_client._get_base_version_url() + "crossdomain.xml"
41 resp, body = self.account_client.raw_request(url, "GET")
42 self.account_client._error_checker(resp, body)
Jordan Pittierb84f2d42016-12-21 19:02:15 +010043 body = body.decode()
Joe H. Rahme836da3f2013-10-09 15:47:16 +020044
Joe H. Rahme836da3f2013-10-09 15:47:16 +020045 self.assertTrue(body.startswith(self.xml_start) and
46 body.endswith(self.xml_end))
Daisuke Moritad206d3b2013-12-06 15:18:04 +090047
48 # The target of the request is not any Swift resource. Therefore, the
49 # existence of response header is checked without a custom matcher.
50 self.assertIn('content-length', resp)
51 self.assertIn('content-type', resp)
52 self.assertIn('x-trans-id', resp)
53 self.assertIn('date', resp)
54 # Check only the format of common headers with custom matcher
55 self.assertThat(resp, custom_matchers.AreAllWellFormatted())