Пример #1
0
    /**
     * Setup for each test
     */
    public function setUp()
    {
        $this->infrastructure = CloudFactory::getAdapter(array( 
            CloudFactory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Rackspace',
            Rackspace::RACKSPACE_USER   => 'test', 
            Rackspace::RACKSPACE_KEY    => 'test', 
            Rackspace::RACKSPACE_REGION => 'USA'  
        )); 

        $this->httpClientAdapterTest = new HttpTest();

        $this->infrastructure->getAdapter()
                             ->getHttpClient()
                             ->setAdapter($this->httpClientAdapterTest);
        
        $shortClassName = 'RackspaceTest';      
        // load the HTTP response (from a file)
        $filename= dirname(__FILE__) . '/_files/' . $shortClassName . '_'. $this->getName().'.response';
        
        if (file_exists($filename)) {
            // authentication (from file)
            $content = file_get_contents(dirname(__FILE__) . '/_files/'.$shortClassName . '_testAuthenticate.response');
            $this->httpClientAdapterTest->setResponse($content);
            $this->assertTrue($this->infrastructure->getAdapter()->authenticate(),'Authentication failed');
            // set the specific API response
            $content = file_get_contents($filename);
            $this->httpClientAdapterTest->setResponse($content); 
        }
        
    }
 /**
  * Tests Zend_Service_Amazon_Ec2_Instance_Reserved->purchaseOffering()
  */
 public function testPurchaseOffering()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<PurchaseReservedInstancesOfferingResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <reservedInstancesId>4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8</reservedInstancesId>\r\n" . "</PurchaseReservedInstancesOfferingResponse>";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $return = $this->instance->purchaseOffering('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8');
     $this->assertSame('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8', $return);
 }
Пример #3
0
    /**
     * Setup for each test
     */
    public function setUp()
    {
        $this->infrastructure = CloudFactory::getAdapter(array( 
            CloudFactory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Ec2',
            Ec2::AWS_ACCESS_KEY         => '0123456789', 
            Ec2::AWS_SECRET_KEY         => 'test', 
            Ec2::AWS_REGION             => 'us-east-1'     
        )); 

        $this->httpClientAdapterTest = new HttpTest();     

        // load the HTTP response (from a file)
        $shortClassName = 'Ec2Test';
        $filename= dirname(__FILE__) . '/_files/' . $shortClassName . '_'. $this->getName().'.response';

        if (file_exists($filename)) {
            $this->httpClientAdapterTest->setResponse(file_get_contents($filename)); 
        }
        
        $adapter= $this->infrastructure->getAdapter();
        
        $client = new HttpClient(null, array(
            'adapter' => $this->httpClientAdapterTest
        ));
        
        call_user_func(array($adapter,'setHttpClient'),$client);
    
    }
Пример #4
0
 public function testGetAdapterWithConfig()
 {
     $httptest = new HttpClientTest();
     // Nirvanix adapter
     $nirvanixConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/nirvanix.ini'), true);
     $nirvanixConfig = $nirvanixConfig->toArray();
     $nirvanixConfig[Nirvanix::HTTP_ADAPTER] = $httptest;
     $doc = new \DOMDocument('1.0', 'utf-8');
     $root = $doc->createElement('Response');
     $responseCode = $doc->createElement('ResponseCode', 0);
     $sessionTok = $doc->createElement('SessionToken', '54592180-7060-4D4B-BC74-2566F4B2F943');
     $root->appendChild($responseCode);
     $root->appendChild($sessionTok);
     $doc->appendChild($root);
     $body = $doc->saveXML();
     $resp = HttpResponse::fromString("HTTP/1.1 200 OK\nContent-type: text/xml;charset=UTF-8\nDate: 0\n\n" . $body);
     $httptest->setResponse($resp);
     $nirvanixAdapter = Factory::getAdapter($nirvanixConfig);
     $this->assertEquals('Zend\\Cloud\\StorageService\\Adapter\\Nirvanix', get_class($nirvanixAdapter));
     // S3 adapter
     $s3Config = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/s3.ini'), true);
     $s3Adapter = Factory::getAdapter($s3Config);
     $this->assertEquals('Zend\\Cloud\\StorageService\\Adapter\\S3', get_class($s3Adapter));
     // file system adapter
     $fileSystemConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/filesystem.ini'), true);
     $fileSystemAdapter = Factory::getAdapter($fileSystemConfig);
     $this->assertEquals('Zend\\Cloud\\StorageService\\Adapter\\FileSystem', get_class($fileSystemAdapter));
     // Azure adapter
     /*
             $azureConfig    = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/windowsazure.ini'), true);
             $azureConfig    = $azureConfig->toArray();
             $azureContainer = $azureConfig[WindowsAzure::CONTAINER];
             $azureConfig[WindowsAzure::HTTP_ADAPTER] = $httptest;
             $q = "?";
     
             $doc = new \DOMDocument('1.0', 'utf-8');
             $root = $doc->createElement('EnumerationResults');
             $acctName = $doc->createAttribute('AccountName');
             $acctName->value = 'http://myaccount.blob.core.windows.net';
             $root->appendChild($acctName);
             $maxResults     = $doc->createElement('MaxResults', 1);
             $containers     = $doc->createElement('Containers');
             $container      = $doc->createElement('Container');
             $containerName  = $doc->createElement('Name', $azureContainer);
             $container->appendChild($containerName);
             $containers->appendChild($container);
             $root->appendChild($maxResults);
             $root->appendChild($containers);
             $doc->appendChild($root);
             $body = $doc->saveXML();
     
             $resp = HttpResponse::fromString("HTTP/1.1 200 OK\nContent-type: text/xml;charset=UTF-8\nx-ms-request-id: 0\n\n".$body);
     
             $httptest->setResponse($resp);
             $azureAdapter = Factory::getAdapter($azureConfig);
             $this->assertEquals('Zend\Cloud\StorageService\Adapter\WindowsAzure', get_class($azureAdapter));
     *
     */
 }
