Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions pkg/billing/workflow_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (s *testWorkflowServer) CheckAggregationStatus(ctx context.Context, req *pb
// ---------- Test GRPC Dial with TLS Credentials ----------

func TestIntegration_GRPCWithCerts(t *testing.T) {
t.Parallel()
// Paths to self-signed certificate and key fixtures.
serverCertPath := "./test-fixtures/domain_test.pem"
serverKeyPath := "./test-fixtures/domain_test.key"
Expand Down Expand Up @@ -130,6 +131,7 @@ func TestIntegration_GRPCWithCerts(t *testing.T) {
}

func TestIntegration_GRPC_Insecure(t *testing.T) {
t.Parallel()
// Paths to self-signed certificate and key fixtures.
serverCertPath := "./test-fixtures/domain_test.pem"
serverKeyPath := "./test-fixtures/domain_test.key"
Expand Down Expand Up @@ -170,6 +172,7 @@ func TestIntegration_GRPC_Insecure(t *testing.T) {

// Test that NewWorkflowClient fails when given an invalid address.
func TestNewWorkflowClient_InvalidAddress(t *testing.T) {
t.Parallel()
lggr := logger.Test(t)
wc, err := NewWorkflowClient(lggr, "invalid-address",
WithWorkflowTransportCredentials(insecure.NewCredentials()),
Expand All @@ -186,6 +189,7 @@ func TestNewWorkflowClient_InvalidAddress(t *testing.T) {

// Test that calling Close() twice does not cause a panic.
func TestWorkflowClient_CloseTwice(t *testing.T) {
t.Parallel()
lis, err := net.Listen("tcp", "localhost:0")
require.NoError(t, err)
grpcServer := grpc.NewServer()
Expand All @@ -212,6 +216,7 @@ func TestWorkflowClient_CloseTwice(t *testing.T) {

// Additional test: Verify that dialGrpc fails if an unreachable address is provided.
func TestWorkflowClient_DialUnreachable(t *testing.T) {
t.Parallel()
lggr := logger.Test(t)
unreachableAddr := "192.0.2.1:12345" // Reserved for documentation.
wc, err := NewWorkflowClient(lggr, unreachableAddr,
Expand All @@ -230,6 +235,7 @@ func TestWorkflowClient_DialUnreachable(t *testing.T) {
// ---------- Test JWT Token Creation ----------

func TestWorkflowClient_AddJWTAuthToContext(t *testing.T) {
t.Parallel()

mockJWT := mocks.NewJWTGenerator(t)
req := MockRequest{Field: "test request"}
Expand Down Expand Up @@ -258,6 +264,7 @@ func TestWorkflowClient_AddJWTAuthToContext(t *testing.T) {

// Test that client handles the case when no JWT manager is provided.
func TestWorkflowClient_NoSigningKey(t *testing.T) {
t.Parallel()
ctx := context.Background()
req := MockRequest{Field: "test"}
wc := &workflowClient{
Expand All @@ -273,6 +280,7 @@ func TestWorkflowClient_NoSigningKey(t *testing.T) {

// Test that client handles JWT manager errors properly
func TestWorkflowClient_VerifySignature_Invalid(t *testing.T) {
t.Parallel()
mockJWT := mocks.NewJWTGenerator(t)
req := MockRequest{Field: "test"}

Expand All @@ -290,6 +298,7 @@ func TestWorkflowClient_VerifySignature_Invalid(t *testing.T) {
}

func TestWorkflowClient_RepeatedSign(t *testing.T) {
t.Parallel()
mockJWT := mocks.NewJWTGenerator(t)
req := MockRequest{Field: "repeatable"}
expectedToken := "consistent.jwt.token"
Expand Down
1 change: 1 addition & 0 deletions pkg/loop/logger_loop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

func TestHCLogLoggerPanic(t *testing.T) {
t.Parallel()
type testCase struct {
level int
expectedMessage string
Expand Down
12 changes: 11 additions & 1 deletion pkg/storage/workflow_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package storage
import (
"context"
"fmt"
"google.golang.org/protobuf/types/known/timestamppb"
"net"
"os"
"testing"
"time"

"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
Expand Down Expand Up @@ -49,6 +50,7 @@ func (s *testWorkflowServer) DownloadArtifact(ctx context.Context, req *pb.Downl
// ---------- Test GRPC Dial with TLS Credentials ----------

func TestIntegration_GRPCWithCerts(t *testing.T) {
t.Parallel()
// Paths to self-signed certificate and key fixtures.
serverCertPath := "./test-fixtures/domain_test.pem"
serverKeyPath := "./test-fixtures/domain_test.key"
Expand Down Expand Up @@ -120,6 +122,7 @@ func TestIntegration_GRPCWithCerts(t *testing.T) {
}

func TestIntegration_GRPC_Insecure(t *testing.T) {
t.Parallel()
// Start a test gRPC server without TLS.
lis, err := net.Listen("tcp", "localhost:0")
require.NoError(t, err)
Expand Down Expand Up @@ -166,6 +169,7 @@ func TestIntegration_GRPC_Insecure(t *testing.T) {
}

func TestNewWorkflowClient_InvalidAddress(t *testing.T) {
t.Parallel()
lggr := logger.Test(t)
wc, err := NewWorkflowClient(lggr, "invalid-address",
WithWorkflowTransportCredentials(insecure.NewCredentials()),
Expand All @@ -186,6 +190,7 @@ func TestNewWorkflowClient_InvalidAddress(t *testing.T) {
}

func TestWorkflowClient_CloseTwice(t *testing.T) {
t.Parallel()
lis, err := net.Listen("tcp", "localhost:0")
require.NoError(t, err)
grpcServer := grpc.NewServer()
Expand All @@ -211,6 +216,7 @@ func TestWorkflowClient_CloseTwice(t *testing.T) {
}

func TestWorkflowClient_DialUnreachable(t *testing.T) {
t.Parallel()
lggr := logger.Test(t)
unreachableAddr := "192.0.2.1:12345" // Reserved for documentation.
wc, err := NewWorkflowClient(lggr, unreachableAddr,
Expand All @@ -234,6 +240,7 @@ func TestWorkflowClient_DialUnreachable(t *testing.T) {
// ---------- Test JWT Token Creation ----------

func TestWorkflowClient_AddJWTAuthToContext(t *testing.T) {
t.Parallel()

mockJWT := mocks.NewJWTGenerator(t)
req := MockRequest{Field: "test request"}
Expand Down Expand Up @@ -262,6 +269,7 @@ func TestWorkflowClient_AddJWTAuthToContext(t *testing.T) {

// Test that client handles the case when no JWT manager is provided.
func TestWorkflowClient_NoSigningKey(t *testing.T) {
t.Parallel()
ctx := context.Background()
req := MockRequest{Field: "test"}
wc := &workflowClient{
Expand All @@ -277,6 +285,7 @@ func TestWorkflowClient_NoSigningKey(t *testing.T) {

// Test that client handles JWT manager errors properly
func TestWorkflowClient_VerifySignature_Invalid(t *testing.T) {
t.Parallel()
mockJWT := mocks.NewJWTGenerator(t)
req := MockRequest{Field: "test"}

Expand All @@ -294,6 +303,7 @@ func TestWorkflowClient_VerifySignature_Invalid(t *testing.T) {
}

func TestWorkflowClient_RepeatedSign(t *testing.T) {
t.Parallel()
mockJWT := mocks.NewJWTGenerator(t)
req := MockRequest{Field: "repeatable"}
expectedToken := "consistent.jwt.token"
Expand Down
Loading