-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from Venafi/VCertTknClient_readZoneConfigurat…
…ion_issue_115 Fix for VCertTknClient read zone configuration issue #115
- Loading branch information
Showing
15 changed files
with
535 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...cert/sdk/connectors/tpp/TppTestUtils.java → .../venafi/vcert/sdk/utils/TppTestUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.venafi.vcert.sdk.connectors.tpp; | ||
package com.venafi.vcert.sdk.utils; | ||
|
||
import java.time.Instant; | ||
|
||
|
87 changes: 87 additions & 0 deletions
87
src/test/java/com/venafi/vcert/sdk/vcertTknClient/VCertTknClientAT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.venafi.vcert.sdk.vcertTknClient; | ||
|
||
import static com.venafi.vcert.sdk.TestUtils.getTestIps; | ||
import static java.lang.String.format; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatCode; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import java.io.IOException; | ||
import java.io.StringReader; | ||
import java.net.InetAddress; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
|
||
import org.bouncycastle.openssl.PEMParser; | ||
import org.bouncycastle.pkcs.PKCS10CertificationRequest; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.venafi.vcert.sdk.TestUtils; | ||
import com.venafi.vcert.sdk.VCertException; | ||
import com.venafi.vcert.sdk.certificate.CertificateRequest; | ||
import com.venafi.vcert.sdk.certificate.KeyType; | ||
import com.venafi.vcert.sdk.connectors.ZoneConfiguration; | ||
|
||
import feign.FeignException; | ||
|
||
class VCertTknClientAT { | ||
|
||
@RegisterExtension | ||
public static final VCertTknClientResource clientResource = new VCertTknClientResource(); | ||
|
||
@Test | ||
void readZoneConfiguration() throws VCertException { | ||
try { | ||
clientResource.client().readZoneConfiguration(TestUtils.TPP_ZONE); | ||
} catch (FeignException fe) { | ||
throw VCertException.fromFeignException(fe); | ||
} | ||
} | ||
|
||
@Test | ||
void readZoneConfigurationInLongFormat() throws VCertException { | ||
try { | ||
clientResource.client().readZoneConfiguration("\\VED\\Policy\\"+TestUtils.TPP_ZONE); | ||
} catch (FeignException fe) { | ||
throw VCertException.fromFeignException(fe); | ||
} | ||
} | ||
|
||
@Test | ||
void ping() throws VCertException { | ||
assertThatCode(() -> clientResource.client().ping()).doesNotThrowAnyException(); | ||
} | ||
|
||
@Test | ||
void generateRequest() throws VCertException, IOException { | ||
String commonName = TestUtils.randomCN(); | ||
ZoneConfiguration zoneConfiguration = clientResource.client().readZoneConfiguration(TestUtils.TPP_ZONE); | ||
CertificateRequest certificateRequest = new CertificateRequest() | ||
.subject(new CertificateRequest.PKIXName().commonName(commonName) | ||
.organization(Collections.singletonList("Venafi, Inc.")) | ||
.organizationalUnit(Arrays.asList("Engineering", "Automated Tests")) | ||
.country(Collections.singletonList("US")).locality(Collections.singletonList("SLC")) | ||
.province(Collections.singletonList("Utah"))) | ||
.dnsNames(Collections.singletonList(InetAddress.getLocalHost().getHostName())) | ||
.ipAddresses(getTestIps()).keyType(KeyType.RSA).keyLength(2048); | ||
|
||
certificateRequest = clientResource.client().generateRequest(zoneConfiguration, certificateRequest); | ||
|
||
assertThat(certificateRequest.csr()).isNotEmpty(); | ||
|
||
PKCS10CertificationRequest request = (PKCS10CertificationRequest) new PEMParser( | ||
new StringReader(new String(certificateRequest.csr()))).readObject(); | ||
|
||
// Values overridden by policy which is why they don't match the above values | ||
String subject = request.getSubject().toString(); | ||
|
||
assertThat(subject).contains(format("CN=%s", commonName)); | ||
} | ||
|
||
@Test | ||
void readPolicyConfiguration() { | ||
assertThrows(UnsupportedOperationException.class, | ||
() -> clientResource.client().readPolicyConfiguration("zone")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.