Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Kreiger <noahkreiger@gmail.com>
  • Loading branch information
nkreiger committed Feb 5, 2024
1 parent 8853141 commit 10d5c9b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
5 changes: 3 additions & 2 deletions pkg/oauthflow/client_credentials.go
Expand Up @@ -19,13 +19,14 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/coreos/go-oidc/v3/oidc"
"golang.org/x/oauth2"
"io"
"net/http"
"net/url"
"strings"
"time"

"github.com/coreos/go-oidc/v3/oidc"
"golang.org/x/oauth2"
)

// CodeURL fetches the client credentials token authorization endpoint URL from the provider's well-known configuration endpoint
Expand Down
8 changes: 2 additions & 6 deletions pkg/oauthflow/client_credentials_test.go
Expand Up @@ -19,23 +19,19 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/coreos/go-oidc/v3/oidc"
"net/http"
"net/http/httptest"
"strings"
"testing"

"github.com/coreos/go-oidc/v3/oidc"
)

type testccDriver struct {
msgs []string
respCh chan interface{}
t *testing.T
}

func (td *testccDriver) writeMsg(s string) {
td.msgs = append(td.msgs, s)
}

func (td *testccDriver) handler(w http.ResponseWriter, r *http.Request) {
td.t.Log("got request:", r.URL.Path)
if r.URL.Path == "/.well-known/openid-configuration" {
Expand Down
30 changes: 15 additions & 15 deletions pkg/signature/kms/azure/client_test.go
Expand Up @@ -71,17 +71,17 @@ func (c *testKVClient) Verify(_ context.Context, _, _ string, _ azkeys.VerifyPar

type keyNotFoundClient struct {
testKVClient
key azkeys.JSONWebKey
getKeyReturnsErr bool
key azkeys.JSONWebKey
getKeyReturnsErr bool
getKeyCallThreshold int
getKeyCallCount int
getKeyCallCount int
}

func (c *keyNotFoundClient) GetKey(_ context.Context, _, _ string, _ *azkeys.GetKeyOptions) (azkeys.GetKeyResponse, error) {
if c.getKeyReturnsErr && c.getKeyCallCount < c.getKeyCallThreshold {
c.getKeyCallCount++
return azkeys.GetKeyResponse{}, &azcore.ResponseError{
StatusCode: http.StatusNotFound,
StatusCode: http.StatusNotFound,
RawResponse: &http.Response{},
}
}
Expand All @@ -95,7 +95,7 @@ func (c *keyNotFoundClient) GetKey(_ context.Context, _, _ string, _ *azkeys.Get

type nonResponseErrClient struct {
testKVClient
keyCache *ttlcache.Cache[string, crypto.PublicKey]
keyCache *ttlcache.Cache[string, crypto.PublicKey]
}

func (c *nonResponseErrClient) GetKey(_ context.Context, _, _ string, _ *azkeys.GetKeyOptions) (result azkeys.GetKeyResponse, err error) {
Expand All @@ -105,7 +105,7 @@ func (c *nonResponseErrClient) GetKey(_ context.Context, _, _ string, _ *azkeys.

type non404RespClient struct {
testKVClient
keyCache *ttlcache.Cache[string, crypto.PublicKey]
keyCache *ttlcache.Cache[string, crypto.PublicKey]
}

func (c *non404RespClient) GetKey(_ context.Context, _, _ string, _ *azkeys.GetKeyOptions) (result azkeys.GetKeyResponse, err error) {
Expand Down Expand Up @@ -212,8 +212,8 @@ func TestAzureVaultClientFetchPublicKey(t *testing.T) {

func TestAzureVaultClientCreateKey(t *testing.T) {
type test struct {
name string
client kvClient
name string
client kvClient
expectSuccess bool
}

Expand All @@ -226,27 +226,27 @@ func TestAzureVaultClientCreateKey(t *testing.T) {
{
name: "Successfully create key if it doesn't exist",
client: &keyNotFoundClient{
key: key,
getKeyReturnsErr: true,
key: key,
getKeyReturnsErr: true,
getKeyCallThreshold: 1,
},
expectSuccess: true,
},
{
name: "Return public key if it already exists",
client: &testKVClient{
client: &testKVClient{
key: key,
},
expectSuccess: true,
},
{
name: "Fail to create key due to unknown error",
client: &nonResponseErrClient{},
name: "Fail to create key due to unknown error",
client: &nonResponseErrClient{},
expectSuccess: false,
},
{
name: "Fail to create key due to non-404 status code error",
client: &non404RespClient{},
name: "Fail to create key due to non-404 status code error",
client: &non404RespClient{},
expectSuccess: false,
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/signature/kms/azure/integration_test.go
Expand Up @@ -117,7 +117,7 @@ func TestCreateKey(t *testing.T) {
if azureVaultURL == "" {
t.Fatalf("VAULT_URL must be set")
}

newKeyRef := fmt.Sprintf("azurekms://%s.vault.azure.net/%s", azureVaultURL, "new-test-key")

sv, err := LoadSignerVerifier(context.Background(), newKeyRef)
Expand Down
3 changes: 2 additions & 1 deletion test/fuzz/pem/fuzzcert_test.go
Expand Up @@ -18,8 +18,9 @@ package pem
import (
"bytes"
"encoding/pem"
"github.com/sigstore/sigstore/pkg/cryptoutils"
"testing"

"github.com/sigstore/sigstore/pkg/cryptoutils"
)

func FuzzLoadCertificates(f *testing.F) {
Expand Down
2 changes: 1 addition & 1 deletion test/fuzz/signature/fuzz_signature_test.go
Expand Up @@ -33,7 +33,6 @@ import (

func FuzzECDSASigner(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {

x := ecdsa.PrivateKey{}
z := new(big.Int)
z.SetBytes(data)
Expand Down Expand Up @@ -63,6 +62,7 @@ func FuzzECDSASigner(f *testing.F) {
}
})
}

func FuzzComputeDigest(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
hashFuncs := []crypto.Hash{
Expand Down
1 change: 1 addition & 0 deletions test/fuzz/tools.go
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

// Copyright 2021 The Sigstore Authors.
Expand Down

0 comments on commit 10d5c9b

Please sign in to comment.