Пример #5
0
 public function testDescribeMultipleRegions()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <regionInfo>\r\n" . "    <item>\r\n" . "      <regionName>us-east-1</regionName>\r\n" . "      <regionUrl>us-east-1.ec2.amazonaws.com</regionUrl>\r\n" . "    </item>\r\n" . "    <item>\r\n" . "      <regionName>us-west-1</regionName>\r\n" . "      <regionUrl>us-west-1.ec2.amazonaws.com</regionUrl>\r\n" . "    </item>\r\n" . "  </regionInfo>\r\n" . "</DescribeRegionsResponse>";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $response = $this->regionInstance->describe(array('us-east-1', 'us-west-1'));
     $arrRegion = array(array('regionName' => 'us-east-1', 'regionUrl' => 'us-east-1.ec2.amazonaws.com'), array('regionName' => 'us-west-1', 'regionUrl' => 'us-west-1.ec2.amazonaws.com'));
     $this->assertSame($arrRegion, $response);
 }
Пример #6
0
 /**
  * Tests Zend_Service_Amazon_Ec2_Instance_Windows->describeBundle()
  */
 public function testDescribeBundle()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<DescribeBundleTasksResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <bundleInstanceTasksSet>\r\n" . "    <item>\r\n" . "      <instanceId>i-12345678</instanceId>\r\n" . "      <bundleId>bun-cla322b9</bundleId>\r\n" . "      <state>bundling</state>\r\n" . "      <startTime>2008-10-07T11:41:50.000Z</startTime>\r\n" . "      <updateTime>2008-10-07T11:51:50.000Z</updateTime>\r\n" . "      <progress>20%</progress>\r\n" . "      <storage>\r\n" . "        <S3>\r\n" . "          <bucket>my-bucket</bucket>\r\n" . "          <prefix>my-new-image</prefix>\r\n" . "        </S3>\r\n" . "      </storage>\r\n" . "    </item>\r\n" . "  </bundleInstanceTasksSet>\r\n" . "</DescribeBundleTasksResponse>";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $return = $this->instance->describeBundle('bun-cla322b9');
     $arrReturn = array(array("instanceId" => "i-12345678", "bundleId" => "bun-cla322b9", "state" => "bundling", "startTime" => "2008-10-07T11:41:50.000Z", "updateTime" => "2008-10-07T11:51:50.000Z", "progress" => "20%", "storage" => array("s3" => array("bucket" => "my-bucket", "prefix" => "my-new-image"))));
     $this->assertSame($arrReturn, $return);
 }
