Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
fixing UT
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rodrigues committed Oct 12, 2012
1 parent d0f4a8a commit b4af3be
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 2 deletions.
70 changes: 69 additions & 1 deletion test/services/core/storageservicesettings-tests.js
Expand Up @@ -177,7 +177,7 @@ suite('storageservicesettings-tests', function () {
var expectedTableEndpoint = url.format({ protocol: protocol, host: expectedName + '.' + ConnectionStringKeys.TABLE_BASE_DNS_NAME });
var expectedBlobEndpoint = 'http://myprivateblobdns.com';
var expectedQueueEndpoint = 'http://myprivatequeuedns.com';
var connectionString = 'DefaultEndpointsProtocol=' + protocol + ';AccountName=' + expectedName + ';AccountKey=' + expectedKey + ';QueueEndpoint=' + expectedQueueEndpoint+ ';BlobEndpoint=' + expectedBlobEndpoint;
var connectionString = 'DefaultEndpointsProtocol=' + protocol + ';AccountName=' + expectedName + ';AccountKey=' + expectedKey + ';QueueEndpoint=' + expectedQueueEndpoint + ';BlobEndpoint=' + expectedBlobEndpoint;

// Test
var actual = StorageServiceSettings.createFromConnectionString(connectionString);
Expand Down Expand Up @@ -225,6 +225,74 @@ suite('storageservicesettings-tests', function () {
}).should.throw('The provided account key ' + invalidKey + ' is not a valid base64 string.');
});

test('testCreateFromConnectionStringWithQueueAndBlobAndTableEndpointSpecfied', function () {
// Setup
var protocol = 'https';
var expectedName = 'mytestaccount';
var expectedKey = 'AhlzsbLRkjfwObuqff3xrhB2yWJNh1EMptmcmxFJ6fvPTVX3PZXwrG2YtYWf5DPMVgNsteKStM5iBLlknYFVoA==';
var expectedTableEndpoint = 'http://myprivatetabledns.com';
var expectedBlobEndpoint = 'http://myprivateblobdns.com';
var expectedQueueEndpoint = 'http://myprivatequeuedns.com';
var connectionString = 'DefaultEndpointsProtocol=' + protocol + ';AccountName=' + expectedName + ';AccountKey=' + expectedKey + ';QueueEndpoint=' + expectedQueueEndpoint + ';BlobEndpoint=' + expectedBlobEndpoint+ ';TableEndpoint=' + expectedTableEndpoint;

// Test
var actual = StorageServiceSettings.createFromConnectionString(connectionString);

// Assert
actual._name.should.equal(expectedName);
actual._key.should.equal(expectedKey);
actual._blobEndpointUri.should.equal(expectedBlobEndpoint);
actual._queueEndpointUri.should.equal(expectedQueueEndpoint);
actual._tableEndpointUri.should.equal(expectedTableEndpoint);
});

test('testCreateFromConnectionStringMissingServicesEndpointsFail', function () {
// Setup
var expectedName = 'mytestaccount';
var expectedKey = 'AhlzsbLRkjfwObuqff3xrhB2yWJNh1EMptmcmxFJ6fvPTVX3PZXwrG2YtYWf5DPMVgNsteKStM5iBLlknYFVoA==';
var invalidUri = 'https://www.invalid_domain';
var connectionString = 'BlobEndpoint=' + invalidUri + ';DefaultEndpointsProtocol=http;AccountName=' + expectedName + ';AccountKey=' + expectedKey;

// Test
(function() {
StorageServiceSettings.createFromConnectionString(connectionString);
}).should.throw('The provided URI "' + invalidUri + '" is invalid.');
});

test('testCreateFromConnectionStringWithInvalidSettingKeyFail', function () {
// Setup
var expectedName = 'mytestaccount';
var expectedKey = 'AhlzsbLRkjfwObuqff3xrhB2yWJNh1EMptmcmxFJ6fvPTVX3PZXwrG2YtYWf5DPMVgNsteKStM5iBLlknYFVoA==';
var invalidKey = 'InvalidKey';
var connectionString = 'DefaultEndpointsProtocol=http;' + invalidKey + '=MyValue;AccountName=' + expectedName + ';AccountKey=' + expectedKey;

// Test
(function() {
StorageServiceSettings.createFromConnectionString(connectionString);
}).should.throw('Invalid connection string setting key ' + invalidKey.toLowerCase());
});

test('testCreateFromConnectionStringWithCaseInsensitive', function () {
// Setup
var protocol = 'https';
var expectedName = 'mytestaccount';
var expectedKey = 'AhlzsbLRkjfwObuqff3xrhB2yWJNh1EMptmcmxFJ6fvPTVX3PZXwrG2YtYWf5DPMVgNsteKStM5iBLlknYFVoA==';
var connectionString = 'defaultendpointsprotocol=' + protocol + ';accountname=' + expectedName + ';accountkey=' + expectedKey;
var expectedBlobEndpoint = url.format({ protocol: protocol, host: expectedName + '.' + ConnectionStringKeys.BLOB_BASE_DNS_NAME });
var expectedQueueEndpoint = url.format({ protocol: protocol, host: expectedName + '.' + ConnectionStringKeys.QUEUE_BASE_DNS_NAME });
var expectedTableEndpoint = url.format({ protocol: protocol, host: expectedName + '.' + ConnectionStringKeys.TABLE_BASE_DNS_NAME });

// Test
var actual = StorageServiceSettings.createFromConnectionString(connectionString);

// Assert
actual._name.should.equal(expectedName);
actual._key.should.equal(expectedKey);
actual._blobEndpointUri.should.equal(expectedBlobEndpoint);
actual._queueEndpointUri.should.equal(expectedQueueEndpoint);
actual._tableEndpointUri.should.equal(expectedTableEndpoint);
});

test('getDevelopmentStorageAccount', function () {
var developmentStorageAccount = StorageServiceSettings._getDevelopmentStorageAccount();

Expand Down
35 changes: 34 additions & 1 deletion test/testlist.txt
@@ -1 +1,34 @@
services/core/storageservicesettings-tests.js
cli/commands/generate-psm1-utils-test.js
serviceruntime/roleenvironment-tests.js
serviceruntime/runtimeversionmanager-tests.js
serviceruntime/runtimeversionprotocolclient-tests.js
services/blob/blobservice-tests.js
services/blob/sharedaccesssignature-tests.js
services/blob/sharedkey-tests.js
services/blob/sharedkeylite-tests.js
services/blob/filters-tests.js
services/core/connectionstringparser-tests.js
services/core/serviceclient-tests.js
services/core/exponentialretrypolicyfilter-tests.js
services/core/linearretrypolicyfilter-tests.js
services/core/servicesettings-tests.js
services/core/storageservicesettings-tests.js
services/queue/queueservice-tests.js
services/table/batchserviceclient-tests.js
services/table/sharedkeytable-tests.js
services/table/sharedkeylitetable-tests.js
services/serviceBus/servicebusservice-tests.js
services/serviceBus/wrapservice-tests.js
services/serviceBus/wraptokenmanager-tests.js
services/table/tablequery-tests.js
services/table/tableservice-batch-tests.js
services/table/tableservice-tablequery-tests.js
services/table/tableservice-tests.js
util/atomhandler-tests.js
util/iso8061date-tests.js
util/util-tests.js
util/validate-tests.js
util/certificates/der.decoder-tests.js
util/certificates/der.decoder.pfx.root-tests.js
util/certificates/pkcs.filedecoder-tests.js
azure-tests.js

0 comments on commit b4af3be

Please sign in to comment.