Skip to content

Commit 5532b88

Browse files
author
Jamie Hannaford
committed
Merge pull request rackspace#598 from rackspace/working
Merge working into master for release
2 parents 9f0dbcb + 17d35e0 commit 5532b88

File tree

9 files changed

+58
-64
lines changed

9 files changed

+58
-64
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"require": {
2929
"php" : ">=5.4",
30-
"guzzle/http" : "~3.8",
30+
"guzzle/guzzle" : "~3.8",
3131
"psr/log": "~1.0",
3232
"mikemccabe/json-patch-php": "~0.1"
3333
},

doc/services/object-store/cdn.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ Once a container has been CDN-enabled, you can retrieve it like so:
7171
7272
$cdnContainer = $cdnService->cdnContainer('{containerName}');
7373
74+
If you already have a container object and want to avoid instantiating a new service, you can also do:
75+
76+
.. code-block:: php
77+
78+
$cdnContainer = $container->getCdn();
79+
7480
7581
Retrieve the SSL URL of a CDN container
7682
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lib/OpenCloud/Common/Resource/PersistentResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ protected function noDelete()
319319
*/
320320
protected function noUpdate()
321321
{
322-
throw new UpdateError('his resource does not support the update operation');
322+
throw new UpdateError('This resource does not support the update operation');
323323
}
324324

325325
/**

lib/OpenCloud/Database/Service.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -105,39 +105,4 @@ public function datastoreList($params = array())
105105

106106
return $this->resourceList('Datastore', $url);
107107
}
108-
109-
/**
110-
* {@inheritDoc}
111-
*/
112-
public function setClient(ClientInterface $client)
113-
{
114-
// The Rackspace Cloud Databases service only supports the
115-
// RC4 SSL cipher which is not supported by modern OpenSSL clients.
116-
// Until the service can support additional, more modern and secure
117-
// ciphers, this SDK has to ask curl to allow using the weaker
118-
// cipher. For more information, see https://github.com/rackspace/php-opencloud/issues/560
119-
120-
$curlOptions = $client->getConfig()->get('curl.options');
121-
$curlOptions['CURLOPT_SSL_CIPHER_LIST'] = static::getSslCipherList();
122-
$client->getConfig()->set('curl.options', $curlOptions);
123-
124-
$logMessage = 'The SDK is using a custom cipher suite when connecting '
125-
. 'to the Rackspace Cloud Databases service. This suite contains '
126-
. 'a weak cipher (RC4) so please use at your own risk. See '
127-
. 'https://github.com/rackspace/php-opencloud/issues/560 for details.';
128-
$client->getLogger()->critical($logMessage);
129-
130-
$this->client = $client;
131-
}
132-
133-
/**
134-
* @see https://github.com/rackspace/php-opencloud/issues/560#issuecomment-81790778
135-
*/
136-
public static function getSslCipherList()
137-
{
138-
return 'ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:'
139-
. 'ECDH+AES128:DH+AES:ECDH+HIGH:DH+HIGH:ECDH+3DES:'
140-
. 'DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES:'
141-
. 'ECDH+RC4:DH+RC4:RSA+RC4:!aNULL:!eNULL:!MD5';
142-
}
143108
}

lib/OpenCloud/ObjectStore/CDNService.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,19 @@ public function cdnContainer($data)
5454
{
5555
$container = new CDNContainer($this, $data);
5656

57-
$metadata = new ContainerMetadata();
58-
$metadata->setArray(array(
59-
'Streaming-Uri' => $data->cdn_streaming_uri,
60-
'Ios-Uri' => $data->cdn_ios_uri,
61-
'Ssl-Uri' => $data->cdn_ssl_uri,
62-
'Enabled' => $data->cdn_enabled,
63-
'Ttl' => $data->ttl,
64-
'Log-Retention' => $data->log_retention,
65-
'Uri' => $data->cdn_uri,
66-
));
67-
68-
$container->setMetadata($metadata);
57+
if (is_object($data)) {
58+
$metadata = new ContainerMetadata();
59+
$metadata->setArray(array(
60+
'Streaming-Uri' => $data->cdn_streaming_uri,
61+
'Ios-Uri' => $data->cdn_ios_uri,
62+
'Ssl-Uri' => $data->cdn_ssl_uri,
63+
'Enabled' => $data->cdn_enabled,
64+
'Ttl' => $data->ttl,
65+
'Log-Retention' => $data->log_retention,
66+
'Uri' => $data->cdn_uri,
67+
));
68+
$container->setMetadata($metadata);
69+
}
6970

7071
return $container;
7172
}

