/**
  * @test
  */
 public function testToXml()
 {
     $cfg = new DistributionConfigData();
     $cfg->setAliases(array(array('cname' => 'cname-1'), new DistributionConfigAliasData('cname-2')));
     $cfg->callerReference = 'caller-reference';
     $cfg->comment = 'the-comment';
     $cfg->enabled = true;
     $cfg->priceClass = 'price-class';
     $cfg->defaultRootObject = 'default-root-object';
     $cbd = new CacheBehaviorData();
     $cbd->minTtl = 3600;
     $cbd->pathPattern = 'path-pattern';
     $cbd->targetOriginId = 'target-origin-id';
     $cbd->viewerProtocolPolicy = 'pp-1';
     $cbd->setTrustedSigners(array(array('awsAccountNumber' => 'awsAccountNumber-1'), array('awsAccountNumber' => 'awsAccountNumber-2')));
     $fc = new ForwardedValuesCookiesData();
     $fc->forward = 'whitelist';
     $fc->setWhitelistedNames(array(array('name' => 'cookie-name-1'), array('name' => 'cookie-name-2')));
     $fwd = new ForwardedValuesData();
     $fwd->queryString = true;
     $fwd->setCookies($fc);
     $cbd->setForwardedValues($fwd);
     $cfg->setCacheBehaviors(array($cbd, $cbd));
     $cfg->setDefaultCacheBehavior($cbd);
     $this->assertEquals($this->getFixtureFileContent('CloudFront/20150727/DistributionConfig1.xml'), $cfg->toXml());
     unset($cfg);
 }
Example #2
0
 /**
  * Loads ForwardedValuesData from simple xml object
  *
  * @param   \SimpleXMLElement $sxml
  * @return  ForwardedValuesData Returns ForwardedValuesData
  */
 protected function _loadForwardedValuesData(\SimpleXMLElement $sxml)
 {
     $item = null;
     if ($this->exist($sxml)) {
         $item = new ForwardedValuesData();
         $item->cookies = $this->_loadForwardedValuesCookiesData($sxml->Cookies);
         $item->queryString = $this->exist($sxml->QueryString) ? (string) $sxml->QueryString == 'true' : null;
         $item->setCloudFront($this->cloudFront);
         $item->headers = [];
         if (!empty($sxml->Headers->Items->Name)) {
             foreach ($sxml->Headers->Items->Name as $v) {
                 $item->headers[] = (string) $v;
             }
         }
     }
     return $item;
 }
Example #3
0
 /**
  * @test
  */
 public function testFunctional()
 {
     $this->skipIfEc2PlatformDisabled();
     $aws = $this->aws;
     //$aws->setDebug(true);
     $list = $aws->cloudFront->distribution->describe();
     $this->assertInstanceOf($this->getCloudFrontClassName('DataType\\DistributionList'), $list);
     /* @var $dist CloudFrontDataType\DistirbutionData */
     foreach ($list as $dist) {
         $dist->refresh();
         $this->assertNotEmpty($dist->getOriginalXml());
         $this->assertNotNull($dist->distributionConfig->getETag());
         $dist->refreshConfig();
         $this->assertNotNull($dist->getETag());
         $this->assertInstanceOf($this->getCloudFrontClassName('DataType\\DistributionConfigData'), $dist->distributionConfig);
         $this->assertNotEmpty($dist->distributionConfig->getOriginalXml());
         $dom = new \DOMDocument();
         $dom->loadXML($dist->distributionConfig->getOriginalXml());
         $this->assertEqualXMLStructure($dom->firstChild, $dist->distributionConfig->toXml(true)->firstChild);
         unset($dist);
     }
     unset($list);
     //Creates distribution
     $origin = new CloudFrontDataType\DistributionConfigOriginData();
     $origin->originId = 'MyOriginId';
     $origin->domainName = 'test.s3.amazonaws.com';
     $origin->setS3OriginConfig(new CloudFrontDataType\DistributionS3OriginConfigData(''));
     $fvd = new CloudFrontDataType\ForwardedValuesData();
     $fvd->queryString = false;
     $fvd->setCookies(new CloudFrontDataType\ForwardedValuesCookiesData(CloudFrontDataType\ForwardedValuesCookiesData::FORWARD_NONE));
     $ts = new CloudFrontDataType\TrustedSignerList();
     $ts->setEnabled(false);
     $dcb = new CloudFrontDataType\CacheBehaviorData();
     $dcb->minTtl = 3600;
     $dcb->targetOriginId = $origin->originId;
     $dcb->viewerProtocolPolicy = 'allow-all';
     $dcb->setForwardedValues($fvd);
     $dcb->setTrustedSigners($ts);
     $dc = new CloudFrontDataType\DistributionConfigData();
     $dc->comment = 'phpunit test distribution';
     $dc->enabled = false;
     $dc->setAliases(array(array('cname' => 'test2.scalr.com')));
     $dc->priceClass = 'PriceClass_All';
     $dc->setOrigins($origin);
     $dc->setDefaultCacheBehavior($dcb);
     $dist = $aws->cloudFront->distribution->create($dc);
     $this->assertInstanceOf($this->getCloudFrontClassName('DataType\\DistributionData'), $dist);
     $dist->refresh();
     //Too time consuming test
     //         $ret = $dist->delete();
     //         $this->assertTrue($ret);
     //Releases all memory from storage.
     $aws->getEntityManager()->detachAll();
 }
Example #4
0
 /**
  * Loads ForwardedValuesData from simple xml object
  *
  * @param   \SimpleXMLElement $sxml
  * @return  ForwardedValuesData Returns ForwardedValuesData
  */
 protected function _loadForwardedValuesData(\SimpleXMLElement $sxml)
 {
     $item = null;
     if ($this->exist($sxml)) {
         $item = new ForwardedValuesData();
         $item->cookies = $this->_loadForwardedValuesCookiesData($sxml->Cookies);
         $item->queryString = $this->exist($sxml->QueryString) ? (string) $sxml->QueryString == 'true' : null;
         $item->setCloudFront($this->cloudFront);
     }
     return $item;
 }