/** * Returns a connection string for this storage account, without sensitive data. * * @return A <code>String</code> that represents the connection string for this storage account, without sensitive * data. */ @Override public String toString() { return this.toString(false); }
/** * Returns a connection string for this storage account, without sensitive data. * * @return A <code>String</code> that represents the connection string for this storage account, without sensitive * data. */ @Override public String toString() { return this.toString(false); }
@Test public void testCloudStorageAccountAnonymousRoundtrip() throws InvalidKeyException, URISyntaxException { String accountString = "BlobEndpoint=http://blobs/"; assertEquals(accountString, CloudStorageAccount.parse(accountString).toString(true)); CloudStorageAccount account = new CloudStorageAccount( null, new StorageUri(new URI("http://blobs/")), null, null, null); AccountsAreEqual(account, CloudStorageAccount.parse(account.toString(true))); }
@Test public void testCloudStorageAccountDevStoreProxyRoundtrip() throws InvalidKeyException, URISyntaxException { String accountString = "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://ipv4.fiddler/"; assertEquals(accountString, CloudStorageAccount.parse(accountString).toString(true)); }
@Test public void testCloudStorageAccountDefaultCloudRoundtrip() throws InvalidKeyException, URISyntaxException { String accountString = "EndpointSuffix=a.b.c;DefaultEndpointsProtocol=http;AccountName=test;" + "AccountKey=abc="; assertEquals(accountString, CloudStorageAccount.parse(accountString).toString(true)); }
@Test public void testCloudStorageAccountExplicitCloudRoundtrip() throws InvalidKeyException, URISyntaxException { String accountString = "EndpointSuffix=a.b.c;BlobEndpoint=https://blobs/;DefaultEndpointsProtocol=https;" + "AccountName=test;AccountKey=abc="; assertEquals(accountString, CloudStorageAccount.parse(accountString).toString(true)); }
@Test public void testCloudStorageAccountEmptyValues() throws InvalidKeyException, URISyntaxException { String accountString = ";EndpointSuffix=a.b.c;;BlobEndpoint=http://blobs/;;" + "AccountName=test;;AccountKey=abc=;;;"; String validAccountString = "EndpointSuffix=a.b.c;BlobEndpoint=http://blobs/;" + "DefaultEndpointsProtocol=http;AccountName=test;AccountKey=abc="; assertEquals(validAccountString, CloudStorageAccount.parse(accountString).toString(true)); }
@Test public void testCloudStorageAccountJustFileToString() throws InvalidKeyException, URISyntaxException { String accountString = "FileEndpoint=http://file/;DefaultEndpointsProtocol=https;AccountName=test;AccountKey=abc="; assertEquals(accountString, CloudStorageAccount.parse(accountString).toString(true)); }
private void connectionStringRoundtripHelper(String accountString) throws InvalidKeyException, URISyntaxException { CloudStorageAccount originalAccount = CloudStorageAccount.parse(accountString); String copiedAccountString = originalAccount.toString(true); CloudStorageAccount copiedAccount = CloudStorageAccount.parse(copiedAccountString); // make sure it round trips this.AccountsAreEqual(originalAccount, copiedAccount); }
@Test public void testCloudStorageAccountDevStoreRoundtrip() throws InvalidKeyException, URISyntaxException { String accountString = "UseDevelopmentStorage=true"; assertEquals(accountString, CloudStorageAccount.parse(accountString).toString(true)); }
@Test public void testCloudStorageAccountJustBlobToString() throws InvalidKeyException, URISyntaxException { String accountString = "BlobEndpoint=http://blobs/;DefaultEndpointsProtocol=http;AccountName=test;AccountKey=abc="; assertEquals(accountString, CloudStorageAccount.parse(accountString).toString(true)); }
@Test public void testCloudStorageAccountJustQueueToString() throws InvalidKeyException, URISyntaxException { String accountString = "QueueEndpoint=http://queue/;DefaultEndpointsProtocol=https;AccountName=test;AccountKey=abc="; assertEquals(accountString, CloudStorageAccount.parse(accountString).toString(true)); }
@Test public void testCloudStorageAccountJustTableToString() throws InvalidKeyException, URISyntaxException { String accountString = "TableEndpoint=http://table/;DefaultEndpointsProtocol=https;AccountName=test;AccountKey=abc="; assertEquals(accountString, CloudStorageAccount.parse(accountString).toString(true)); }
@Test public void testCloudStorageAccountDefaultStorageAccountWithHttp() throws URISyntaxException, InvalidKeyException { StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY); CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(cred, false); assertEquals(cloudStorageAccount.getBlobEndpoint(), new URI(String.format("http://%s.blob.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getQueueEndpoint(), new URI(String.format("http://%s.queue.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getTableEndpoint(), new URI(String.format("http://%s.table.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getFileEndpoint(), new URI(String.format("http://%s.file.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getBlobStorageUri().getSecondaryUri(), new URI(String.format("http://%s-secondary.blob.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getQueueStorageUri().getSecondaryUri(), new URI(String.format("http://%s-secondary.queue.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getTableStorageUri().getSecondaryUri(), new URI(String.format("http://%s-secondary.table.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getFileStorageUri().getSecondaryUri(), new URI(String.format("http://%s-secondary.file.core.windows.net", ACCOUNT_NAME))); String cloudStorageAccountToStringWithSecrets = cloudStorageAccount.toString(true); CloudStorageAccount testAccount = CloudStorageAccount.parse(cloudStorageAccountToStringWithSecrets); AccountsAreEqual(testAccount, cloudStorageAccount); }
@Test public void testCloudStorageAccountDefaultStorageAccountWithHttps() throws URISyntaxException, InvalidKeyException { StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY); CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(cred, true); assertEquals(cloudStorageAccount.getBlobEndpoint(), new URI(String.format("https://%s.blob.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getQueueEndpoint(), new URI(String.format("https://%s.queue.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getTableEndpoint(), new URI(String.format("https://%s.table.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getFileEndpoint(), new URI(String.format("https://%s.file.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getBlobStorageUri().getSecondaryUri(), new URI(String.format("https://%s-secondary.blob.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getQueueStorageUri().getSecondaryUri(), new URI(String.format("https://%s-secondary.queue.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getTableStorageUri().getSecondaryUri(), new URI(String.format("https://%s-secondary.table.core.windows.net", ACCOUNT_NAME))); assertEquals(cloudStorageAccount.getFileStorageUri().getSecondaryUri(), new URI(String.format("https://%s-secondary.file.core.windows.net", ACCOUNT_NAME))); String cloudStorageAccountToStringWithSecrets = cloudStorageAccount.toString(true); CloudStorageAccount testAccount = CloudStorageAccount.parse(cloudStorageAccountToStringWithSecrets); AccountsAreEqual(testAccount, cloudStorageAccount); }
@Test public void testCloudStorageAccountDevelopmentStorageAccount() throws InvalidKeyException, URISyntaxException { CloudStorageAccount devstoreAccount = CloudStorageAccount.getDevelopmentStorageAccount(); assertEquals(devstoreAccount.getBlobStorageUri().getPrimaryUri(), new URI( "http://127.0.0.1:10000/devstoreaccount1")); assertEquals(devstoreAccount.getQueueStorageUri().getPrimaryUri(), new URI( "http://127.0.0.1:10001/devstoreaccount1")); assertEquals(devstoreAccount.getTableStorageUri().getPrimaryUri(), new URI( "http://127.0.0.1:10002/devstoreaccount1")); assertEquals(devstoreAccount.getBlobStorageUri().getSecondaryUri(), new URI( "http://127.0.0.1:10000/devstoreaccount1-secondary")); assertEquals(devstoreAccount.getQueueStorageUri().getSecondaryUri(), new URI( "http://127.0.0.1:10001/devstoreaccount1-secondary")); assertEquals(devstoreAccount.getTableStorageUri().getSecondaryUri(), new URI( "http://127.0.0.1:10002/devstoreaccount1-secondary")); String devstoreAccountToStringWithSecrets = devstoreAccount.toString(true); CloudStorageAccount testAccount = CloudStorageAccount.parse(devstoreAccountToStringWithSecrets); AccountsAreEqual(testAccount, devstoreAccount); // Following should not throw exception: CloudStorageAccount.parse(devstoreAccountToStringWithSecrets); }
private void AccountsAreEqual(CloudStorageAccount a, CloudStorageAccount b) { // endpoints are the same assertEquals(a.getBlobEndpoint(), b.getBlobEndpoint()); assertEquals(a.getQueueEndpoint(), b.getQueueEndpoint()); assertEquals(a.getTableEndpoint(), b.getTableEndpoint()); assertEquals(a.getFileEndpoint(), b.getFileEndpoint()); // storage uris are the same assertEquals(a.getBlobStorageUri(), b.getBlobStorageUri()); assertEquals(a.getQueueStorageUri(), b.getQueueStorageUri()); assertEquals(a.getTableStorageUri(), b.getTableStorageUri()); assertEquals(a.getFileStorageUri(), b.getFileStorageUri()); // seralized representatons are the same. String aToStringNoSecrets = a.toString(); String aToStringWithSecrets = a.toString(true); String bToStringNoSecrets = b.toString(false); String bToStringWithSecrets = b.toString(true); assertEquals(aToStringNoSecrets, bToStringNoSecrets); assertEquals(aToStringWithSecrets, bToStringWithSecrets); // credentials are the same if (a.getCredentials() != null && b.getCredentials() != null) { assertEquals(a.getCredentials().getClass(), b.getCredentials().getClass()); } else if (a.getCredentials() == null && b.getCredentials() == null) { return; } else { fail("credentials mismatch"); } }