Skip to content

Commit

Permalink
Merge pull request Azure#44 from tiffanyachen/dev
Browse files Browse the repository at this point in the history
Added msak tests
  • Loading branch information
tiffanyachen authored Jun 5, 2018
2 parents ec38edb + 516df2f commit 0661add
Show file tree
Hide file tree
Showing 9 changed files with 1,434 additions and 3 deletions.
1 change: 1 addition & 0 deletions azure-keyvault/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
21 changes: 18 additions & 3 deletions azure-keyvault/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
the MIT License. See License.txt in the project root for license information. -->
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
the MIT License. See License.txt in the project root for license information. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -91,6 +91,12 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-mgmt-keyvault</artifactId>
<version>1.11.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-mgmt-resources</artifactId>
Expand All @@ -107,7 +113,16 @@
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.54</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -162,4 +177,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"roleDefUUID":"61927a2e-1dd1-4ae2-8ad1-e53fdf3ae32d","storageAccountName":"sa7333192560","vaultName":"vaultf9c58684e"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"roleDefUUID":"0c337b82-553c-4aaf-aa62-eab5dc446bb3","storageAccountName":"sa2c77808410","vaultName":"vault669612016"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package resources;

import java.io.IOException;
import java.util.Date;

import com.microsoft.azure.AzureEnvironment;
import com.microsoft.azure.credentials.UserTokenCredentials;
import com.microsoft.aad.adal4j.AuthenticationResult;



public class MockUserTokenCredentials extends UserTokenCredentials {

private AuthenticationResult authenticationResult;


public MockUserTokenCredentials(String clientId, String domain, String username, String password,
AzureEnvironment environment) {
super(clientId, domain, username, password, environment);
}

public MockUserTokenCredentials() {
this("","","","", AzureEnvironment.AZURE);
}
@Override
public String getToken(String resource) throws IOException {
if (authenticationResult != null
&& authenticationResult.getExpiresOnDate().before(new Date())) {
acquireAccessTokenFromRefreshToken();
} else {
acquireAccessToken();
}
return authenticationResult.getAccessToken();
}

private void acquireAccessToken() throws IOException {
this.authenticationResult = new AuthenticationResult(
null,
"token1",
"refresh",
1,
null,
null,
false);
}

private void acquireAccessTokenFromRefreshToken() throws IOException {
this.authenticationResult = new AuthenticationResult(
null,
"token2",
"refresh",
1,
null,
null,
false);
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@

<dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.microsoft.azure/azure-mgmt-keyvault -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-mgmt-keyvault</artifactId>
<version>1.11.1</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down

0 comments on commit 0661add

Please sign in to comment.