Mauro S. M. Rodrigues | e86ed04 | 2013-12-12 18:56:00 +0000 | [diff] [blame] | 1 | # Copyright 2013 IBM Corp. |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 16 | from tempest import config |
Mauro S. M. Rodrigues | e86ed04 | 2013-12-12 18:56:00 +0000 | [diff] [blame] | 17 | from tempest.openstack.common import log as logging |
| 18 | from tempest.scenario import manager |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 19 | from tempest import test |
Mauro S. M. Rodrigues | e86ed04 | 2013-12-12 18:56:00 +0000 | [diff] [blame] | 20 | |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 21 | CONF = config.CONF |
| 22 | |
Mauro S. M. Rodrigues | e86ed04 | 2013-12-12 18:56:00 +0000 | [diff] [blame] | 23 | LOG = logging.getLogger(__name__) |
| 24 | |
| 25 | |
Chris Dent | 0d49411 | 2014-08-26 13:48:30 +0100 | [diff] [blame] | 26 | class TestSwiftBasicOps(manager.SwiftScenarioTest): |
Mauro S. M. Rodrigues | e86ed04 | 2013-12-12 18:56:00 +0000 | [diff] [blame] | 27 | """ |
Chris Dent | 0d49411 | 2014-08-26 13:48:30 +0100 | [diff] [blame] | 28 | Test swift basic ops. |
Mauro S. M. Rodrigues | e86ed04 | 2013-12-12 18:56:00 +0000 | [diff] [blame] | 29 | * get swift stat. |
| 30 | * create container. |
| 31 | * upload a file to the created container. |
| 32 | * list container's objects and assure that the uploaded file is present. |
Fei Long Wang | 02abbf3 | 2014-06-12 11:50:35 +1200 | [diff] [blame] | 33 | * download the object and check the content |
Mauro S. M. Rodrigues | e86ed04 | 2013-12-12 18:56:00 +0000 | [diff] [blame] | 34 | * delete object from container. |
| 35 | * list container's objects and assure that the deleted file is gone. |
| 36 | * delete a container. |
| 37 | * list containers and assure that the deleted container is gone. |
Fei Long Wang | 02abbf3 | 2014-06-12 11:50:35 +1200 | [diff] [blame] | 38 | * change ACL of the container and make sure it works successfully |
Mauro S. M. Rodrigues | e86ed04 | 2013-12-12 18:56:00 +0000 | [diff] [blame] | 39 | """ |
| 40 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 41 | @test.idempotent_id('b920faf1-7b8a-4657-b9fe-9c4512bfb381') |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 42 | @test.services('object_storage') |
Mauro S. M. Rodrigues | e86ed04 | 2013-12-12 18:56:00 +0000 | [diff] [blame] | 43 | def test_swift_basic_ops(self): |
Chris Dent | de456a1 | 2014-09-10 12:41:15 +0100 | [diff] [blame] | 44 | self.get_swift_stat() |
| 45 | container_name = self.create_container() |
| 46 | obj_name, obj_data = self.upload_object_to_container(container_name) |
Chris Dent | 1d4313a | 2014-10-28 12:16:48 +0000 | [diff] [blame] | 47 | self.list_and_check_container_objects(container_name, |
| 48 | present_obj=[obj_name]) |
Chris Dent | de456a1 | 2014-09-10 12:41:15 +0100 | [diff] [blame] | 49 | self.download_and_verify(container_name, obj_name, obj_data) |
| 50 | self.delete_object(container_name, obj_name) |
Chris Dent | 1d4313a | 2014-10-28 12:16:48 +0000 | [diff] [blame] | 51 | self.list_and_check_container_objects(container_name, |
| 52 | not_present_obj=[obj_name]) |
Chris Dent | de456a1 | 2014-09-10 12:41:15 +0100 | [diff] [blame] | 53 | self.delete_container(container_name) |
Fei Long Wang | 02abbf3 | 2014-06-12 11:50:35 +1200 | [diff] [blame] | 54 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 55 | @test.idempotent_id('916c7111-cb1f-44b2-816d-8f760e4ea910') |
Fei Long Wang | 02abbf3 | 2014-06-12 11:50:35 +1200 | [diff] [blame] | 56 | @test.services('object_storage') |
| 57 | def test_swift_acl_anonymous_download(self): |
| 58 | """This test will cover below steps: |
| 59 | 1. Create container |
| 60 | 2. Upload object to the new container |
| 61 | 3. Change the ACL of the container |
| 62 | 4. Check if the object can be download by anonymous user |
| 63 | 5. Delete the object and container |
| 64 | """ |
Chris Dent | de456a1 | 2014-09-10 12:41:15 +0100 | [diff] [blame] | 65 | container_name = self.create_container() |
| 66 | obj_name, _ = self.upload_object_to_container(container_name) |
Fei Long Wang | 02abbf3 | 2014-06-12 11:50:35 +1200 | [diff] [blame] | 67 | obj_url = '%s/%s/%s' % (self.object_client.base_url, |
| 68 | container_name, obj_name) |
Ken'ichi Ohmichi | f82cfb5 | 2015-01-14 06:00:21 +0000 | [diff] [blame] | 69 | resp, _ = self.object_client.raw_request(obj_url, 'GET') |
Fei Long Wang | 02abbf3 | 2014-06-12 11:50:35 +1200 | [diff] [blame] | 70 | self.assertEqual(resp.status, 401) |
Ken'ichi Ohmichi | f82cfb5 | 2015-01-14 06:00:21 +0000 | [diff] [blame] | 71 | |
Chris Dent | de456a1 | 2014-09-10 12:41:15 +0100 | [diff] [blame] | 72 | self.change_container_acl(container_name, '.r:*') |
Ken'ichi Ohmichi | f82cfb5 | 2015-01-14 06:00:21 +0000 | [diff] [blame] | 73 | resp, _ = self.object_client.raw_request(obj_url, 'GET') |
Fei Long Wang | 02abbf3 | 2014-06-12 11:50:35 +1200 | [diff] [blame] | 74 | self.assertEqual(resp.status, 200) |