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

Commit

Permalink
Merge pull request #25 from tiffanyachen/new-spec
Browse files Browse the repository at this point in the history
Updated with preview swagger and re-recorded tests
  • Loading branch information
tiffanyachen authored Mar 13, 2018
2 parents bf3f736 + 4ac1543 commit ea80c2b
Show file tree
Hide file tree
Showing 137 changed files with 13,402 additions and 5,274 deletions.
2 changes: 1 addition & 1 deletion azure-keyvault-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-parent</artifactId>
<version>1.1-alpha-1</version>
<version>1.1-alpha-2</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
6 changes: 3 additions & 3 deletions azure-keyvault-cryptography/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-parent</artifactId>
<version>1.1-alpha-1</version>
<version>1.1-alpha-2</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -57,12 +57,12 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-core</artifactId>
<version>1.1-alpha-1</version>
<version>1.1-alpha-2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-webkey</artifactId>
<version>1.1-alpha-1</version>
<version>1.1-alpha-2</version>
</dependency>
</dependencies>
</project>
10 changes: 5 additions & 5 deletions azure-keyvault-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-parent</artifactId>
<version>1.1-alpha-1</version>
<version>1.1-alpha-2</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -68,22 +68,22 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-core</artifactId>
<version>1.1-alpha-1</version>
<version>1.1-alpha-2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-cryptography</artifactId>
<version>1.1-alpha-1</version>
<version>1.1-alpha-2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault</artifactId>
<version>1.1-alpha-1</version>
<version>1.1-alpha-2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-webkey</artifactId>
<version>1.1-alpha-1</version>
<version>1.1-alpha-2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import com.microsoft.azure.keyvault.KeyVaultClient;
import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials;
import com.microsoft.azure.keyvault.models.Attributes;
import com.microsoft.azure.keyvault.models.DeletedCertificateBundle;
import com.microsoft.azure.keyvault.models.DeletedKeyBundle;
import com.microsoft.azure.keyvault.models.DeletedSecretBundle;
import com.microsoft.azure.management.resources.core.AzureTestCredentials;
import com.microsoft.azure.management.resources.core.InterceptorManager;
import com.microsoft.azure.management.resources.core.TestBase;
Expand Down Expand Up @@ -309,6 +312,60 @@ public void write(int b) {
}

}

protected static DeletedCertificateBundle pollOnCertificateDeletion(String vaultBaseUrl, String certificateName)
throws Exception {
int pendingPollCount = 0;
while (pendingPollCount < 21) {
DeletedCertificateBundle certificateBundle = keyVaultClient.getDeletedCertificate(vaultBaseUrl,
certificateName);
if (certificateBundle == null) {
if (isRecordMode()) {
Thread.sleep(10000);
}
pendingPollCount += 1;
continue;
} else {
return certificateBundle;
}
}
throw new Exception("Deleting certificate delayed");
}

protected static DeletedKeyBundle pollOnKeyDeletion(String vaultBaseUrl, String certificateName) throws Exception {
int pendingPollCount = 0;
while (pendingPollCount < 21) {
DeletedKeyBundle deletedKeyBundle = keyVaultClient.getDeletedKey(vaultBaseUrl, certificateName);
if (deletedKeyBundle == null) {
if (isRecordMode()) {
Thread.sleep(10000);
}
pendingPollCount += 1;
continue;
} else {
return deletedKeyBundle;
}
}
throw new Exception("Deleting key delayed");
}

protected static DeletedSecretBundle pollOnSecretDeletion(String vaultBaseUrl, String secretName) throws Exception {
int pendingPollCount = 0;
while (pendingPollCount < 50) {
DeletedSecretBundle deletedSecretBundle = keyVaultClient.getDeletedSecret(vaultBaseUrl, secretName);
if (deletedSecretBundle == null) {
if (isRecordMode()) {
Thread.sleep(10000);
}
pendingPollCount += 1;
continue;
} else {
return deletedSecretBundle;
}
}
throw new Exception("Deleting secret delayed");
}


@After
public void afterTest() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ public void tearDown() throws Exception {
@Test
public void KeyVault_KeyVaultKeyResolver_Key_KeyVaultKeyResolverBCProviderTest() throws InterruptedException, ExecutionException
{
String TEST_KEY_NAME = KEY_NAME + "1";
try {
// Create a key on a vault.
CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build();
CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), TEST_KEY_NAME, JsonWebKeyType.RSA).build();
KeyBundle bundle = keyVaultClient.createKey(request);

if ( bundle != null )
Expand All @@ -100,7 +101,10 @@ public void KeyVault_KeyVaultKeyResolver_Key_KeyVaultKeyResolverBCProviderTest()
finally
{
// Delete the key
keyVaultClient.deleteKey( getVaultUri(), KEY_NAME );
keyVaultClient.deleteKey( getVaultUri(), TEST_KEY_NAME );
pollOnKeyDeletion( getVaultUri(), TEST_KEY_NAME );
keyVaultClient.purgeDeletedKey( getVaultUri(), TEST_KEY_NAME);

}
}
}
Expand All @@ -121,9 +125,10 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64_KeyVaultKeyResolverBCPr
byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF };
byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 };

String TEST_SECRET_NAME = SECRET_NAME + "1";
try {

SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), TEST_SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SecretBundle secretBundle = keyVaultClient.setSecret( request );

