diff options
| author | root <root@kabir-PC> | 2016-03-23 11:31:51 +0100 |
|---|---|---|
| committer | root <root@kabir-PC> | 2016-03-23 11:31:51 +0100 |
| commit | a26989103d70fb0dd3ff6834de107cae246778c3 (patch) | |
| tree | 0f243c83b790ffb57f19261fc2a509131f6776ce /server/vendor/php-opencloud/common/tests/integration/Utils.php | |
| parent | 1342db60283cb61a1c3810993575d35b9fb33ac0 (diff) | |
| parent | 6e78d76f887d1149ea85bfb06db7ee7ad7435f5a (diff) | |
Merge branch 'develop' of https://github.com/manzerbredes/istic-openstack 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.php | 59 |
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)); + } +} |
