Skip to content

Commit 594fe6a

Browse files
Merge pull request #539 from Venafi/fixes-test-pipeline-issue-tpp
Fixes test pipeline issue tpp
2 parents 5e219b3 + 7db073f commit 594fe6a

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

pkg/venafi/tpp/connector_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,6 @@ func TestRenewCertRestoringValues(t *testing.T) {
18141814
req.KeyType = certificate.KeyTypeECDSA
18151815
req.KeyCurve = certificate.EllipticCurveP521
18161816
req.CsrOrigin = certificate.ServiceGeneratedCSR
1817-
req.Timeout = time.Second * 10
18181817
err = tpp.GenerateRequest(&endpoint.ZoneConfiguration{}, req)
18191818
if err != nil {
18201819
t.Fatalf("err is not nil, err: %s", err)
@@ -1828,6 +1827,11 @@ func TestRenewCertRestoringValues(t *testing.T) {
18281827
req.FetchPrivateKey = true
18291828
req.KeyPassword = os.Getenv("TPP_PASSWORD")
18301829

1830+
req.Timeout = time.Second * 30 // explicitly setting this value here
1831+
// to make sure we only wait for certificate issuance for 30 seconds because
1832+
// setting it before the RequestCertificate function, will override
1833+
// workToDoTimeout to only wait to 30 seconds
1834+
18311835
pcc, err := tpp.RetrieveCertificate(req)
18321836
if err != nil {
18331837
t.Fatal(err)
@@ -1847,11 +1851,11 @@ func TestRenewCertRestoringValues(t *testing.T) {
18471851
renewReq := certificate.RenewalRequest{
18481852
CertificateDN: req.PickupID,
18491853
}
1850-
pickupdID, err := tpp.RenewCertificate(&renewReq)
1854+
pickupID, err := tpp.RenewCertificate(&renewReq)
18511855
if err != nil {
18521856
t.Fatal(err)
18531857
}
1854-
req = &certificate.Request{PickupID: pickupdID, Timeout: 30 * time.Second}
1858+
req = &certificate.Request{PickupID: pickupID, Timeout: 30 * time.Second}
18551859
pcc, err = tpp.RetrieveCertificate(req)
18561860
if err != nil {
18571861
t.Fatal(err)
@@ -2288,7 +2292,6 @@ func TestEnrollWithLocation(t *testing.T) {
22882292

22892293
req := certificate.Request{}
22902294
req.Subject.CommonName = cn
2291-
req.Timeout = time.Second * 10
22922295
req.Location = &certificate.Location{
22932296
Instance: "instance",
22942297
Workload: workload,
@@ -2305,7 +2308,6 @@ func TestEnrollWithLocation(t *testing.T) {
23052308
}
23062309
req = certificate.Request{}
23072310
req.Subject.CommonName = cn
2308-
req.Timeout = time.Second * 10
23092311
req.Location = &certificate.Location{
23102312
Instance: "instance",
23112313
Workload: workload,
@@ -2322,7 +2324,6 @@ func TestEnrollWithLocation(t *testing.T) {
23222324
}
23232325
req = certificate.Request{}
23242326
req.Subject.CommonName = cn
2325-
req.Timeout = time.Second * 10
23262327
req.Location = &certificate.Location{
23272328
Instance: "instance",
23282329
Workload: workload,
@@ -2862,6 +2863,9 @@ func TestSetPolicyValuesAndValidate(t *testing.T) {
28622863
func TestCreateSshCertServiceGeneratedKP(t *testing.T) {
28632864

28642865
tpp, err := getTestConnector(ctx.TPPurl, ctx.TPPZone)
2866+
if err != nil {
2867+
t.Fatalf("err is not nil, err: %s", err)
2868+
}
28652869

28662870
duration := 4
28672871

@@ -2880,7 +2884,6 @@ func TestCreateSshCertServiceGeneratedKP(t *testing.T) {
28802884
req.ValidityPeriod = fmt.Sprint(duration, "h")
28812885
req.Template = os.Getenv("TPP_SSH_CA")
28822886
req.SourceAddresses = []string{"test.com"}
2883-
req.Timeout = time.Second * 10
28842887

28852888
respData, err := tpp.RequestSSHCertificate(req)
28862889

@@ -2928,6 +2931,10 @@ func TestCreateSshCertLocalGeneratedKP(t *testing.T) {
29282931

29292932
tpp, err := getTestConnector(ctx.TPPurl, ctx.TPPZone)
29302933

2934+
if err != nil {
2935+
t.Fatalf("err is not nil, err: %s", err)
2936+
}
2937+
29312938
duration := 4
29322939

29332940
tpp.verbose = true
@@ -2959,7 +2966,6 @@ func TestCreateSshCertLocalGeneratedKP(t *testing.T) {
29592966
req.ValidityPeriod = fmt.Sprint(duration, "h")
29602967
req.Template = os.Getenv("TPP_SSH_CA")
29612968
req.SourceAddresses = []string{"test.com"}
2962-
req.Timeout = time.Second * 10
29632969

29642970
sPubKey := string(pub)
29652971

pkg/venafi/tpp/sshCertUtils.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ func RequestSshCertificate(c *Connector, req *certificate.SshCertRequest) (*cert
4646
}
4747

4848
//TODO: Maybe, there is a better way to set the timeout.
49-
c.client.Timeout = time.Duration(req.Timeout) * time.Second
49+
if req.Timeout > 0 {
50+
c.client.Timeout = req.Timeout * time.Second
51+
}
5052
statusCode, status, body, err := c.request("POST", urlResourceSshCertReq, sshCertReq)
5153
if err != nil {
5254
return nil, err

0 commit comments

Comments
 (0)