| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <?php
- namespace AlibabaCloud\Client\Tests\Unit\Credentials\Ini;
- use org\bovigo\vfs\vfsStream;
- /**
- * Class VirtualAccessKeyCredential
- *
- * @codeCoverageIgnore
- *
- * @package AlibabaCloud\Client\Tests\Unit\Credentials\Ini
- */
- class VirtualAccessKeyCredential
- {
- /**
- * @var string Virtual Credential Content
- */
- private $content;
- /**
- * @var string File Name
- */
- private $fileName;
- /**
- * VirtualCredential constructor.
- *
- * @param string $content
- * @param string $fileName
- */
- public function __construct($content, $fileName = '')
- {
- $this->content = $content;
- $this->fileName = $fileName;
- }
- /**
- * @param string $clineName
- *
- * @return string
- */
- public static function akClientWithAttributes($clineName = 'phpunit')
- {
- $content = <<<EOT
- [{$clineName}]
- enable = true
- type = access_key
- access_key_id = access_key_id
- access_key_secret = access_key_secret
- security_token = security_token
- region_id = cn-hangzhou
- debug = true
- delay = 3.2
- timeout = 3.2
- connect_timeout = 3.2
- cert_file = /path/server.pem
- cert_password = password
- proxy = tcp://localhost:8125
- proxy_http = tcp://localhost:8125
- proxy_https = tcp://localhost:9124
- proxy_no = .mit.edu,foo.com
- EOT;
- return (new static($content))->url();
- }
- /**
- * @return string Virtual Credential Filename
- */
- public function url()
- {
- $fileName = 'credentials-1';
- if ($this->fileName) {
- $fileName .= "-$this->fileName";
- }
- return vfsStream::newFile($fileName)
- ->withContent($this->content)
- ->at(vfsStream::setup('AlibabaCloud'))
- ->url();
- }
- /**
- * @param string $clineName
- *
- * @return string
- */
- public static function akClientWithAttributesNoCertPassword($clineName = 'phpunit')
- {
- $content = <<<EOT
- [{$clineName}]
- enable = true
- type = access_key
- access_key_id = access_key_id
- access_key_secret = access_key_secret
- security_token = security_token
- debug = true
- delay = 3.2
- timeout = 3.2
- connect_timeout = 3.2
- cert_file = /path/server.pem
- proxy = tcp://localhost:8125
- proxy_http = tcp://localhost:8125
- proxy_https = tcp://localhost:9124
- proxy_no = .mit.edu,foo.com
- EOT;
- return (new static($content))->url();
- }
- /**
- * @return string
- */
- public static function noType()
- {
- $content = <<<EOT
- [phpunit]
- enable = true
- EOT;
- return (new static($content))->url();
- }
- /**
- * @return string
- */
- public static function noSecret()
- {
- $content = <<<EOT
- [phpunit]
- enable = true
- type = access_key
- access_key_id = access_key_id
- security_token = security_token
- debug = false
- EOT;
- return (new static($content))->url();
- }
- /**
- * @return string
- */
- public static function badFormat()
- {
- $content = <<<EOT
- badFormat
- EOT;
- return (new static($content, 'badFormat'))->url();
- }
- /**
- * @return string
- */
- public static function disable()
- {
- $content = <<<EOT
- [phpunit]
- enable = false
- type = access_key
- access_key_id = access_key_id
- access_key_secret = access_key_secret
- security_token = security_token
- debug = false
- EOT;
- return (new static($content))->url();
- }
- /**
- * @return string
- */
- public static function invalidType()
- {
- $content = <<<EOT
- [phpunit]
- enable = true
- type = invalidType
- EOT;
- return (new static($content))->url();
- }
- /**
- * @return string
- */
- public static function noKey()
- {
- $content = <<<EOT
- [phpunit]
- enable = true
- type = access_key
- access_key_secret = access_key_secret
- security_token = security_token
- debug = false
- EOT;
- return (new static($content))->url();
- }
- /**
- * @return string
- */
- public static function ok()
- {
- $content = <<<EOT
- [ok]
- enable = true
- type = access_key
- access_key_id = foo
- access_key_secret = bar
- region_id = cn-hangzhou
- debug = true
- timeout = 0.2
- connect_Timeout = 0.03
- cert_file = /path/server.pem
- cert_password = password
- proxy = tcp://localhost:8125
- proxy_http = tcp://localhost:8125
- proxy_https = tcp://localhost:9124
- proxy_no = .mit.edu,foo.com
- EOT;
- return (new static($content, 'ok'))->url();
- }
- }
|