Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Riccardo Schirone <[email protected]>
  • Loading branch information
ret2libc committed Feb 6, 2025
1 parent e65897c commit 277af89
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cmd/app/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func setupHTTPServer(t *testing.T) (httpServer, string) {

viper.Set("grpc-host", "")
viper.Set("grpc-port", 0)
algorithmRegistry, err := signature.NewAlgorithmRegistryConfig([]v1.KnownSignatureAlgorithm{})
algorithmRegistry, err := signature.NewAlgorithmRegistryConfig([]v1.PublicKeyDetails{})
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -99,7 +99,7 @@ func setupHTTPServerWithGRPCTLS(t *testing.T) (httpServer, string) {

viper.Set("grpc-host", "")
viper.Set("grpc-port", 0)
algorithmRegistry, err := signature.NewAlgorithmRegistryConfig([]v1.KnownSignatureAlgorithm{})
algorithmRegistry, err := signature.NewAlgorithmRegistryConfig([]v1.PublicKeyDetails{})
if err != nil {
t.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/app/serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestDuplex(t *testing.T) {
t.Fatal(err)
}
metricsPort := 2114
algorithmRegistry, err := signature.NewAlgorithmRegistryConfig([]v1.KnownSignatureAlgorithm{})
algorithmRegistry, err := signature.NewAlgorithmRegistryConfig([]v1.PublicKeyDetails{})
if err != nil {
t.Error(err)
}
Expand Down
59 changes: 37 additions & 22 deletions pkg/server/grpc_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,27 @@ import (
"crypto/rand"
"crypto/rsa"
"crypto/sha256"

"github.com/sigstore/fulcio/pkg/ca/ephemeralca"
"github.com/sigstore/fulcio/pkg/config"
"github.com/sigstore/fulcio/pkg/generated/protobuf"
"github.com/sigstore/fulcio/pkg/identity"
v1 "github.com/sigstore/protobuf-specs/gen/pb-go/common/v1"
"github.com/sigstore/sigstore/pkg/cryptoutils"
"github.com/sigstore/sigstore/pkg/signature"
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"net"
"net/http"
"net/http/httptest"
"net/url"
"reflect"
"strings"
"testing"
"time"

"chainguard.dev/sdk/uidp"
"github.com/go-jose/go-jose/v4"
"github.com/go-jose/go-jose/v4/jwt"
ctclient "github.com/google/certificate-transparency-go/client"
"github.com/google/certificate-transparency-go/jsonclient"

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand All @@ -46,6 +59,8 @@ import (
"github.com/sigstore/fulcio/pkg/identity"

Check failure on line 59 in pkg/server/grpc_server_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not properly formatted (gofmt)

Check failure on line 59 in pkg/server/grpc_server_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not properly formatted (goimports)
"github.com/sigstore/sigstore/pkg/cryptoutils"
"google.golang.org/grpc/resolver"
"github.com/sigstore/sigstore/pkg/signature"
v1 "github.com/sigstore/protobuf-specs/gen/pb-go/common/v1"
)

const (
Expand Down Expand Up @@ -80,7 +95,7 @@ func setupGRPCForTest(t *testing.T, cfg *config.FulcioConfig, ctl *ctclient.LogC
lis = bufconn.Listen(bufSize)
s := grpc.NewServer(grpc.UnaryInterceptor(passFulcioConfigThruContext(cfg)))
ip := NewIssuerPool(cfg)
algorithmRegistry, err := signature.NewAlgorithmRegistryConfig([]v1.KnownSignatureAlgorithm{v1.KnownSignatureAlgorithm_ECDSA_SHA2_256_NISTP256, v1.KnownSignatureAlgorithm_RSA_SIGN_PKCS1_2048_SHA256})
algorithmRegistry, err := signature.NewAlgorithmRegistryConfig([]v1.PublicKeyDetails{v1.PublicKeyDetails_PKIX_ECDSA_P256_SHA_256, v1.PublicKeyDetails_PKIX_RSA_PKCS1V15_2048_SHA256})
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -1630,7 +1645,7 @@ func TestAPIWithChainguard(t *testing.T) {
Audience: jwt.Audience{"sigstore"},
}).Claims(&claims).Serialize()
if err != nil {
t.Fatalf("CompactSerialize() = %v", err)
t.Fatalf("Serialize() = %v", err)
}

ctClient, eca := createCA(cfg, t)
Expand Down Expand Up @@ -1809,14 +1824,14 @@ func TestAPIWithRSA(t *testing.T) {
Expiry: jwt.NewNumericDate(time.Now().Add(30 * time.Minute)),
Subject: emailSubject,
Audience: jwt.Audience{"sigstore"},
}).Claims(customClaims{Email: emailSubject, EmailVerified: true}).CompactSerialize()
}).Claims(customClaims{Email: emailSubject, EmailVerified: true}).Serialize()
if err != nil {
t.Fatalf("CompactSerialize() = %v", err)
t.Fatalf("Serialize() = %v", err)
}

ctClient, eca := createCA(cfg, t)
ctx := context.Background()
server, conn := setupGRPCForTest(ctx, t, cfg, ctClient, eca)
server, conn := setupGRPCForTest(t, cfg, ctClient, eca)
defer func() {
server.Stop()
conn.Close()
Expand Down Expand Up @@ -1979,14 +1994,14 @@ func TestAPIWithCSRChallengeRSA(t *testing.T) {
Expiry: jwt.NewNumericDate(time.Now().Add(30 * time.Minute)),
Subject: emailSubject,
Audience: jwt.Audience{"sigstore"},
}).Claims(customClaims{Email: emailSubject, EmailVerified: true}).CompactSerialize()
}).Claims(customClaims{Email: emailSubject, EmailVerified: true}).Serialize()
if err != nil {
t.Fatalf("CompactSerialize() = %v", err)
t.Fatalf("Serialize() = %v", err)
}

