Example #1
0
 public function testGenerateAuthorization()
 {
     $auth = new Auth(new BceCredentials(array('ak' => 'my_ak', 'sk' => 'my_sk')));
     $method = 'PUT';
     $uri = '/v1/bucket/object1';
     $params = array('A' => null, 'b' => '', 'C' => 'd');
     $headers = array('Host' => 'bce.baidu.com', 'abc' => '123', 'x-bce-meta-key1' => 'ABC');
     $signature = $auth->generateAuthorization($method, $uri, $params, $headers, 1402639056);
     $this->assertEquals('bce-auth-v1/my_ak/2014-06-13T05:57:36Z/1800/host;x-bce-meta-key1/' . '80c9672aca2ea9af4bb40b9a8ff458d72df94e97d550840727f3a929af271d25', $signature);
     $signature = $auth->generateAuthorization($method, $uri, $params, $headers, 1402639056, 1800);
     $this->assertEquals('bce-auth-v1/my_ak/2014-06-13T05:57:36Z/1800/host;' . 'x-bce-meta-key1/80c9672aca2ea9af4bb40b9a8ff458d72' . 'df94e97d550840727f3a929af271d25', $signature);
     $method = 'DELETE';
     $uri = '/v1/test-bucket1361199862';
     $params = array();
     $headers = array('Content-Type' => 'application/json; charset=utf-8', 'Content-Length' => 0, 'User-Agent' => 'This is the user-agent');
     $signature = $auth->generateAuthorization($method, $uri, $params, $headers, 1402639056, 1800);
     $this->assertEquals('bce-auth-v1/my_ak/2014-06-13T05:57:36Z/1800/' . 'content-length;content-type/' . 'c9386b15d585960ae5e6972f73ed92a9a682dc81025480ba5b41206d3e489822', $signature);
 }
Example #2
0
 public function generateAuthorization($credentials, $http_method, $path, $params, $headers)
 {
     $auth = new Auth(new BceCredentials($credentials));
     return $auth->generateAuthorization($http_method, $path, $params, $headers);
 }