diff --git a/internal/keystore/credhub/credhub.go b/internal/keystore/credhub/credhub.go index 12b9b3c8..5e96e837 100644 --- a/internal/keystore/credhub/credhub.go +++ b/internal/keystore/credhub/credhub.go @@ -13,15 +13,16 @@ import ( "encoding/pem" "errors" "fmt" + "net/http" + "os" + "strings" + "time" + "github.com/golang/groupcache/singleflight" "github.com/google/uuid" "github.com/minio/kes" "github.com/minio/kes/internal/keystore" kesdk "github.com/minio/kms-go/kes" - "net/http" - "os" - "strings" - "time" ) const ( diff --git a/internal/keystore/credhub/credhub_test.go b/internal/keystore/credhub/credhub_test.go index c84c8fdd..8ef0f55f 100644 --- a/internal/keystore/credhub/credhub_test.go +++ b/internal/keystore/credhub/credhub_test.go @@ -6,12 +6,13 @@ import ( "encoding/json" "errors" "fmt" - "github.com/minio/kes/internal/api" - "github.com/minio/kms-go/kes" "io" "net/http" "reflect" "testing" + + "github.com/minio/kes/internal/api" + "github.com/minio/kms-go/kes" ) /** CredHub Rest API contract tests. @@ -40,7 +41,6 @@ func TestStore_MTLS(t *testing.T) { assertNoError(t, resp.err) fmt.Println(resp.status) }) - } // `credhub curl -X=GET -p /health` @@ -220,7 +220,6 @@ func TestStore_Get(t *testing.T) { assertErrorIs(t, err, kes.ErrKeyNotFound) assertAPIErrorStatus(t, err, http.StatusNotFound) }) - } // `credhub curl -X=DELETE -p "/api/v1/data?name=/test-namespace/element-name"` @@ -381,6 +380,7 @@ func assertEqualComparable(t *testing.T, expected, got any) { t.Fatalf("expected '%v' got '%v'", expected, got) } } + func assertEqualBytes(t *testing.T, expected, got []byte) { if !bytes.Equal(expected, got) { t.Fatalf("expected '%v' got '%v'", expected, got) @@ -395,6 +395,7 @@ func assertRequest(t *testing.T, fc *FakeHTTPClient, method, uri string) { t.Fatalf("expected requested uri '%s' but got '%s'", uri, fc.reqURI) } } + func assertRequestWithJSONBody(t *testing.T, fc *FakeHTTPClient, method, uri string, jsonBody string) { assertRequest(t, fc, method, uri) diff --git a/internal/keystore/credhub/http_client.go b/internal/keystore/credhub/http_client.go index 3e450db2..18ba4dbd 100644 --- a/internal/keystore/credhub/http_client.go +++ b/internal/keystore/credhub/http_client.go @@ -18,6 +18,7 @@ type httpResponse struct { func newHTTPResponseError(err error) httpResponse { return httpResponse{statusCode: -1, status: "", body: nil, err: err} } + func (c *httpResponse) isStatusCode2xx() bool { return c.statusCode >= http.StatusOK && c.statusCode < http.StatusMultipleChoices }