Skip to content

Commit

Permalink
add test for NewSymmetricKey
Browse files Browse the repository at this point in the history
Signed-off-by: qmuntal <qmuntaldiaz@microsoft.com>
  • Loading branch information
qmuntal committed Jul 10, 2023
1 parent 34b0e37 commit 382c9bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,10 @@ func NewEC2Key(alg Algorithm, x, y, d []byte) (*Key, error) {
// NewSymmetricKey returns a Key created using the provided Symmetric key
// bytes.
func NewSymmetricKey(k []byte) *Key {
key := &Key{
return &Key{
KeyType: KeyTypeSymmetric,
K: k,
}
return key
}

// NewKeyFromPublic returns a Key created using the provided crypto.PublicKey.
Expand Down
23 changes: 23 additions & 0 deletions key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,29 @@ func TestNewEC2Key(t *testing.T) {
}
}

func TestNewSymmetricKey(t *testing.T) {
type args struct {
k []byte
}
tests := []struct {
name string
args args
want *Key
}{
{"valid", args{[]byte{1, 2, 3}}, &Key{
KeyType: KeyTypeSymmetric,
K: []byte{1, 2, 3},
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewSymmetricKey(tt.args.k); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewSymmetricKey() = %v, want %v", got, tt.want)
}
})
}
}

func TestKey_SignRoundtrip(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 382c9bf

Please sign in to comment.