if ( secretBundle != null )
Expand Down Expand Up @@ -162,7 +167,10 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64_KeyVaultKeyResolverBCPr
finally
{
// Delete the secret
keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME );
keyVaultClient.deleteSecret( getVaultUri(), TEST_SECRET_NAME );
pollOnSecretDeletion( getVaultUri(), TEST_SECRET_NAME );
keyVaultClient.purgeDeletedSecret( getVaultUri(), TEST_SECRET_NAME );

}
}
}
Expand All @@ -182,8 +190,9 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64_KeyVaultKeyResolverBCPr
byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF };
byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D };

String TEST_SECRET_NAME = SECRET_NAME + "2";
try {
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), TEST_SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SecretBundle secretBundle = keyVaultClient.setSecret( request );

if ( secretBundle != null )
Expand Down Expand Up @@ -223,7 +232,9 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64_KeyVaultKeyResolverBCPr
finally
{
// Delete the key
keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME );
keyVaultClient.deleteSecret( getVaultUri(), TEST_SECRET_NAME );
pollOnSecretDeletion( getVaultUri(), TEST_SECRET_NAME );
keyVaultClient.purgeDeletedSecret( getVaultUri(), TEST_SECRET_NAME);
}
}
} catch (Exception ex) {
Expand All @@ -242,8 +253,10 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64_KeyVaultKeyResolverBCPr
byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF };
byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 };

String TEST_SECRET_NAME = SECRET_NAME + "3";

try {
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), TEST_SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SecretBundle secretBundle = keyVaultClient.setSecret( request );

if ( secretBundle != null )
Expand Down Expand Up @@ -283,7 +296,9 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64_KeyVaultKeyResolverBCPr
finally
{
// Delete the key
keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME );
keyVaultClient.deleteSecret( getVaultUri(), TEST_SECRET_NAME );
pollOnSecretDeletion( getVaultUri(), TEST_SECRET_NAME );
keyVaultClient.purgeDeletedSecret( getVaultUri(), TEST_SECRET_NAME );
}
}
} catch ( Exception ex ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ public void tearDown() throws Exception {
@Test
public void KeyVault_KeyVaultKeyResolver_Key_KeyVaultKeyResolverDefaultProviderTest() throws InterruptedException, ExecutionException
{
String TEST_KEY_NAME = KEY_NAME + "1";
try {
// Create a key on a vault.
CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build();
CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), TEST_KEY_NAME, JsonWebKeyType.RSA).build();
KeyBundle keyBundle = keyVaultClient.createKey(request);

try
Expand All @@ -96,7 +97,9 @@ public void KeyVault_KeyVaultKeyResolver_Key_KeyVaultKeyResolverDefaultProviderT
finally
{
// Delete the key
keyVaultClient.deleteKey( getVaultUri(), KEY_NAME );
keyVaultClient.deleteKey( getVaultUri(), TEST_KEY_NAME );
pollOnKeyDeletion( getVaultUri(), TEST_KEY_NAME );
keyVaultClient.purgeDeletedKey( getVaultUri(), TEST_KEY_NAME );
}
} catch(Exception ex) {
fail(ex.getMessage());
Expand All @@ -114,8 +117,10 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64_KeyVaultKeyResolverDefa
byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF };
byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 };

String TEST_SECRET_NAME = SECRET_NAME + "1";

try {
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), TEST_SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SecretBundle secretBundle = keyVaultClient.setSecret(request);

if ( secretBundle != null )
Expand Down Expand Up @@ -155,7 +160,9 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64_KeyVaultKeyResolverDefa
finally
{
// Delete the key
keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME );
keyVaultClient.deleteSecret( getVaultUri(), TEST_SECRET_NAME );
pollOnSecretDeletion( getVaultUri(), TEST_SECRET_NAME );
keyVaultClient.purgeDeletedSecret( getVaultUri(), TEST_SECRET_NAME );
}
}
} catch ( Exception ex ) {
Expand All @@ -174,8 +181,10 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64_KeyVaultKeyResolverDefa
byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF };
byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D };

String TEST_SECRET_NAME = SECRET_NAME + "2";

try {
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), TEST_SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SecretBundle secretBundle = keyVaultClient.setSecret( request );

if ( secretBundle != null )
Expand Down Expand Up @@ -228,7 +237,9 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64_KeyVaultKeyResolverDefa
finally
{
// Delete the key
keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME );
keyVaultClient.deleteSecret( getVaultUri(), TEST_SECRET_NAME );
pollOnSecretDeletion( getVaultUri(), TEST_SECRET_NAME );
keyVaultClient.purgeDeletedSecret( getVaultUri(), TEST_SECRET_NAME );
}
}
} catch ( Exception ex ) {
Expand All @@ -247,8 +258,10 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64_KeyVaultKeyResolverDefa
byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF };
byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 };

String TEST_SECRET_NAME = SECRET_NAME + "3";

try {
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), TEST_SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build();
SecretBundle secretBundle = keyVaultClient.setSecret( request );

if ( secretBundle != null )
Expand Down Expand Up @@ -307,7 +320,9 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64_KeyVaultKeyResolverDefa
finally
{
// Delete the key
keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME );
keyVaultClient.deleteSecret( getVaultUri(), TEST_SECRET_NAME );
pollOnSecretDeletion( getVaultUri(), TEST_SECRET_NAME );
keyVaultClient.purgeDeletedSecret( getVaultUri(), TEST_SECRET_NAME );
}
}
} catch ( Exception ex ) {
Expand Down
Loading

0 comments on commit ea80c2b

Please sign in to comment.