Skip to content

Commit

Permalink
nil errs and err checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Jun 6, 2024
1 parent 6806958 commit 824c9ee
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
6 changes: 4 additions & 2 deletions database/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2576,8 +2576,10 @@ func newResources() *Resources {
jwkTwo := testutils.JWK()

jwkSet := jwk.NewSet()
jwkSet.AddKey(jwkOne)
jwkSet.AddKey(jwkTwo)

_ = jwkSet.AddKey(jwkOne)

_ = jwkSet.AddKey(jwkTwo)

logServiceOne := new(library.Log)
logServiceOne.SetID(1)
Expand Down
5 changes: 4 additions & 1 deletion database/jwk/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ func (e *engine) ListJWKs(_ context.Context) (jwk.Set, error) {
tmp := key

// convert query result to API type
keySet.AddKey(tmp.ToAPI())
err = keySet.AddKey(tmp.ToAPI())
if err != nil {
return nil, err
}
}

return keySet, nil
Expand Down
12 changes: 10 additions & 2 deletions database/jwk/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@ func TestJWK_Engine_ListJWKs(t *testing.T) {
}

wantSet := jwk.NewSet()
wantSet.AddKey(_jwkOne)
wantSet.AddKey(_jwkTwo)

err = wantSet.AddKey(_jwkOne)
if err != nil {
t.Errorf("unable to add jwk to set: %v", err)
}

err = wantSet.AddKey(_jwkTwo)
if err != nil {
t.Errorf("unable to add jwk to set: %v", err)
}

// setup tests
tests := []struct {
Expand Down
6 changes: 3 additions & 3 deletions internal/token/generate_rsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ func (tm *Manager) GenerateRSA(ctx context.Context, db database.Interface) error

pubJwk, err := jwk.FromRaw(privateRSAKey.PublicKey)
if err != nil {
return nil
return err
}

switch j := pubJwk.(type) {
case jwk.RSAPublicKey:
// assign KID to key pair
kid, err := uuid.NewV7()
if err != nil {
return nil
return err
}

err = pubJwk.Set(jwk.KeyIDKey, kid.String())
if err != nil {
return nil
return err
}

// create the JWK in the database
Expand Down

0 comments on commit 824c9ee

Please sign in to comment.