summaryrefslogtreecommitdiff
path: root/server/vendor/php-opencloud/common/tests/integration/Utils.php
diff options
context:
space:
mode:
authorEoleDev <root@serverpc.home>2016-03-09 15:37:42 +0100
committerEoleDev <root@serverpc.home>2016-03-09 15:37:42 +0100
commit1d3ed3af6d57316640c143002ddf80d61e6c098a (patch)
tree97ac49bc7ff0f16150aefee821da3557dc0d0644 /server/vendor/php-opencloud/common/tests/integration/Utils.php
parentd69adc4f9d1f6019927de235ef84885c68e6e508 (diff)
parent08ea5ef31abcc4e23a39a780cacb64fa27f19194 (diff)
Merge branch 'Evan' into develop
Diffstat (limited to 'server/vendor/php-opencloud/common/tests/integration/Utils.php')
-rw-r--r--server/vendor/php-opencloud/common/tests/integration/Utils.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/server/vendor/php-opencloud/common/tests/integration/Utils.php b/server/vendor/php-opencloud/common/tests/integration/Utils.php
new file mode 100644
index 0000000..daa1426
--- /dev/null
+++ b/server/vendor/php-opencloud/common/tests/integration/Utils.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace OpenCloud\integration;
+
+use GuzzleHttp\Client;
+use OpenCloud\Identity\v2\Api;
+use OpenCloud\Identity\v2\Service;
+use OpenCloud\Common\Transport\HandlerStack;
+use OpenCloud\Common\Transport\Utils as CommonUtils;
+
+class Utils
+{
+ public static function getAuthOptsV3()
+ {
+ return [
+ 'authUrl' => getenv('OS_AUTH_URL'),
+ 'region' => getenv('OS_REGION_NAME'),
+ 'user' => [
+ 'id' => getenv('OS_USER_ID'),
+ 'password' => getenv('OS_PASSWORD'),
+ ],
+ 'scope' => [
+ 'project' => [
+ 'id' => getenv('OS_PROJECT_ID'),
+ ]
+ ]
+ ];
+ }
+
+ public static function getAuthOptsV2()
+ {
+ $httpClient = new Client([
+ 'base_uri' => CommonUtils::normalizeUrl(getenv('OS_AUTH_URL')),
+ 'handler' => HandlerStack::create(),
+ ]);
+ return [
+ 'authUrl' => getenv('OS_AUTH_URL'),
+ 'region' => getenv('OS_REGION_NAME'),
+ 'username' => getenv('OS_USERNAME'),
+ 'password' => getenv('OS_PASSWORD'),
+ 'tenantName' => getenv('OS_TENANT_NAME'),
+ 'identityService' => new Service($httpClient, new Api),
+ ];
+ }
+
+ public static function getAuthOpts(array $options = [])
+ {
+ $authOptions = getenv('OS_IDENTITY_API_VERSION') == '2.0'
+ ? self::getAuthOptsV2()
+ : self::getAuthOptsV3();
+
+ return array_merge($authOptions, $options);
+ }
+
+ public static function toCamelCase($word, $separator = '_')
+ {
+ return str_replace($separator, '', ucwords($word, $separator));
+ }
+}