blob: 69e0c4cb707e452a8c2d3d0d9e7169c680e677e8 [file] [log] [blame]
Mauro S. M. Rodriguese86ed042013-12-12 18:56:00 +00001# 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
Doug Hellmann583ce2c2015-03-11 14:55:46 +000016from oslo_log import log as logging
17
Matthew Treinish6c072292014-01-29 19:15:52 +000018from tempest import config
Mauro S. M. Rodriguese86ed042013-12-12 18:56:00 +000019from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090020from tempest import test
Mauro S. M. Rodriguese86ed042013-12-12 18:56:00 +000021
Matthew Treinish6c072292014-01-29 19:15:52 +000022CONF = config.CONF
23
Mauro S. M. Rodriguese86ed042013-12-12 18:56:00 +000024LOG = logging.getLogger(__name__)
25
26
Chris Dent0d494112014-08-26 13:48:30 +010027class TestSwiftBasicOps(manager.SwiftScenarioTest):
Mauro S. M. Rodriguese86ed042013-12-12 18:56:00 +000028 """
Chris Dent0d494112014-08-26 13:48:30 +010029 Test swift basic ops.
Mauro S. M. Rodriguese86ed042013-12-12 18:56:00 +000030 * get swift stat.
31 * create container.
32 * upload a file to the created container.
33 * list container's objects and assure that the uploaded file is present.
Fei Long Wang02abbf32014-06-12 11:50:35 +120034 * download the object and check the content
Mauro S. M. Rodriguese86ed042013-12-12 18:56:00 +000035 * delete object from container.
36 * list container's objects and assure that the deleted file is gone.
37 * delete a container.
38 * list containers and assure that the deleted container is gone.
Fei Long Wang02abbf32014-06-12 11:50:35 +120039 * change ACL of the container and make sure it works successfully
Mauro S. M. Rodriguese86ed042013-12-12 18:56:00 +000040 """
41
Chris Hoge7579c1a2015-02-26 14:12:15 -080042 @test.idempotent_id('b920faf1-7b8a-4657-b9fe-9c4512bfb381')
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090043 @test.services('object_storage')
Mauro S. M. Rodriguese86ed042013-12-12 18:56:00 +000044 def test_swift_basic_ops(self):
Chris Dentde456a12014-09-10 12:41:15 +010045 self.get_swift_stat()
46 container_name = self.create_container()
47 obj_name, obj_data = self.upload_object_to_container(container_name)
Chris Dent1d4313a2014-10-28 12:16:48 +000048 self.list_and_check_container_objects(container_name,
49 present_obj=[obj_name])
Chris Dentde456a12014-09-10 12:41:15 +010050 self.download_and_verify(container_name, obj_name, obj_data)
51 self.delete_object(container_name, obj_name)
Chris Dent1d4313a2014-10-28 12:16:48 +000052 self.list_and_check_container_objects(container_name,
53 not_present_obj=[obj_name])
Chris Dentde456a12014-09-10 12:41:15 +010054 self.delete_container(container_name)
Fei Long Wang02abbf32014-06-12 11:50:35 +120055
Chris Hoge7579c1a2015-02-26 14:12:15 -080056 @test.idempotent_id('916c7111-cb1f-44b2-816d-8f760e4ea910')
Fei Long Wang02abbf32014-06-12 11:50:35 +120057 @test.services('object_storage')
58 def test_swift_acl_anonymous_download(self):
59 """This test will cover below steps:
60 1. Create container
61 2. Upload object to the new container
62 3. Change the ACL of the container
63 4. Check if the object can be download by anonymous user
64 5. Delete the object and container
65 """
Chris Dentde456a12014-09-10 12:41:15 +010066 container_name = self.create_container()
67 obj_name, _ = self.upload_object_to_container(container_name)
Fei Long Wang02abbf32014-06-12 11:50:35 +120068 obj_url = '%s/%s/%s' % (self.object_client.base_url,
69 container_name, obj_name)
Ken'ichi Ohmichif82cfb52015-01-14 06:00:21 +000070 resp, _ = self.object_client.raw_request(obj_url, 'GET')
Fei Long Wang02abbf32014-06-12 11:50:35 +120071 self.assertEqual(resp.status, 401)
Ken'ichi Ohmichif82cfb52015-01-14 06:00:21 +000072
Chris Dentde456a12014-09-10 12:41:15 +010073 self.change_container_acl(container_name, '.r:*')
Ken'ichi Ohmichif82cfb52015-01-14 06:00:21 +000074 resp, _ = self.object_client.raw_request(obj_url, 'GET')
Fei Long Wang02abbf32014-06-12 11:50:35 +120075 self.assertEqual(resp.status, 200)