Пример #7
0
 public function testZF8149()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<GetMetricStatisticsResponse xmlns=\"http://monitoring.amazonaws.com/doc/2009-05-15/\">\r\n" . "  <GetMetricStatisticsResult>\r\n" . "    <Datapoints>\r\n" . "      <member>\r\n" . "        <Timestamp>2009-11-19T21:52:00Z</Timestamp>\r\n" . "        <Unit>Percent</Unit>\r\n" . "        <Samples>1.0</Samples>\r\n" . "        <Average>0.09</Average>\r\n" . "      </member>\r\n" . "      <member>\r\n" . "        <Timestamp>2009-11-19T21:55:00Z</Timestamp>\r\n" . "        <Unit>Percent</Unit>\r\n" . "        <Samples>1.0</Samples>\r\n" . "        <Average>0.18</Average>\r\n" . "      </member>\r\n" . "      <member>\r\n" . "        <Timestamp>2009-11-19T21:54:00Z</Timestamp>\r\n" . "        <Unit>Percent</Unit>\r\n" . "        <Samples>1.0</Samples>\r\n" . "        <Average>0.09</Average>\r\n" . "      </member>\r\n" . "      <member>\r\n" . "        <Timestamp>2009-11-19T21:51:00Z</Timestamp>\r\n" . "        <Unit>Percent</Unit>\r\n" . "        <Samples>1.0</Samples>\r\n" . "        <Average>0.18</Average>\r\n" . "      </member>\r\n" . "      <member>\r\n" . "        <Timestamp>2009-11-19T21:53:00Z</Timestamp>\r\n" . "        <Unit>Percent</Unit>\r\n" . "        <Samples>1.0</Samples>\r\n" . "        <Average>0.09</Average>\r\n" . "      </member>\r\n" . "    </Datapoints>\r\n" . "    <Label>CPUUtilization</Label>\r\n" . "  </GetMetricStatisticsResult>\r\n" . "  <ResponseMetadata>\r\n" . "    <RequestId>6fb864fd-d557-11de-ac37-475775222f21</RequestId>\r\n" . "  </ResponseMetadata>\r\n" . "</GetMetricStatisticsResponse>";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $return = $this->cloudWatchInstance->getMetricStatistics(array('MeasureName' => 'CPUUtilization', 'Statistics' => array('Average'), 'Dimensions' => array('InstanceId' => 'i-93ba31fa'), 'StartTime' => '2009-11-19T21:51:57+00:00', 'EndTime' => '2009-11-19T21:56:57+00:00'));
     $arrReturn = array('label' => 'CPUUtilization', 'datapoints' => array(0 => array('Timestamp' => '2009-11-19T21:52:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.09'), 1 => array('Timestamp' => '2009-11-19T21:55:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.18'), 2 => array('Timestamp' => '2009-11-19T21:54:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.09'), 3 => array('Timestamp' => '2009-11-19T21:51:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.18'), 4 => array('Timestamp' => '2009-11-19T21:53:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.09')));
     $this->assertSame($arrReturn, $return);
 }
Пример #8
0
 /**
  * Load HTTP client w/ fixture
  *
  * @param string $fixture Fixture name
  *
  * @return HttpClient
  */
 protected function getClient($fixture)
 {
     $file = realpath(__DIR__ . '/../../../../fixtures/wikipedia/' . $fixture);
     $adapter = new TestAdapter();
     $adapter->setResponse(file_get_contents($file));
     $client = new HttpClient();
     $client->setAdapter($adapter);
     return $client;
 }
Пример #9
0
 public function testRetrieve()
 {
     $mock = $this->getMock('WebArchive\\Provider\\ProviderInterface');
     $mock->expects($this->once())->method('generateSnapshots')->will($this->returnValue(true));
     $client = new Client(new Request(null), $mock);
     $adapter = new TestAdapter();
     $adapter->setResponse(new Response());
     $client->getClient()->setAdapter($adapter);
     $this->assertTrue($client->retrieve());
 }
Пример #10
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     $this->gogrid = new Server('foo', 'bar');
     $this->httpClientAdapterTest = new \Zend\Http\Client\Adapter\Test();
     $this->gogrid->getHttpClient()->setAdapter($this->httpClientAdapterTest);
     $filename = __DIR__ . '/_files/' . $this->getName() . '.response';
     if (file_exists($filename)) {
         $this->httpClientAdapterTest->setResponse($this->loadResponse($filename));
     }
 }
Пример #11
0
 /**
  * Result is not HTTP/1.1 200
  */
 public function testHttpError()
 {
     $client = new Client();
     $adapter = new Test();
     $adapter->setResponse(file_get_contents(__DIR__ . '/../data/google-map-response/03.txt'));
     $client->setAdapter($adapter);
     $map = new GoogleMap($client);
     $result = $map->request('My address');
     $this->assertNull($result->lat);
     $this->assertNull($result->lng);
 }
