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

Commit 6a8d71e

Browse files
committed
Fixed Policy test cases
Changed the application name generation from a static value to a dynamic one in order to properly test policy users feature
1 parent 0376642 commit 6a8d71e

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

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

Lines changed: 16 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,15 +36,16 @@ 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);
4746

4847
//The returned policy specification will contain a single user, which is the one who created the policy
49-
//on the first place. We add this user to the source policy spec in order to assert.
48+
//on the first place. Adding this user to the source policy spec in order to assert both objects.
5049
policySpecification.users(new String[]{"jenkins@opensource.qa.venafi.io"});
5150

5251
Assertions.assertEquals(policySpecification, policySpecificationReturned);
@@ -66,13 +65,13 @@ public void createAndGetPolicyForDigicert() throws VCertException {
6665
connector.setPolicy(policyName, policySpecification);
6766

6867
PolicySpecification policySpecificationReturned = connector.getPolicy(policyName);
69-
70-
//The returned policySpecification will have the policy's name so it will copied to the source policySpecification
71-
//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.
7271
policySpecification.name(policySpecificationReturned.name());
7372

7473
//The returned policy specification will contain a single user, which is the one who created the policy
75-
//on the first place. We add this user to the source policy spec in order to assert.
74+
//on the first place. Adding this user to the source policy spec in order to assert both objects.
7675
policySpecification.users(new String[]{"jenkins@opensource.qa.venafi.io"});
7776

7877
Assertions.assertEquals(policySpecification, policySpecificationReturned);
@@ -92,21 +91,21 @@ public void createAndGetPolicyForEntrust() throws VCertException {
9291
connector.setPolicy(policyName, policySpecification);
9392

9493
PolicySpecification policySpecificationReturned = connector.getPolicy(policyName);
95-
96-
//The returned policySpecification will have the policy's name so it will copied to the source policySpecification
97-
//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.
9897
policySpecification.name(policySpecificationReturned.name());
9998

10099
//The returned policy specification will contain a single user, which is the one who created the policy
101-
//on the first place. We add this user to the source policy spec in order to assert.
100+
//on the first place. Adding this user to the source policy spec in order to assert both objects.
102101
policySpecification.users(new String[]{"jenkins@opensource.qa.venafi.io"});
103102

104-
assertEquals(policySpecification, policySpecificationReturned);
103+
Assertions.assertEquals(policySpecification, policySpecificationReturned);
105104
}
106105

107106
@Test
108107
@DisplayName("Cloud - Testing the userByName endpoint")
109-
public void getUserByName() throws VCertException{
108+
public void getUserByName() {
110109
Config config = null;
111110
Cloud cloud = Cloud.connect(config);
112111

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)