k3s/pkg/authenticator/hash/scrypt_test.go
Derek Nola 21c8a33647
Introduction of Integration Tests (#3695)
* Commit of new etcd snapshot integration tests.
* Updated integration github action to not run on doc changes.
* Update Drone runner to only run unit tests

Signed-off-by: dereknola <derek.nola@suse.com>
2021-07-26 09:59:33 -07:00

40 lines
718 B
Go

package hash
import (
"strings"
"testing"
)
func Test_UnitSCrypt_VerifyHash(t *testing.T) {
type args struct {
secretKey string
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "Basic Hash Test",
args: args{
secretKey: "hello world",
},
},
{
name: "Long Hash Test",
args: args{
secretKey: strings.Repeat("A", 720),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
hasher := NewSCrypt()
hash, _ := hasher.CreateHash(tt.args.secretKey)
if err := hasher.VerifyHash(hash, tt.args.secretKey); (err != nil) != tt.wantErr {
t.Errorf("SCrypt.VerifyHash() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}