Пример #12
0
 /**
  * Load WorldCatUtils client w/ fixture
  *
  * @param string $fixture Fixture name
  * @param bool   $silent  Use silent mode?
  *
  * @return WorldCatUtils
  */
 protected function getClient($fixture = null, $silent = true)
 {
     $client = new HttpClient();
     if (null !== $fixture) {
         $adapter = new TestAdapter();
         $file = realpath(__DIR__ . '/../../../../fixtures/worldcat/' . $fixture);
         $adapter->setResponse(file_get_contents($file));
         $client->setAdapter($adapter);
     }
     return new WorldCatUtils('dummy', $client, $silent);
 }
Пример #13
0
 public function testDescribeMultipleAvailabilityZones()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<DescribeAvailabilityZonesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <availabilityZoneInfo>\r\n" . "    <item>\r\n" . "      <zoneName>us-east-1a</zoneName>\r\n" . "      <zoneState>available</zoneState>\r\n" . "    </item>\r\n" . "    <item>\r\n" . "      <zoneName>us-east-1b</zoneName>\r\n" . "      <zoneState>available</zoneState>\r\n" . "    </item>\r\n" . "    <item>\r\n" . "      <zoneName>us-east-1c</zoneName>\r\n" . "      <zoneState>available</zoneState>\r\n" . "    </item>\r\n" . "  </availabilityZoneInfo>\r\n" . "</DescribeAvailabilityZonesResponse>";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $response = $this->availabilityZones->describe();
     $this->assertInternalType('array', $response);
     $arrExpected = array('us-east-1a', 'us-east-1b', 'us-east-1c');
     foreach ($response as $k => $node) {
         $this->assertEquals($arrExpected[$k], $node['zoneName']);
     }
 }
Пример #14
0
 /**
  * @covers ::updateAddressFormats
  */
 public function testUpdateAddressFormatsUsesProgresAdapter()
 {
     $testAdapter = new HttpTestAdapter();
     $testAdapter->setResponse([(new HttpResponse())->setContent('empty'), (new HttpResponse())->setContent('{"name": "ZZ"}')]);
     $httpClient = new HttpClient();
     $httpClient->setAdapter($testAdapter);
     $progressAdapter = $this->getMock('Zend\\ProgressBar\\Adapter\\AbstractAdapter');
     $progressAdapter->expects($this->any())->method('notify')->with($this->logicalOr($this->equalTo(0.0), $this->equalTo(1.0)), $this->equalTo(1.0));
     $maintenanceService = new MaintenanceService($this->options, $httpClient);
     $maintenanceService->updateAddressFormats($progressAdapter);
 }
Пример #15
0
 /**
  * Data is OK, but the response header
  * is HTTP/1.1 404 Not Found
  */
 public function testNot200ResponseCode()
 {
     $client = new Client();
     $adapter = new Test();
     $adapter->setResponse(file_get_contents(__DIR__ . '/../data/ja-response/03.txt'));
     $client->setAdapter($adapter);
     $map = new JaMap($client);
     $result1 = $map->request("Hringbraut 107, 101 Reykjavík");
     $this->assertNull($result1->lat);
     $this->assertNull($result1->lng);
 }
Пример #16
0
 /**
  * @return \WebArchive\SnapshotCollection
  */
 private function generateSnapshots()
 {
     $uri = 'http://pokap.io/';
     $provider = new MementoProvider();
     $client = new Client($provider->createUrlRequest($uri));
     $response = new Response();
     $response->setContent(implode(gzfile(__DIR__ . '/fixtures/pokap.io-memento.gz')));
     $adapter = new TestAdapter();
     $adapter->setResponse($response);
     $client->setAdapter($adapter);
     return $provider->generateSnapshots($client->send(), $uri);
 }
Пример #17
0
 /**
  * @param int $year
  *
  * @return \WebArchive\SnapshotCollection
  */
 private function generateSnapshots($year)
 {
     $uri = 'http://archive.org/';
     $provider = new WayBackProvider($year);
     $client = new Client($provider->createUrlRequest($uri));
     $response = new Response();
     $response->setContent(implode(gzfile(__DIR__ . '/fixtures/archive.org-' . $year . '.html.gz')));
     $adapter = new TestAdapter();
     $adapter->setResponse($response);
     $client->setAdapter($adapter);
     return $provider->generateSnapshots($client->send(), $uri);
 }
