Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 1 | # 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 | |
| 17 | from tempest.api.object_storage import base |
Daisuke Morita | d206d3b | 2013-12-06 15:18:04 +0900 | [diff] [blame] | 18 | from tempest.common import custom_matchers |
Matthew Treinish | 2034538 | 2013-12-13 17:04:23 +0000 | [diff] [blame] | 19 | from tempest import test |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 20 | |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 21 | |
| 22 | class CrossdomainTest(base.BaseObjectTest): |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 23 | |
| 24 | @classmethod |
Andrea Frittoli | 5f13f71 | 2014-09-15 13:14:54 +0100 | [diff] [blame] | 25 | def resource_setup(cls): |
| 26 | super(CrossdomainTest, cls).resource_setup() |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 27 | |
| 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. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 35 | def setUp(self): |
| 36 | super(CrossdomainTest, self).setUp() |
| 37 | |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 38 | # Turning http://.../v1/foobar into http://.../ |
Daisuke Morita | 41a5cf4 | 2014-08-26 19:39:15 +0900 | [diff] [blame] | 39 | self.account_client.skip_path() |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 40 | |
Matthew Treinish | 2034538 | 2013-12-13 17:04:23 +0000 | [diff] [blame] | 41 | @test.attr('gate') |
| 42 | @test.requires_ext(extension='crossdomain', service='object') |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 43 | def test_get_crossdomain_policy(self): |
Daisuke Morita | 41a5cf4 | 2014-08-26 19:39:15 +0900 | [diff] [blame] | 44 | resp, body = self.account_client.get("crossdomain.xml", {}) |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 45 | |
Matthew Treinish | 2034538 | 2013-12-13 17:04:23 +0000 | [diff] [blame] | 46 | self.assertIn(int(resp['status']), test.HTTP_SUCCESS) |
Joe H. Rahme | 836da3f | 2013-10-09 15:47:16 +0200 | [diff] [blame] | 47 | self.assertTrue(body.startswith(self.xml_start) and |
| 48 | body.endswith(self.xml_end)) |
Daisuke Morita | d206d3b | 2013-12-06 15:18:04 +0900 | [diff] [blame] | 49 | |
| 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()) |