lib/OpenCloud/ObjectStore/Resource/DataObject.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,18 @@ public function createSymlinkFrom($source)
451451
*
452452
* @link http://docs.rackspace.com/files/api/v1/cf-devguide/content/TempURL-d1a4450.html
453453
*
454-
* @param $expires Expiration time in seconds
455-
* @param $method What method can use this URL? (`GET' or `PUT')
454+
* @param int $expires Expiration time in seconds
455+
* @param string $method What method can use this URL? (`GET' or `PUT')
456+
* @param bool $forcePublicUrl If set to TRUE, a public URL will always be used. The default is to use whatever
457+
* URL type the user has set for the main service.
458+
*
456459
* @return string
460+
*
457461
* @throws \OpenCloud\Common\Exceptions\InvalidArgumentError
458462
* @throws \OpenCloud\Common\Exceptions\ObjectError
459463
*
460464
*/
461-
public function getTemporaryUrl($expires, $method)
465+
public function getTemporaryUrl($expires, $method, $forcePublicUrl = false)
462466
{
463467
$method = strtoupper($method);
464468
$expiry = time() + (int) $expires;
@@ -477,7 +481,7 @@ public function getTemporaryUrl($expires, $method)
477481
}
478482
// @codeCoverageIgnoreEnd
479483

480-
$url = $this->getUrl();
484+
$url = ($forcePublicUrl === true) ? $this->getService()->getEndpoint()->getPublicUrl() : $this->getUrl();
481485
$urlPath = urldecode($url->getPath());
482486
$body = sprintf("%s\n%d\n%s", $method, $expiry, $urlPath);
483487
$hash = hash_hmac('sha1', $body, $secret);

lib/OpenCloud/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
class Version
2929
{
30-
const VERSION = '1.14.0';
30+
const VERSION = '1.14.2';
3131

3232
/**
3333
* @return string Indicate current SDK version.

tests/OpenCloud/Tests/Database/ServiceTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,4 @@ public function testDatastoreList()
7373
{
7474
$this->assertInstanceOf(self::COLLECTION_CLASS, $this->service->datastoreList());
7575
}
76-
77-
public function testClientUsesCustomCipherSuite()
78-
{
79-
$client = $this->service->getClient();
80-
$curlOptions = $client->getConfig('curl.options');
81-
$this->assertEquals(Service::getSslCipherList(), $curlOptions['CURLOPT_SSL_CIPHER_LIST']);
82-
$this->assertCriticalMessageWasLogged();
83-
}
8476
}

tests/OpenCloud/Tests/ObjectStore/Resource/DataObjectTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,47 @@ public function test_Copy()
7272
}
7373

7474
/**
75-
* @expectedException OpenCloud\Common\Exceptions\NoNameError
75+
* @expectedException \OpenCloud\Common\Exceptions\NoNameError
7676
*/
7777
public function test_Copy_Fails()
7878
{
7979
$this->container->dataObject()->copy(null);
8080
}
8181

8282
/**
83-
* @expectedException OpenCloud\Common\Exceptions\InvalidArgumentError
83+
* @expectedException \OpenCloud\Common\Exceptions\InvalidArgumentError
8484
*/
8585
public function test_Temp_Url_Fails_With_Incorrect_Method()
8686
{
8787
$this->container->dataObject('foobar')->getTemporaryUrl(1000, 'DELETE');
8888
}
8989

90+
public function test_Temp_Url_Inherits_Url_Type()
91+
{
92+
$service = $this->getClient()->objectStoreService(null, 'IAD', 'internalURL');
93+
$object = $service->getContainer('foo')->dataObject('bar');
94+
95+
$this->addMockSubscriber(new Response(204, ['X-Account-Meta-Temp-URL-Key' => 'secret']));
96+
97+
$tempUrl = $object->getTemporaryUrl(60, 'GET');
98+
99+
// Check that internal URLs are used
100+
$this->assertContains('snet-storage', $tempUrl);
101+
}
102+
103+
public function test_temp_urls_can_be_forced_to_use_public_urls()
104+
{
105+
$service = $this->getClient()->objectStoreService(null, 'IAD', 'internalURL');
106+
$object = $service->getContainer('foo')->dataObject('bar');
107+
108+
$this->addMockSubscriber(new Response(204, ['X-Account-Meta-Temp-URL-Key' => 'secret']));
109+
110+
$tempUrl = $object->getTemporaryUrl(60, 'GET', true);
111+
112+
// Check that internal URLs are NOT used
113+
$this->assertNotContains('snet-storage', $tempUrl);
114+
}
115+
90116
public function test_Purge()
91117
{
92118
$object = $this->container->dataObject('foobar');

0 commit comments

Comments
 (0)