mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -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/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
@ -281,11 +284,20 @@ func TestMTLSServer_NoCertFails(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error fetching StateMgr with %s: %v", backend.DefaultStateName, err)
|
t.Fatalf("unexpected error fetching StateMgr with %s: %v", backend.DefaultStateName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opErr := new(net.OpError)
|
||||||
err = sm.RefreshState()
|
err = sm.RefreshState()
|
||||||
if nil == err {
|
if err == nil {
|
||||||
t.Error("expected error when refreshing state without a client cert")
|
t.Fatal("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 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