mirror of
https://github.com/outbackdingo/certificates.git
synced 2026-01-27 10:18:34 +00:00
Merge pull request #1511 from smallstep/fix-cbor-error
Fix error string in tests
This commit is contained in:
@@ -3444,7 +3444,7 @@ func Test_deviceAttest01Validate(t *testing.T) {
|
||||
},
|
||||
payload: errorCBORPayload,
|
||||
},
|
||||
wantErr: NewErrorISE("error unmarshalling CBOR: cbor: cannot unmarshal positive integer into Go value of type acme.attestationObject"),
|
||||
wantErr: NewErrorISE("error unmarshalling CBOR: cbor:"),
|
||||
}
|
||||
},
|
||||
"ok/prov.IsAttestationFormatEnabled": func(t *testing.T) test {
|
||||
@@ -4003,8 +4003,9 @@ func Test_deviceAttest01Validate(t *testing.T) {
|
||||
tc := run(t)
|
||||
|
||||
if err := deviceAttest01Validate(tc.args.ctx, tc.args.ch, tc.args.db, tc.args.jwk, tc.args.payload); err != nil {
|
||||
assert.Error(t, tc.wantErr)
|
||||
assert.EqualError(t, err, tc.wantErr.Error())
|
||||
if assert.Error(t, tc.wantErr) {
|
||||
assert.ErrorContains(t, err, tc.wantErr.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,13 @@ func generateOTT(subject string) string {
|
||||
return raw
|
||||
}
|
||||
|
||||
func startTestServer(tlsConfig *tls.Config, handler http.Handler) *httptest.Server {
|
||||
func startTestServer(baseContext context.Context, tlsConfig *tls.Config, handler http.Handler) *httptest.Server {
|
||||
srv := httptest.NewUnstartedServer(handler)
|
||||
srv.TLS = tlsConfig
|
||||
// Base context MUST be set before the start of the server
|
||||
srv.Config.BaseContext = func(l net.Listener) context.Context {
|
||||
return baseContext
|
||||
}
|
||||
srv.StartTLS()
|
||||
// Force the use of GetCertificate on IPs
|
||||
srv.TLS.Certificates = nil
|
||||
@@ -78,11 +82,8 @@ func startCATestServer() *httptest.Server {
|
||||
panic(err)
|
||||
}
|
||||
// Use a httptest.Server instead
|
||||
srv := startTestServer(ca.srv.TLSConfig, ca.srv.Handler)
|
||||
baseContext := buildContext(ca.auth, nil, nil, nil)
|
||||
srv.Config.BaseContext = func(net.Listener) context.Context {
|
||||
return baseContext
|
||||
}
|
||||
srv := startTestServer(baseContext, ca.srv.TLSConfig, ca.srv.Handler)
|
||||
return srv
|
||||
}
|
||||
|
||||
@@ -153,7 +154,7 @@ func TestClient_GetServerTLSConfig_http(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Client.GetServerTLSConfig() error = %v", err)
|
||||
}
|
||||
srvMTLS := startTestServer(tlsConfig, serverHandler(t, clientDomain))
|
||||
srvMTLS := startTestServer(context.Background(), tlsConfig, serverHandler(t, clientDomain))
|
||||
defer srvMTLS.Close()
|
||||
|
||||
// Create TLS server
|
||||
@@ -163,7 +164,7 @@ func TestClient_GetServerTLSConfig_http(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Client.GetServerTLSConfig() error = %v", err)
|
||||
}
|
||||
srvTLS := startTestServer(tlsConfig, serverHandler(t, clientDomain))
|
||||
srvTLS := startTestServer(context.Background(), tlsConfig, serverHandler(t, clientDomain))
|
||||
defer srvTLS.Close()
|
||||
|
||||
tests := []struct {
|
||||
@@ -258,7 +259,7 @@ func TestClient_GetServerTLSConfig_renew(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Client.GetServerTLSConfig() error = %v", err)
|
||||
}
|
||||
srvMTLS := startTestServer(tlsConfig, serverHandler(t, clientDomain))
|
||||
srvMTLS := startTestServer(context.Background(), tlsConfig, serverHandler(t, clientDomain))
|
||||
defer srvMTLS.Close()
|
||||
|
||||
// Start TLS server
|
||||
@@ -268,7 +269,7 @@ func TestClient_GetServerTLSConfig_renew(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Client.GetServerTLSConfig() error = %v", err)
|
||||
}
|
||||
srvTLS := startTestServer(tlsConfig, serverHandler(t, clientDomain))
|
||||
srvTLS := startTestServer(context.Background(), tlsConfig, serverHandler(t, clientDomain))
|
||||
defer srvTLS.Close()
|
||||
|
||||
// Transport
|
||||
|
||||
Reference in New Issue
Block a user