作者:bitmovi
项目:azure-sdk-for-ph
public function setUp()
{
parent::setUp();
$serviceBusWrapper = $this->builder->createServiceBusService(TestResources::getServiceBusConnectionString());
$this->_createdTopics = array();
$this->_createdSubscriptions = array();
$this->_createdRules = array();
$this->_createdQueues = array();
parent::setProxy($serviceBusWrapper);
}
作者:southworksco
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Common\Models\GetServicePropertiesResult::setValue
*/
public function testSetValue()
{
// Setup
$result = new GetServicePropertiesResult();
$expected = ServiceProperties::create(TestResources::getServicePropertiesSample());
// Test
$result->setValue($expected);
// Assert
$this->assertEquals($expected, $result->getValue());
}
作者:rdohm
项目:azure-sdk-for-ph
public static function setUpBeforeClass()
{
$storageKey = TestResources::accountKey();
$storageName = TestResources::accountName();
if (empty($storageKey)) {
throw new \Exception('AZURE_STORAGE_KEY envionment variable is missing');
}
if (empty($storageName)) {
throw new \Exception('AZURE_STORAGE_ACCOUNT envionment variable is missing');
}
}
作者:rdohm
项目:azure-sdk-for-ph
public function __construct()
{
$config = new Configuration();
$blobUri = 'http://' . TestResources::accountName() . '.blob.core.windows.net';
$config->setProperty(BlobSettings::ACCOUNT_KEY, TestResources::accountKey());
$config->setProperty(BlobSettings::ACCOUNT_NAME, TestResources::accountName());
$config->setProperty(BlobSettings::URI, $blobUri);
$blobRestProxy = BlobService::create($config);
parent::__construct($config, $blobRestProxy);
$this->_createdContainers = array();
}
作者:bitmovi
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\ServiceBus\Internal\WrapRestProxy::__construct
* @covers WindowsAzure\ServiceBus\Internal\WrapRestProxy::wrapAccessToken
*/
public function testWrapAccessToken()
{
$settings = ServiceBusSettings::createFromConnectionString(TestResources::getServiceBusConnectionString());
$wrapUri = $settings->getWrapEndpointUri();
$wrapUserName = $settings->getWrapName();
$wrapPassword = $settings->getWrapPassword();
$scope = str_replace('https', 'http', $settings->getServiceBusEndpointUri());
$wrapAccessTokenResult = $this->_wrapRestProxy->wrapAccessToken($wrapUri, $wrapUserName, $wrapPassword, $scope);
$this->assertNotNull($wrapAccessTokenResult);
$this->assertNotNull($wrapAccessTokenResult->getAccessToken());
}
作者:rdohm
项目:azure-sdk-for-ph
public function __construct()
{
$config = new Configuration();
$queueUri = TestResources::accountName() . '.queue.core.windows.net';
$config->setProperty(QueueSettings::ACCOUNT_KEY, TestResources::accountKey());
$config->setProperty(QueueSettings::ACCOUNT_NAME, TestResources::accountName());
$config->setProperty(QueueSettings::URI, $queueUri);
$queueRestProxy = QueueService::create($config);
parent::__construct($config, $queueRestProxy);
$this->_createdQueues = array();
}
作者:southworksco
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Common\Internal\Serialization\XmlSerializer::serialize
* @covers WindowsAzure\Common\Internal\Serialization\XmlSerializer::_arr2xml
*/
public function testSerialize()
{
// Setup
$xmlSerializer = new XmlSerializer();
$propertiesSample = TestResources::getServicePropertiesSample();
$properties = ServiceProperties::create($propertiesSample);
$expected = $properties->toXml($xmlSerializer);
$array = $properties->toArray();
$serializerProperties = array(XmlSerializer::ROOT_NAME => ServiceProperties::$xmlRootName);
// Test
$actual = $xmlSerializer->serialize($array, $serializerProperties);
$this->assertEquals($expected, $actual);
}
作者:rdohm
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Table\TableService::create
*/
public function testCreateWithConfig()
{
// Setup
$uri = 'http://' . TestResources::accountName() . '.table.core.windows.net';
$config = new Configuration();
$config->setProperty(TableSettings::ACCOUNT_KEY, TestResources::accountKey());
$config->setProperty(TableSettings::ACCOUNT_NAME, TestResources::accountName());
$config->setProperty(TableSettings::URI, $uri);
// Test
$tableRestProxy = TableService::create($config);
// Assert
$this->assertInstanceOf('WindowsAzure\\Table\\Internal\\ITable', $tableRestProxy);
}
作者:rdohm
项目:azure-sdk-for-ph
public function __construct()
{
$config = new Configuration();
$config->setProperty(ServiceManagementSettings::SUBSCRIPTION_ID, TestResources::serviceManagementSubscriptionId());
$config->setProperty(ServiceManagementSettings::URI, Resources::SERVICE_MANAGEMENT_URL);
$config->setProperty(ServiceManagementSettings::CERTIFICATE_PATH, TestResources::serviceManagementCertificatePath());
$serviceManagementRestProxy = ServiceManagementService::create($config);
parent::__construct($config, $serviceManagementRestProxy);
$this->createdStorageServices = array();
$this->createdAffinityGroups = array();
$this->storageCount = count($this->restProxy->listStorageServices()->getStorageServices());
$this->affinityGroupCount = count($this->restProxy->listAffinityGroups()->getAffinityGroups());
}
作者:bitmovi
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Queue\Models\WindowsAzureQueueMessage::createFromPeekMessages
*/
public function testCreateFromPeekMessages()
{
// Setup
$sample = TestResources::listMessagesSample();
$sample = $sample['QueueMessage'];
// Test
$actual = WindowsAzureQueueMessage::createFromPeekMessages($sample);
// Assert
$this->assertEquals($sample['MessageId'], $actual->getMessageId());
$this->assertEquals(Utilities::rfc1123ToDateTime($sample['InsertionTime']), $actual->getInsertionDate());
$this->assertEquals(Utilities::rfc1123ToDateTime($sample['ExpirationTime']), $actual->getExpirationDate());
$this->assertEquals(intval($sample['DequeueCount']), $actual->getDequeueCount());
$this->assertEquals($sample['MessageText'], $actual->getMessageText());
}
作者:bitmovi
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Blob\Models\CreateBlobPagesResult::create
*/
public function testCreate()
{
// Setup
$sample = TestResources::listBlobsOneEntry();
$expected = $sample['Blobs']['Blob']['Properties'];
$expectedDate = Utilities::rfc1123ToDateTime($expected['Last-Modified']);
// Test
$actual = CreateBlobPagesResult::create($expected);
// Assert
$this->assertEquals($expectedDate, $actual->getLastModified());
$this->assertEquals($expected['Etag'], $actual->getETag());
$this->assertEquals($expected['Content-MD5'], $actual->getContentMD5());
$this->assertEquals(intval($expected['x-ms-blob-sequence-number']), $actual->getSequenceNumber());
}
作者:rdohm
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Blob\Models\ListBlobsResult::create
*/
public function testCreateWithMultipleEntries()
{
// Setup
$sample = TestResources::listBlobsMultipleEntries();
// Test
$actual = ListBlobsResult::create($sample);
// Assert
$this->assertCount(2, $actual->getBlobs());
$this->assertCount(2, $actual->getBlobPrefixes());
$this->assertEquals($sample['Marker'], $actual->getMarker());
$this->assertEquals(intval($sample['MaxResults']), $actual->getMaxResults());
$this->assertEquals($sample['NextMarker'], $actual->getNextMarker());
return $actual;
}
作者:jdrui
项目:Microsoft-Azure-PHP-SDK-Storag
/**
* @covers WindowsAzure\Common\Internal\Filters\WrapFilter::handleResponse
*/
public function testHandleResponse()
{
// Setup
$channel = new HttpClient();
$url = new Url('http://microsoft.com');
$channel->setUrl($url);
$response = null;
$settings = ServiceBusSettings::createFromConnectionString(TestResources::getServiceBusConnectionString());
$wrapUri = $settings->getWrapEndpointUri();
$wrapFilter = new WrapFilter($wrapUri, $settings->getWrapName(), $settings->getWrapPassword(), $this->_wrapRestProxy);
// Test
$response = $wrapFilter->handleResponse($channel, $response);
// Assert
$this->assertNull($response);
}
作者:jdrui
项目:Microsoft-Azure-PHP-SDK-Storag
/**
* @covers WindowsAzure\Common\Internal\OAuthRestProxy::getAccessToken
* @covers WindowsAzure\Common\Internal\OAuthRestProxy::__construct
*/
public function testGetAccessToken()
{
// Setup
$channel = new HttpClient();
$uri = Resources::MEDIA_SERVICES_OAUTH_URL;
$connection = TestResources::getMediaServicesConnectionParameters();
$settings = new MediaServicesSettings($connection['accountName'], $connection['accessKey']);
$scope = Resources::MEDIA_SERVICES_OAUTH_SCOPE;
// Test
$proxy = new OAuthRestProxy($channel, $uri);
$actual = $proxy->getAccessToken(Resources::OAUTH_GT_CLIENT_CREDENTIALS, $settings->getAccountName(), $settings->getAccessKey(), $scope);
// Assert
$this->assertNotNull($proxy);
$this->assertNotNull($actual->getAccessToken());
$this->assertGreaterThan(time(), $actual->getExpiresIn());
$this->assertEquals($scope, $actual->getScope());
}
作者:bitmovi
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Queue\Models\ListQueuesResult::create
*/
public function testCreateWithMultipleEntries()
{
// Setup
$sample = TestResources::listQueuesMultipleEntries();
// Test
$actual = ListQueuesResult::create($sample);
// Assert
$queues = $actual->getQueues();
$this->assertCount(2, $queues);
$this->assertEquals($sample['Queues']['Queue'][0]['Name'], $queues[0]->getName());
$this->assertEquals($sample['Queues']['Queue'][0]['Url'], $queues[0]->getUrl());
$this->assertEquals($sample['Queues']['Queue'][1]['Name'], $queues[1]->getName());
$this->assertEquals($sample['Queues']['Queue'][1]['Url'], $queues[1]->getUrl());
$this->assertEquals($sample['MaxResults'], $actual->getMaxResults());
$this->assertEquals($sample['NextMarker'], $actual->getNextMarker());
return $actual;
}
作者:rdohm
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Blob\Models\ListContainersResult::create
*/
public function testCreateWithMultipleEntries()
{
// Setup
$sample = TestResources::listContainersMultipleEntries();
// Test
$actual = ListContainersResult::create($sample);
// Assert
$containers = $actual->getContainers();
$this->assertCount(2, $containers);
$this->assertEquals($sample['Containers']['Container'][0]['Name'], $containers[0]->getName());
$this->assertEquals($sample['Containers']['Container'][0]['Url'], $containers[0]->getUrl());
$this->assertEquals(Utilities::rfc1123ToDateTime($sample['Containers']['Container'][0]['Properties']['Last-Modified']), $containers[0]->getProperties()->getLastModified());
$this->assertEquals($sample['Containers']['Container'][0]['Properties']['Etag'], $containers[0]->getProperties()->getEtag());
$this->assertEquals($sample['Containers']['Container'][1]['Name'], $containers[1]->getName());
$this->assertEquals($sample['Containers']['Container'][1]['Url'], $containers[1]->getUrl());
$this->assertEquals(Utilities::rfc1123ToDateTime($sample['Containers']['Container'][1]['Properties']['Last-Modified']), $containers[1]->getProperties()->getLastModified());
$this->assertEquals($sample['Containers']['Container'][1]['Properties']['Etag'], $containers[1]->getProperties()->getEtag());
$this->assertEquals($sample['MaxResults'], $actual->getMaxResults());
$this->assertEquals($sample['NextMarker'], $actual->getNextMarker());
return $actual;
}
作者:rdohm
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Blob\Models\BlobProperties::create
*/
public function testCreate()
{
// Setup
$sample = TestResources::listBlobsOneEntry();
$expected = $sample['Blobs']['Blob']['Properties'];
$expectedDate = Utilities::rfc1123ToDateTime($expected['Last-Modified']);
// Test
$actual = BlobProperties::create($expected);
// Assert
$this->assertEquals($expectedDate, $actual->getLastModified());
$this->assertEquals($expected['Etag'], $actual->getEtag());
$this->assertEquals(intval($expected['Content-Length']), $actual->getContentLength());
$this->assertEquals($expected['Content-Type'], $actual->getContentType());
$this->assertEquals($expected['Content-Encoding'], $actual->getContentEncoding());
$this->assertEquals($expected['Content-Language'], $actual->getContentLanguage());
$this->assertEquals($expected['Content-MD5'], $actual->getContentMD5());
$this->assertEquals($expected['Cache-Control'], $actual->getCacheControl());
$this->assertEquals(intval($expected['x-ms-blob-sequence-number']), $actual->getSequenceNumber());
$this->assertEquals($expected['BlobType'], $actual->getBlobType());
$this->assertEquals($expected['LeaseStatus'], $actual->getLeaseStatus());
}
作者:jdrui
项目:Microsoft-Azure-PHP-SDK-Storag
/**
* @covers WindowsAzure\MediaServices\MediaServicesRestProxy::getAssetStorageAccount
*/
public function testGetAssetStorageAccount()
{
// Setup
$asset = new Asset(Asset::OPTIONS_NONE);
$asset->setName(TestResources::MEDIA_SERVICES_ASSET_NAME . $this->createSuffix());
$asset = $this->createAsset($asset);
$connectionParameters = TestResources::getMediaServicesConnectionParameters();
$storageAccountName = $connectionParameters['accountName'];
// Test
$result = $this->restProxy->getAssetStorageAccount($asset);
// Assert
$this->assertEquals($storageAccountName, $result->getName());
}
作者:bitmovi
项目:azure-sdk-for-ph
public function testIngestEncryptedAssetAndDecryptAtAzure()
{
// Setup
$content = TestResources::MEDIA_SERVICES_DUMMY_FILE_CONTENT;
$aesKey = Utilities::generateCryptoKey(32);
$protectionKeyId = $this->restProxy->getProtectionKeyId(ProtectionKeyTypes::X509_CERTIFICATE_THUMBPRINT);
$protectionKey = $this->restProxy->getProtectionKey($protectionKeyId);
$contentKey = new ContentKey();
$contentKey->setContentKey($aesKey, $protectionKey);
$contentKey->setProtectionKeyId($protectionKeyId);
$contentKey->setProtectionKeyType(ProtectionKeyTypes::X509_CERTIFICATE_THUMBPRINT);
$contentKey->setContentKeyType(ContentKeyTypes::STORAGE_ENCRYPTION);
$contentKey = $this->createContentKey($contentKey);
$asset = new Asset(Asset::OPTIONS_STORAGE_ENCRYPTED);
$asset->setName(TestResources::MEDIA_SERVICES_ASSET_NAME . $this->createSuffix());
$asset = $this->createAsset($asset);
$this->restProxy->linkContentKeyToAsset($asset, $contentKey);
$initializationVector = Utilities::generateCryptoKey(8);
$encrypted = Utilities::ctrCrypt($content, $aesKey, str_pad($initializationVector, 16, chr(0)));
// Test
$access = new AccessPolicy(TestResources::MEDIA_SERVICES_ACCESS_POLICY_NAME . $this->createSuffix());
$access->setDurationInMinutes(30);
$access->setPermissions(AccessPolicy::PERMISSIONS_WRITE);
$access = $this->createAccessPolicy($access);
$locator = new Locator($asset, $access, Locator::TYPE_SAS);
$locator->setName(TestResources::MEDIA_SERVICES_LOCATOR_NAME . $this->createSuffix());
$locator->setStartTime(new \DateTime('now -5 minutes'));
$locator = $this->createLocator($locator);
$fileName = TestResources::MEDIA_SERVICES_DUMMY_FILE_NAME;
$this->restProxy->uploadAssetFile($locator, $fileName, $encrypted);
$this->restProxy->createFileInfos($asset);
$files = $this->restProxy->getAssetAssetFileList($asset);
$files[0]->setIsEncrypted(true);
$files[0]->setEncryptionKeyId($contentKey->getId());
$files[0]->setEncryptionScheme(EncryptionSchemes::STORAGE_ENCRYPTION);
$files[0]->setEncryptionVersion(Resources::MEDIA_SERVICES_ENCRYPTION_VERSION);
$files[0]->setInitializationVector(Utilities::base256ToDec($initializationVector));
$this->restProxy->updateAssetFile($files[0]);
$decodeProcessor = $this->restProxy->getLatestMediaProcessor(TestResources::MEDIA_SERVICES_DECODE_PROCESSOR_NAME);
$task = new Task(TestResources::getMediaServicesTask($this->getOutputAssetName()), $decodeProcessor->getId(), TaskOptions::NONE);
$job = new Job();
$job->setName(TestResources::MEDIA_SERVICES_JOB_NAME . $this->createSuffix());
$job = $this->createJob($job, array($asset), array($task));
$this->waitJobStatus($job, array(Job::STATE_FINISHED, Job::STATE_ERROR));
$this->assertEquals($this->restProxy->getJobStatus($job), Job::STATE_FINISHED);
$outputAssets = $this->restProxy->getJobOutputMediaAssets($job);
$this->assertCount(1, $outputAssets);
$accessPolicy = new AccessPolicy(TestResources::MEDIA_SERVICES_ACCESS_POLICY_NAME . $this->createSuffix());
$accessPolicy->setDurationInMinutes(300);
$accessPolicy->setPermissions(AccessPolicy::PERMISSIONS_READ);
$accessPolicy = $this->createAccessPolicy($accessPolicy);
$locator = new Locator($outputAssets[0], $accessPolicy, Locator::TYPE_SAS);
$locator->setName(TestResources::MEDIA_SERVICES_LOCATOR_NAME . $this->createSuffix());
$locator->setStartTime(new \DateTime('now -5 minutes'));
$locator = $this->createLocator($locator);
// without sleep() Locator hasn't enough time to create URL, so that's why we have to use at least sleep(30)
sleep(40);
$method = Resources::HTTP_GET;
$url = new Url($locator->getBaseUri() . '/' . TestResources::MEDIA_SERVICES_DUMMY_FILE_NAME . $locator->getContentAccessComponent());
$filters = array();
$statusCode = Resources::STATUS_OK;
$httpClient = new HttpClient();
$httpClient->setMethod($method);
$httpClient->setExpectedStatusCode($statusCode);
$actual = $httpClient->send($filters, $url);
$this->assertEquals($content, $actual);
}
作者:southworksco
项目:azure-sdk-for-ph
/**
* @covers WindowsAzure\Common\Models\OAuthAccessToken::getScope
* @covers WindowsAzure\Common\Models\OAuthAccessToken::setScope
*/
public function testGetSetScope()
{
// Setup
$sample = TestResources::getTestOAuthAccessToken();
// Test
$actual = new OAuthAccessToken();
$actual->setScope($sample[Resources::OAUTH_SCOPE]);
// Assert
$this->assertEquals($sample[Resources::OAUTH_SCOPE], $actual->getScope());
}