diff options
Diffstat (limited to 'internal/oidc/hasher_test.go')
| -rw-r--r-- | internal/oidc/hasher_test.go | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/internal/oidc/hasher_test.go b/internal/oidc/hasher_test.go index bc3dfac1b..04f1b0f41 100644 --- a/internal/oidc/hasher_test.go +++ b/internal/oidc/hasher_test.go @@ -5,32 +5,46 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestShouldNotRaiseErrorOnEqualPasswordsPlainText(t *testing.T) { - hasher := AdaptiveHasher{} + hasher, err := NewAdaptiveHasher() + + require.NoError(t, err) a := []byte("$plaintext$abc") b := []byte("abc") ctx := context.Background() - err := hasher.Compare(ctx, a, b) + assert.NoError(t, hasher.Compare(ctx, a, b)) +} + +func TestShouldNotRaiseErrorOnEqualPasswordsPlainTextWithSeparator(t *testing.T) { + hasher, err := NewAdaptiveHasher() - assert.NoError(t, err) + require.NoError(t, err) + + a := []byte("$plaintext$abc$123") + b := []byte("abc$123") + + ctx := context.Background() + + assert.NoError(t, hasher.Compare(ctx, a, b)) } func TestShouldRaiseErrorOnNonEqualPasswordsPlainText(t *testing.T) { - hasher := AdaptiveHasher{} + hasher, err := NewAdaptiveHasher() + + require.NoError(t, err) a := []byte("$plaintext$abc") b := []byte("abcd") ctx := context.Background() - err := hasher.Compare(ctx, a, b) - - assert.Equal(t, errPasswordsDoNotMatch, err) + assert.Equal(t, errPasswordsDoNotMatch, hasher.Compare(ctx, a, b)) } func TestShouldHashPassword(t *testing.T) { |
