From d2fdb42cb2f77d388d6e0c48334fced2c473aeae Mon Sep 17 00:00:00 2001 From: Justin Hiemstra Date: Wed, 4 Oct 2023 19:16:30 +0000 Subject: [PATCH] Incorporate feedback from review --- director.go | 1 - director/redirect.go | 3 --- director/redirect_test.go | 23 ++--------------------- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/director.go b/director.go index f2a14c31a..47d11ab1e 100644 --- a/director.go +++ b/director.go @@ -160,7 +160,6 @@ func QueryDirector(source string, directorUrl string) (resp *http.Response, err // Check HTTP response -- should be 307 (redirect), else something went wrong body, _ := io.ReadAll(resp.Body) if resp.StatusCode != 307 { - fmt.Printf("\n\n\nresp.StatusCode %d\n\n\n", resp.StatusCode) var respErr directorResponse if unmarshalErr := json.Unmarshal(body, &respErr); unmarshalErr != nil { // Error creating json return nil, errors.Wrap(unmarshalErr, "Could not unmarshall the director's response") diff --git a/director/redirect.go b/director/redirect.go index 97c8ac307..0e60830a4 100644 --- a/director/redirect.go +++ b/director/redirect.go @@ -132,9 +132,6 @@ func versionCompatCheck(ginCtx *gin.Context) error { case "origin": minCompatVer = minOriginVersion } - if err != nil { - return errors.Wrapf(err, "Could not parse min version compatible for service %s\n", service) - } if reqVer.LessThan(minCompatVer) { return errors.Errorf("The director does not support your %s version (%s). Please update to %s or newer.", service, reqVer.String(), minCompatVer.String()) diff --git a/director/redirect_test.go b/director/redirect_test.go index de3caee3d..d7173e2a8 100644 --- a/director/redirect_test.go +++ b/director/redirect_test.go @@ -208,27 +208,8 @@ func TestDirectorRegistration(t *testing.T) { URL: &url.URL{}, } - // Create a private key to use for the test - privateKeyInv, err = ecdsa.GenerateKey(elliptic.P521(), rand.Reader) - assert.NoError(t, err, "Error generating private key") - - // Convert from raw ecdsa to jwk.Key - pKeyInv, err = jwk.FromRaw(privateKeyInv) - assert.NoError(t, err, "Unable to convert ecdsa.PrivateKey to jwk.Key") - - //Assign Key id to the private key - err = jwk.AssignKeyID(pKeyInv) - assert.NoError(t, err, "Error assigning kid to private key") - - //Set an algorithm for the key - err = pKeyInv.Set(jwk.AlgorithmKey, jwa.ES512) - assert.NoError(t, err, "Unable to set algorithm for pKey") - - // Create a token to be inserted - issuerURL.Host = cInv.Request.URL.Host - - // Sign token with previously created private key (mismatch to what's in the keyset) - signedInv, err = jwt.Sign(tok, jwt.WithKey(jwa.ES512, pKeyInv)) + // Sign token with the good key + signedInv, err = jwt.Sign(tok, jwt.WithKey(jwa.ES512, pKey)) assert.NoError(t, err, "Error signing token") // Create the request and set the headers