Пример #18
0
 /**
  * Set up the test case
  *
  * @return void
  */
 public function setUp()
 {
     $this->rackspace = new RackspaceFiles('foo', 'bar');
     $this->httpClientAdapterTest = new HttpTest();
     $this->rackspace->getHttpClient()->setAdapter($this->httpClientAdapterTest);
     // authentication (from a file)
     $this->httpClientAdapterTest->setResponse(self::loadResponse('../../_files/testAuthenticate'));
     $this->assertTrue($this->rackspace->authenticate(), 'Authentication failed');
     $this->metadata = array('foo' => 'bar', 'foo2' => 'bar2');
     $this->metadata2 = array('hello' => 'world');
     // load the HTTP response (from a file)
     $this->httpClientAdapterTest->setResponse($this->loadResponse($this->getName()));
 }
 public function setUp()
 {
     $this->options = array('url' => TESTS_ZENDSERVICE_OPENSTACK_URL, 'user' => TESTS_ZENDSERVICE_OPENSTACK_USER, 'password' => TESTS_ZENDSERVICE_OPENSTACK_PASSWORD, 'key' => TESTS_ZENDSERVICE_OPENSTACK_APIKEY);
     $http = new HttpClient();
     if (!TESTS_ZENDSERVICE_OPENSTACK_ONLINE && $this->responseExists($this->getName())) {
         $httpAdapter = new HttpTest();
         $httpAdapter->setResponse($this->loadResponse('../../Identity/_files/testAuthenticate'));
         $http->setAdapter($httpAdapter);
     }
     $this->compute = new Compute($this->options, $http);
     if (!TESTS_ZENDSERVICE_OPENSTACK_ONLINE && $this->responseExists($this->getName())) {
         $this->compute->getHttpClient()->getAdapter()->setResponse($this->loadResponse($this->getName()));
     }
 }
 public function setUp()
 {
     $this->options = array('url' => 'http://identity.api.openstack.com', 'user' => 'test', 'password' => 'test', 'key' => '123cfe4c13a3e321d609c402cd43f936a');
     $this->backupId = '2ef47aee-8844-490c-804d-2a8efe561c65';
     $this->volumeId = '795114e8-7489-40be-a978-83797f2c1dd3';
     if (!$this->responseExists($this->getName())) {
         $this->markTestSkipped('I cannot find the ' . $this->getName() . '.response file');
     }
     $httpAdapter = new HttpTest();
     $httpAdapter->setResponse($this->loadResponse('../../../Identity/_files/testAuthenticate'));
     $http = new HttpClient();
     $http->setAdapter($httpAdapter);
     $this->backup = new Backup($this->options, $http);
     $this->backup->getHttpClient()->getAdapter()->setResponse($this->loadResponse($this->getName()));
 }
Пример #21
0
 public function testResetAttribute()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<ResetImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <return>true</return>\r\n" . "</ResetImageAttributeResponse>\r\n";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $return = $this->ec2ImageInstance->resetAttribute('ami-61a54008', 'launchPermission');
     $this->assertTrue($return);
 }
Пример #22
0
 /**
  * Ensures that groupPoolGetPhotos() throws an exception when an invalid group_id is given
  *
  * @return void
  */
 public function testGroupPoolGetPhotosExceptionGroupIdInvalid()
 {
     $this->flickr->getRestClient()->getHttpClient()->setAdapter($this->httpClientAdapterTest);
     $this->httpClientAdapterTest->setResponse($this->loadResponse(__FUNCTION__));
     $this->setExpectedException('Zend\\Service\\Flickr\\Exception\\RuntimeException', 'Group not found');
     $this->flickr->groupPoolGetPhotos('2e38a9d9425d7e2c9d0788455e9ccc61');
 }
Пример #23
0
 public function testRevokeSecurityGroupName()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" . "<RevokeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <return>true</return>\r\n" . "</RevokeSecurityGroupIngressResponse>\r\n";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $return = $this->securitygroupsInstance->revokeGroup('MyGroup', 'groupname', '15333848');
     $this->assertTrue($return);
 }
