Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork committed Jan 14, 2025
1 parent 3519929 commit 2750631
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion api/clients/v2/dispersal_request_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
grpc "github.com/Layr-Labs/eigenda/api/grpc/node/v2"
"github.com/Layr-Labs/eigenda/api/hashing"
aws2 "github.com/Layr-Labs/eigenda/common/aws"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/kms"
)
Expand All @@ -31,6 +32,7 @@ type requestSigner struct {
func NewDispersalRequestSigner(
ctx context.Context,
region string,
endpoint string,
keyID string) (DispersalRequestSigner, error) {

// Load the AWS SDK configuration, which will automatically detect credentials
Expand All @@ -42,7 +44,16 @@ func NewDispersalRequestSigner(
return nil, fmt.Errorf("failed to load AWS config: %w", err)
}

keyManager := kms.NewFromConfig(cfg)
var keyManager *kms.Client
if endpoint != "" {
keyManager = kms.New(kms.Options{
Region: region,
BaseEndpoint: aws.String(endpoint),
})
} else {
keyManager = kms.NewFromConfig(cfg)
}

key, err := aws2.LoadPublicKeyKMS(ctx, keyManager, keyID)
if err != nil {
return nil, fmt.Errorf("failed to get ecdsa public key: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion api/clients/v2/dispersal_request_signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestRequestSigning(t *testing.T) {
request := auth.RandomStoreChunksRequest(rand)
request.Signature = nil

signer, err := NewDispersalRequestSigner(context.Background(), region, keyID)
signer, err := NewDispersalRequestSigner(context.Background(), region, localstackHost, keyID)
require.NoError(t, err)

// Test a valid signature.
Expand Down
1 change: 1 addition & 0 deletions disperser/cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func RunController(ctx *cli.Context) error {
requestSigner, err = clients.NewDispersalRequestSigner(
context.Background(),
config.AwsClientConfig.Region,
config.AwsClientConfig.EndpointURL,
config.DisperserKMSKeyID)
if err != nil {
return fmt.Errorf("failed to create request signer: %v", err)
Expand Down

0 comments on commit 2750631

Please sign in to comment.