Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 1654907

Browse files
authored
Merge pull request #110 from Venafi/contacts-support
Fixed Policy test cases
2 parents 889876f + 6a8d71e commit 1654907

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

src/test/java/com/venafi/vcert/sdk/connectors/cloud/CloudConnectorPolicyAT.java

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.venafi.vcert.sdk.connectors.cloud;
22

3-
import static org.junit.Assert.assertEquals;
4-
53
import com.venafi.vcert.sdk.Config;
64
import com.venafi.vcert.sdk.connectors.cloud.domain.User;
75
import com.venafi.vcert.sdk.connectors.cloud.domain.UserResponse;
@@ -38,13 +36,18 @@ public void createAndGetPolicy() throws VCertException {
3836

3937
PolicySpecification policySpecificationReturned = connector.getPolicy(policyName);
4038

41-
//The returned policySpecification will have the policy's name so it will copied to the source policySpecification
42-
//due it doesn't contain it
39+
//The returned policySpecification will contain the policy's name, which is not part of the source policy spec
40+
//Adding the name to the source policy spec in order to assert both objects.
4341
policySpecification.name(policySpecificationReturned.name());
44-
//The returned policySpecification will contains the default cloud CA, then it will needed
45-
//to set it to the policySpecification source
42+
43+
// The returned policySpecification will contain the default cloud CA, which is omitted in the source policy spec
44+
// Adding the default CA to the source policy spec in order to assert both objects.
4645
policySpecification.policy().certificateAuthority(VCertConstants.CLOUD_DEFAULT_CA);
47-
46+
47+
//The returned policy specification will contain a single user, which is the one who created the policy
48+
//on the first place. Adding this user to the source policy spec in order to assert both objects.
49+
policySpecification.users(new String[]{"jenkins@opensource.qa.venafi.io"});
50+
4851
Assertions.assertEquals(policySpecification, policySpecificationReturned);
4952
}
5053

@@ -62,11 +65,15 @@ public void createAndGetPolicyForDigicert() throws VCertException {
6265
connector.setPolicy(policyName, policySpecification);
6366

6467
PolicySpecification policySpecificationReturned = connector.getPolicy(policyName);
65-
66-
//The returned policySpecification will have the policy's name so it will copied to the source policySpecification
67-
//due it doesn't contain it
68+
69+
//The returned policySpecification will contain the policy's name, which is not part of the source policy spec
70+
//Adding the name to the source policy spec in order to assert both objects.
6871
policySpecification.name(policySpecificationReturned.name());
69-
72+
73+
//The returned policy specification will contain a single user, which is the one who created the policy
74+
//on the first place. Adding this user to the source policy spec in order to assert both objects.
75+
policySpecification.users(new String[]{"jenkins@opensource.qa.venafi.io"});
76+
7077
Assertions.assertEquals(policySpecification, policySpecificationReturned);
7178
}
7279

@@ -84,17 +91,21 @@ public void createAndGetPolicyForEntrust() throws VCertException {
8491
connector.setPolicy(policyName, policySpecification);
8592

8693
PolicySpecification policySpecificationReturned = connector.getPolicy(policyName);
87-
88-
//The returned policySpecification will have the policy's name so it will copied to the source policySpecification
89-
//due it doesn't contain it
94+
95+
//The returned policySpecification will contain the policy's name, which is not part of the source policy spec
96+
//Adding the name to the source policy spec in order to assert both objects.
9097
policySpecification.name(policySpecificationReturned.name());
91-
92-
assertEquals(policySpecification, policySpecificationReturned);
98+
99+
//The returned policy specification will contain a single user, which is the one who created the policy
100+
//on the first place. Adding this user to the source policy spec in order to assert both objects.
101+
policySpecification.users(new String[]{"jenkins@opensource.qa.venafi.io"});
102+
103+
Assertions.assertEquals(policySpecification, policySpecificationReturned);
93104
}
94105

95106
@Test
96107
@DisplayName("Cloud - Testing the userByName endpoint")
97-
public void getUserByName() throws VCertException{
108+
public void getUserByName() {
98109
Config config = null;
99110
Cloud cloud = Cloud.connect(config);
100111

src/test/java/com/venafi/vcert/sdk/connectors/cloud/CloudTestUtils.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66

77
public class CloudTestUtils {
88

9-
public static final String APP_NAME = String.format("VCert-Java-%d-%s", System.currentTimeMillis(), RandomStringUtils.randomAlphabetic(4));
9+
// public static final String APP_NAME = String.format("VCert-Java-%d-%s", System.currentTimeMillis(), RandomStringUtils.randomAlphabetic(4));
1010

1111
public static String getRandomZone() {
12-
return APP_NAME+"\\"+TestUtils.randomCITName();
12+
return getRandomAppName()+"\\"+TestUtils.randomCITName();
13+
}
14+
15+
public static String getRandomAppName(){
16+
return String.format("VCert-Java-%d-%s", System.currentTimeMillis(), RandomStringUtils.randomAlphabetic(4));
1317
}
1418

1519
public static PolicySpecification getPolicySpecification() {

0 commit comments

Comments
 (0)