Пример #24
0
 /**
  * testJobList
  *
  * @return void
  */
 public function testJobList()
 {
     $this->_job->getHttpClient()->setAdapter($this->_httpClientAdapterTest);
     $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));
     $joblist = $this->_job->getList();
     $this->assertEquals(count($joblist), 2);
     $this->assertEquals($joblist->getStatus(), 'success');
     $job = $joblist[0];
     $this->assertEquals($job->getAttribute('id'), '583288');
     $this->assertEquals($job->getAttribute('owner'), '*****@*****.**');
     $command = $job->getAttribute('command');
     $this->assertEquals($command['name'], 'DeleteVirtualServer');
     $history = $job->getAttribute('history');
     $this->assertEquals($history[0]['id'], '3303238');
     $this->assertEquals(count($history), 4);
 }
 public function setUp()
 {
     $this->options = array('url' => TESTS_ZENDSERVICE_OPENSTACK_URL, 'user' => TESTS_ZENDSERVICE_OPENSTACK_USER, 'password' => TESTS_ZENDSERVICE_OPENSTACK_PASSWORD, 'key' => TESTS_ZENDSERVICE_OPENSTACK_APIKEY);
     $this->volumeId = '5aa119a8-d25b-45a7-8d1b-88e127885635';
     $this->snapshotId = '2bb856e1-b3d8-4432-a858-09e4ce939389';
     $this->volumeTypeId = '6685584b-1eac-4da6-b5c3-555430cf68ff';
     if (!$this->responseExists($this->getName())) {
         $this->markTestSkipped('I cannot find the ' . $this->getName() . '.response file');
     }
     $httpAdapter = new HttpTest();
     $httpAdapter->setResponse($this->loadResponse('../../Identity/_files/testAuthenticate'));
     $http = new HttpClient();
     $http->setAdapter($httpAdapter);
     $this->blockStorage = new BlockStorage($this->options, $http);
     $this->blockStorage->getHttpClient()->getAdapter()->setResponse($this->loadResponse($this->getName()));
 }
Пример #26
0
 /**
  * Tests Zend_Service_Amazon_Ec2_Elasticip->release()
  */
 public function testReleaseElasticIp()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<ReleaseAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <return>true</return>\r\n" . "</ReleaseAddressResponse>";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $return = $this->elasticip->release('67.202.55.255');
     $this->assertTrue($return);
 }
Пример #27
0
 /**
  * Create connector with fixture file.
  *
  * @param string $fixture Fixture file
  *
  * @return Connector
  *
  * @throws InvalidArgumentException Fixture file does not exist
  */
 protected function createConnector($fixture = null)
 {
     $adapter = new TestAdapter();
     if ($fixture) {
         $file = realpath(__DIR__ . '/../../../../../../tests/fixtures/resolver/response/' . $fixture);
         if (!is_string($file) || !file_exists($file) || !is_readable($file)) {
             throw new InvalidArgumentException(sprintf('Unable to load fixture file: %s ', $file));
         }
         $response = file_get_contents($file);
         $responseObj = HttpResponse::fromString($response);
         $adapter->setResponse($responseObj);
     }
     $client = new \Zend\Http\Client();
     $client->setAdapter($adapter);
     $conn = new Redi($this->openUrlConfig['OpenURL']['url'], $client);
     return $conn;
 }
Пример #28
0
 public function testUnmonitorInstance()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<UnmonitorInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <instancesSet>" . "    <item>" . "      <instanceId>i-43a4412a</instanceId>" . "      <monitoring>" . "        <state>pending</state>" . "      </monitoring>" . "    </item>" . "  </instancesSet>" . "</UnmonitorInstancesResponse>\r\n";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $return = $this->instance->unmonitor('i-43a4412a');
     $arrReturn = array(array('instanceid' => 'i-43a4412a', 'monitorstate' => 'pending'));
     $this->assertSame($arrReturn, $return);
 }
Пример #29
0
 /**
  * Tests ZendService\Amazon\Ec2\Ebs->detachVolume()
  */
 public function testDetachVolume()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<DetachVolumeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <volumeId>vol-4d826724</volumeId>\r\n" . "  <instanceId>i-6058a509</instanceId>\r\n" . "  <device>/dev/sdh</device>\r\n" . "  <status>detaching</status>\r\n" . "  <attachTime>2008-05-08T11:51:50.000Z</attachTime>\r\n" . "</DetachVolumeResponse>";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $return = $this->ebsInstance->detachVolume('vol-4d826724');
     $arrVolume = array('volumeId' => 'vol-4d826724', 'instanceId' => 'i-6058a509', 'device' => '/dev/sdh', 'status' => 'detaching', 'attachTime' => '2008-05-08T11:51:50.000Z');
     $this->assertSame($arrVolume, $return);
 }
Пример #30
0
 public function testDeleteDoesNotFailOnValidKey()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" . "<DeleteKeyPair xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <return>true</return>\r\n" . "</DeleteKeyPair>";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $response = $this->keypairInstance->delete('example-key-name');
     $this->assertInternalType('boolean', $response);
     $this->assertTrue($response);
 }