-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
378f34b
commit 4a23a1a
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |