Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 1 | # Copyright (C) 2013 eNovance SAS <licensing@enovance.com> |
| 2 | # |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 3 | # 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 | |
| 15 | from tempest.api.object_storage import base |
Daisuke Morita | d206d3b | 2013-12-06 15:18:04 +0900 | [diff] [blame] | 16 | from tempest.common import custom_matchers |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 17 | from tempest.common import utils |
Ken'ichi Ohmichi | b7bc1de | 2017-01-27 18:12:22 -0800 | [diff] [blame] | 18 | from tempest.lib import decorators |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 19 | |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 20 | |
| 21 | class CrossdomainTest(base.BaseObjectTest): |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 22 | |
| 23 | @classmethod |
Andrea Frittoli | 5f13f71 | 2014-09-15 13:14:54 +0100 | [diff] [blame] | 24 | def resource_setup(cls): |
| 25 | super(CrossdomainTest, cls).resource_setup() |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 26 | |
| 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. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 34 | def setUp(self): |
| 35 | super(CrossdomainTest, self).setUp() |
| 36 | |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 37 | # Turning http://.../v1/foobar into http://.../ |
Daisuke Morita | 41a5cf4 | 2014-08-26 19:39:15 +0900 | [diff] [blame] | 38 | self.account_client.skip_path() |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 39 | |
Ken'ichi Ohmichi | b7bc1de | 2017-01-27 18:12:22 -0800 | [diff] [blame] | 40 | @decorators.idempotent_id('d1b8b031-b622-4010-82f9-ff78a9e915c7') |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 41 | @utils.requires_ext(extension='crossdomain', service='object') |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 42 | def test_get_crossdomain_policy(self): |
Daisuke Morita | 41a5cf4 | 2014-08-26 19:39:15 +0900 | [diff] [blame] | 43 | resp, body = self.account_client.get("crossdomain.xml", {}) |
Jordan Pittier | b84f2d4 | 2016-12-21 19:02:15 +0100 | [diff] [blame] | 44 | body = body.decode() |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 45 | |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 46 | self.assertTrue(body.startswith(self.xml_start) and |
| 47 | body.endswith(self.xml_end)) |
Daisuke Morita | d206d3b | 2013-12-06 15:18:04 +0900 | [diff] [blame] | 48 | |
| 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()) |