OssClientBucketRefererTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace OSS\Tests;
  3. use OSS\Core\OssException;
  4. use OSS\Model\RefererConfig;
  5. require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
  6. class OssClientBucketRefererTest extends TestOssClientBase
  7. {
  8. public function testBucket()
  9. {
  10. $refererConfig = new RefererConfig();
  11. $refererConfig->addReferer('http://www.aliyun.com');
  12. try {
  13. $this->ossClient->putBucketReferer($this->bucket, $refererConfig);
  14. } catch (OssException $e) {
  15. var_dump($e->getMessage());
  16. $this->assertTrue(false);
  17. }
  18. try {
  19. Common::waitMetaSync();
  20. $refererConfig2 = $this->ossClient->getBucketReferer($this->bucket);
  21. $this->assertEquals($refererConfig->serializeToXml(), $refererConfig2->serializeToXml());
  22. } catch (OssException $e) {
  23. $this->assertTrue(false);
  24. }
  25. try {
  26. Common::waitMetaSync();
  27. $nullRefererConfig = new RefererConfig();
  28. $nullRefererConfig->setAllowEmptyReferer(false);
  29. $this->ossClient->putBucketReferer($this->bucket, $nullRefererConfig);
  30. } catch (OssException $e) {
  31. $this->assertTrue(false);
  32. }
  33. try {
  34. Common::waitMetaSync();
  35. $refererConfig3 = $this->ossClient->getBucketLogging($this->bucket);
  36. $this->assertNotEquals($refererConfig->serializeToXml(), $refererConfig3->serializeToXml());
  37. } catch (OssException $e) {
  38. $this->assertTrue(false);
  39. }
  40. }
  41. }