Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions internal/httputil/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ func (s *Signer) Add(ctx context.Context, uri string) error {
if err != nil {
return err
}
a := u.Host
s.use[a] = struct{}{}
if s.use != nil {
a := u.Host
s.use[a] = struct{}{}
}
return nil
}

Expand Down
25 changes: 25 additions & 0 deletions internal/httputil/signer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package httputil

import (
"context"
"github.com/quay/clair/config"
"github.com/quay/zlog"
"gopkg.in/square/go-jose.v2/jwt"
"testing"
)

func TestNewSigner(t *testing.T) {
ctx := zlog.Test(context.Background(), t)
cfg := config.Config{}
signer, err := NewSigner(ctx, &cfg, jwt.Claims{})
if err != nil {
t.Error("signer initialization with empty config should succeed")
}
if signer.use != nil {
t.Error("signed request authority map should be non-initialized")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Error("signed request authority map should be non-initialized")
t.Error("signed request authority map should be initialized")

}
err = signer.Add(ctx, "http://test-url")
if err != nil {
t.Error("Adding host to non-initialized signed request authority map should not fail")
}
}