Selaa lähdekoodia

Fix the integration test

Herman Slatman 2 vuotta sitten
vanhempi
sitoutus
85309bb8ec
4 muutettua tiedostoa jossa 22 lisäystä ja 14 poistoa
  1. 8 6
      acme/api/account_test.go
  2. 14 5
      acme/api/im_integration_test.go
  3. 0 1
      go.mod
  4. 0 2
      go.sum

+ 8 - 6
acme/api/account_test.go

@@ -24,12 +24,14 @@ import (
 )
 
 var (
-	defaultDisableRenewal   = false
-	globalProvisionerClaims = provisioner.Claims{
-		MinTLSDur:      &provisioner.Duration{Duration: 5 * time.Minute},
-		MaxTLSDur:      &provisioner.Duration{Duration: 24 * time.Hour},
-		DefaultTLSDur:  &provisioner.Duration{Duration: 24 * time.Hour},
-		DisableRenewal: &defaultDisableRenewal,
+	defaultDisableRenewal             = false
+	defaultDisableSmallstepExtensions = false
+	globalProvisionerClaims           = provisioner.Claims{
+		MinTLSDur:                  &provisioner.Duration{Duration: 5 * time.Minute},
+		MaxTLSDur:                  &provisioner.Duration{Duration: 24 * time.Hour},
+		DefaultTLSDur:              &provisioner.Duration{Duration: 24 * time.Hour},
+		DisableRenewal:             &defaultDisableRenewal,
+		DisableSmallstepExtensions: &defaultDisableSmallstepExtensions,
 	}
 )
 

+ 14 - 5
acme/api/im_integration_test.go

@@ -7,6 +7,7 @@ import (
 	"crypto/rand"
 	"crypto/x509"
 	"crypto/x509/pkix"
+	"encoding/asn1"
 	"encoding/base64"
 	"encoding/json"
 	"errors"
@@ -20,7 +21,7 @@ import (
 	"testing"
 	"time"
 
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 	"github.com/smallstep/certificates/acme"
 	"github.com/smallstep/certificates/acme/db/nosql"
 	"github.com/smallstep/certificates/authority"
@@ -37,8 +38,7 @@ const (
 func TestIMIntegration(t *testing.T) {
 	ctx := context.Background()
 
-	// mock provisioner and linker
-	ctx = acme.NewProvisionerContext(ctx, newProvWithOptions(&provisioner.Options{
+	prov := newACMEProvWithOptions(t, &provisioner.Options{
 		OIDC: &provisioner.OIDCOptions{
 			Provider: provisioner.ProviderJSON{
 				IssuerURL:   "",
@@ -61,7 +61,10 @@ func TestIMIntegration(t *testing.T) {
 		DPOP: &provisioner.DPOPOptions{
 			ValidationExecPath: "true", // true will always exit with code 0
 		},
-	}))
+	})
+
+	// mock provisioner and linker
+	ctx = acme.NewProvisionerContext(ctx, prov)
 	ctx = acme.NewLinkerContext(ctx, acme.NewLinker(baseURL, linkerPrefix))
 
 	// create temporary BoltDB file
@@ -395,7 +398,12 @@ func TestIMIntegration(t *testing.T) {
 		csrTemplate := &x509.CertificateRequest{
 			Subject: pkix.Name{
 				Organization: []string{"example.com"},
-				CommonName:   "Smith, Alice M (QA)",
+				ExtraNames: []pkix.AttributeTypeAndValue{
+					{
+						Type:  asn1.ObjectIdentifier{2, 16, 840, 1, 113730, 3, 1, 241},
+						Value: "Smith, Alice M (QA)",
+					},
+				},
 			},
 			URIs: []*url.URL{
 				qUserName,
@@ -403,6 +411,7 @@ func TestIMIntegration(t *testing.T) {
 			},
 			SignatureAlgorithm: x509.PureEd25519,
 		}
+
 		csr, err := x509.CreateCertificateRequest(rand.Reader, csrTemplate, priv)
 		if err != nil {
 			t.Fatal("create CSR from template:", err)

+ 0 - 1
go.mod

@@ -10,7 +10,6 @@ require (
 	github.com/dgraph-io/badger v1.6.2
 	github.com/dgraph-io/badger/v2 v2.2007.4
 	github.com/fxamacker/cbor/v2 v2.5.0
-	github.com/go-chi/chi v1.5.5
 	github.com/go-chi/chi/v5 v5.0.11
 	github.com/go-jose/go-jose/v3 v3.0.1
 	github.com/golang/mock v1.6.0

+ 0 - 2
go.sum

@@ -182,8 +182,6 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
 github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE=
 github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
 github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
-github.com/go-chi/chi v1.5.5 h1:vOB/HbEMt9QqBqErz07QehcOKHaWFtuj87tTDVz2qXE=
-github.com/go-chi/chi v1.5.5/go.mod h1:C9JqLr3tIYjDOZpzn+BCuxY8z8vmca43EeMgyZt7irw=
 github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA=
 github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
 github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=