Skip to content

Commit

Permalink
feat: nil signer
Browse files Browse the repository at this point in the history
  • Loading branch information
brokeyourbike committed Aug 29, 2023
1 parent 378f34b commit 4a23a1a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 0 additions & 1 deletion signature/google/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type KeyManagementClient interface {
AsymmetricSign(context.Context, *kmspb.AsymmetricSignRequest, ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error)
}

// Signer is a Google Cloud KMS signer.
type signer struct {
client KeyManagementClient
keyName string
Expand Down
15 changes: 15 additions & 0 deletions signature/local/signer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package local

import "context"

type nilSigner struct{}

// NewNilSigner creates a signer that does nothing.
func NewNilSigner() *nilSigner {
return &nilSigner{}
}

// Sign returns the same message and no error.
func (s *nilSigner) Sign(ctx context.Context, message []byte) ([]byte, error) {
return message, nil
}
17 changes: 17 additions & 0 deletions signature/local/signer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package local_test

import (
"context"
"testing"

"github.com/brokeyourbike/clearbank-api-client-go/signature/local"
"github.com/stretchr/testify/assert"
)

func TestNilSigner(t *testing.T) {
signer := local.NewNilSigner()
got, err := signer.Sign(context.TODO(), []byte("hello!"))

assert.NoError(t, err)
assert.Equal(t, []byte("hello!"), got)
}

0 comments on commit 4a23a1a

Please sign in to comment.