Skip to content

Commit

Permalink
Incorporate feedback from review
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Oct 4, 2023
1 parent 975e0e8 commit d2fdb42
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
1 change: 0 additions & 1 deletion director.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 0 additions & 3 deletions director/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
23 changes: 2 additions & 21 deletions director/redirect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d2fdb42

Please sign in to comment.