Skip to content

Commit

Permalink
fix: VCertTknClient SDK methods are working again
Browse files Browse the repository at this point in the history
The VCertTknClient SDK methods left to work since the releases v.0.9.0
until v0.9.2 given a mistake which caused the endpoints used in the
background were the specific endpoints declared for the VCertClient.

Also it was created a bunch of tests to test the VCertTknClient SDK
methods in order to confirm they are working correctly.

Resolves: #115
  • Loading branch information
marcos-albornoz committed Sep 1, 2022
1 parent f12fc7e commit bafc48a
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/venafi/vcert/sdk/VCertTknClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.venafi.vcert.sdk.connectors.Connector;
import com.venafi.vcert.sdk.connectors.TokenConnector;
import com.venafi.vcert.sdk.connectors.tpp.TokenInfo;
import com.venafi.vcert.sdk.connectors.tpp.Tpp;
import com.venafi.vcert.sdk.connectors.tpp.TppToken;
import com.venafi.vcert.sdk.connectors.tpp.TppTokenConnector;
import com.venafi.vcert.sdk.endpoint.Authentication;

Expand All @@ -22,7 +22,7 @@ protected Connector createConnector(Config config) throws VCertException {
Connector connector;
switch (config.connectorType()) {
case TPP_TOKEN:{
connector = new TppTokenConnector(Tpp.connect(config));
connector = new TppTokenConnector(TppToken.connect(config));
break;
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ public static class ApiClientInformation{
public static class CsrAttributes {
private String commonName;
private String organization;
private String[] organizationalUnits;
//private String[] organizationalUnits;
private String locality;
private String state;
private String country;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public static CsrAttributes buildCsrAttributes(CertificateRequest request, Polic
}

//computing the organizational Units
List<String> reqOrgUnits = Optional.ofNullable(request).map(req -> req.subject()).map(s -> s.organizationalUnit()).orElse(null);
/*List<String> reqOrgUnits = Optional.ofNullable(request).map(req -> req.subject()).map(s -> s.organizationalUnit()).orElse(null);
if( reqOrgUnits!=null && reqOrgUnits.size() > 0) {
String[] reqOrgUnitsArray = reqOrgUnits.toArray(new String[0]);
Expand All @@ -405,7 +405,7 @@ public static CsrAttributes buildCsrAttributes(CertificateRequest request, Polic
if(defaultOrgUnits!=null && defaultOrgUnits.length>0)
csrAttributes.organizationalUnits(defaultOrgUnits);
}
}*/

//computing the localities
List<String> reqLocalities = Optional.ofNullable(request).map(req -> req.subject()).map(s -> s.locality()).orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public ZoneConfiguration readZoneConfiguration(String zone) throws VCertExceptio
Policy policy = serverPolicy.toPolicy();
ZoneConfiguration zoneConfig = serverPolicy.toZoneConfig();
zoneConfig.policy(policy);
zoneConfig.zoneId(zone);
zoneConfig.zoneId(getPolicyDN(zone));
return zoneConfig;
}

Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/venafi/vcert/sdk/VCertTknClientTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.venafi.vcert.sdk;

import com.venafi.vcert.sdk.Config;
import com.venafi.vcert.sdk.VCertException;
import com.venafi.vcert.sdk.VCertTknClient;
import com.venafi.vcert.sdk.certificate.CertificateRequest;
import com.venafi.vcert.sdk.certificate.ImportRequest;
import com.venafi.vcert.sdk.certificate.RenewalRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.venafi.vcert.sdk.certificate.SshCertificateRequest;
import com.venafi.vcert.sdk.certificate.SshConfig;
import com.venafi.vcert.sdk.endpoint.Authentication;
import com.venafi.vcert.sdk.utils.TppTestUtils;

class TppConnectorATForSSH {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.venafi.vcert.sdk.connectors.ZoneConfiguration;
import com.venafi.vcert.sdk.endpoint.Authentication;
import com.venafi.vcert.sdk.policy.domain.PolicySpecification;
import com.venafi.vcert.sdk.utils.TppTestUtils;

import feign.FeignException;
import feign.FeignException.BadRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.venafi.vcert.sdk.certificate.SshCertificateRequest;
import com.venafi.vcert.sdk.certificate.SshConfig;
import com.venafi.vcert.sdk.endpoint.Authentication;
import com.venafi.vcert.sdk.utils.TppTestUtils;

class TppTokenConnectorATForSSH {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.venafi.vcert.sdk.connectors.tpp.endpoint.ValidateIdentityRequest;
import com.venafi.vcert.sdk.connectors.tpp.endpoint.ValidateIdentityResponse;
import com.venafi.vcert.sdk.policy.domain.PolicySpecification;
import com.venafi.vcert.sdk.utils.TppTestUtils;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.venafi.vcert.sdk.policy.converter.tpp.TPPPolicySpecificationValidator;
import com.venafi.vcert.sdk.policy.domain.PolicySpecification;
import com.venafi.vcert.sdk.policy.domain.PolicySpecificationConst;
import com.venafi.vcert.sdk.utils.TppTestUtils;

import feign.FeignException;
import feign.Request;
import feign.Response;
Expand Down
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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package com.venafi.vcert.sdk;
package com.venafi.vcert.sdk.vcertTknClient;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
Expand All @@ -12,6 +12,10 @@

import org.junit.jupiter.api.Test;

import com.venafi.vcert.sdk.Config;
import com.venafi.vcert.sdk.TestUtils;
import com.venafi.vcert.sdk.VCertException;
import com.venafi.vcert.sdk.VCertTknClient;
import com.venafi.vcert.sdk.connectors.ConnectorException.MissingCredentialsException;
import com.venafi.vcert.sdk.connectors.tpp.TokenInfo;
import com.venafi.vcert.sdk.endpoint.Authentication;
Expand Down

0 comments on commit bafc48a

Please sign in to comment.