mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-24 16:10:46 -06:00
backend/remote-state/http: tests support go1.21 (#391)
This commit is contained in:
parent
072d1dce56
commit
9724c4d748
@ -10,7 +10,10 @@ import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@ -281,11 +284,20 @@ func TestMTLSServer_NoCertFails(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error fetching StateMgr with %s: %v", backend.DefaultStateName, err)
|
||||
}
|
||||
|
||||
opErr := new(net.OpError)
|
||||
err = sm.RefreshState()
|
||||
if nil == err {
|
||||
t.Error("expected error when refreshing state without a client cert")
|
||||
} else if !strings.Contains(err.Error(), "remote error: tls: bad certificate") {
|
||||
t.Errorf("expected the error to report missing tls credentials: %v", err)
|
||||
if err == nil {
|
||||
t.Fatal("expected error when refreshing state without a client cert")
|
||||
}
|
||||
if errors.As(err, &opErr) {
|
||||
errType := fmt.Sprintf("%T", opErr.Err)
|
||||
expected := "tls.alert"
|
||||
if errType != expected {
|
||||
t.Fatalf("expected net.OpError.Err type: %q got: %q error:%s", expected, errType, err)
|
||||
}
|
||||
} else {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user