Skip to content

Commit de8edb7

Browse files
author
Patrick Rose
committed
Make sure container name is valid when retrieving
1 parent 22031ae commit de8edb7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/OpenCloud/ObjectStore/Service.php

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ public function listContainers(array $filter = array())
9292
*/
9393
public function getContainer($data = null)
9494
{
95+
if (is_string($data)) {
96+
$this->checkContainerName($data);
97+
}
98+
9599
return new Container($this, $data);
96100
}
97101

tests/OpenCloud/Tests/ObjectStore/ServiceTest.php

+24
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,30 @@ public function test_Bad_Container_Name_Long()
9999
$this->service->createContainer(str_repeat('a', Service::MAX_CONTAINER_NAME_LENGTH + 1));
100100
}
101101

102+
/**
103+
* @expectedException OpenCloud\Common\Exceptions\InvalidArgumentError
104+
*/
105+
public function test_Get_Bad_Container_Name_Empty()
106+
{
107+
$this->service->getContainer('');
108+
}
109+
110+
/**
111+
* @expectedException OpenCloud\Common\Exceptions\InvalidArgumentError
112+
*/
113+
public function test_Get_Bad_Container_Name_Slashes()
114+
{
115+
$this->service->getContainer('foo/bar');
116+
}
117+
118+
/**
119+
* @expectedException OpenCloud\Common\Exceptions\InvalidArgumentError
120+
*/
121+
public function test_Get_Bad_Container_Name_Long()
122+
{
123+
$this->service->getContainer(str_repeat('a', Service::MAX_CONTAINER_NAME_LENGTH + 1));
124+
}
125+
102126
public function test_Bulk_Extract()
103127
{
104128
$response = $this->service->bulkExtract('fooBarContainer', 'CONTENT', UrlType::TAR);

0 commit comments

Comments
 (0)