ctClient, eca := createCA(cfg, t)
ctx := context.Background()
server, conn := setupGRPCForTest(ctx, t, cfg, ctClient, eca)
server, conn := setupGRPCForTest(t, cfg, ctClient, eca)
defer func() {
server.Stop()
conn.Close()
Expand Down Expand Up @@ -2280,14 +2295,14 @@ func TestAPIWithInvalidPublicKey(t *testing.T) {
Expiry: jwt.NewNumericDate(time.Now().Add(30 * time.Minute)),
Subject: emailSubject,
Audience: jwt.Audience{"sigstore"},
}).Claims(customClaims{Email: emailSubject, EmailVerified: true}).CompactSerialize()
}).Claims(customClaims{Email: emailSubject, EmailVerified: true}).Serialize()
if err != nil {
t.Fatalf("CompactSerialize() = %v", err)
t.Fatalf("Serialize() = %v", err)
}

ctClient, eca := createCA(cfg, t)
ctx := context.Background()
server, conn := setupGRPCForTest(ctx, t, cfg, ctClient, eca)
server, conn := setupGRPCForTest(t, cfg, ctClient, eca)
defer func() {
server.Stop()
conn.Close()
Expand Down Expand Up @@ -2500,14 +2515,14 @@ func TestAPIWithInvalidCSRPublicKey(t *testing.T) {
Expiry: jwt.NewNumericDate(time.Now().Add(30 * time.Minute)),
Subject: emailSubject,
Audience: jwt.Audience{"sigstore"},
}).Claims(customClaims{Email: emailSubject, EmailVerified: true}).CompactSerialize()
}).Claims(customClaims{Email: emailSubject, EmailVerified: true}).Serialize()
if err != nil {
t.Fatalf("CompactSerialize() = %v", err)
t.Fatalf("Serialize() = %v", err)
}

ctClient, eca := createCA(cfg, t)
ctx := context.Background()
server, conn := setupGRPCForTest(ctx, t, cfg, ctClient, eca)
server, conn := setupGRPCForTest(t, cfg, ctClient, eca)
defer func() {
server.Stop()
conn.Close()
Expand Down

0 comments on commit 277af89

Please sign in to comment.