mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
48 lines
794 B
Go
48 lines
794 B
Go
|
package oidc
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestShouldNotRaiseErrorOnEqualPasswordsPlainText(t *testing.T) {
|
||
|
hasher := AutheliaHasher{}
|
||
|
|
||
|
a := []byte("abc")
|
||
|
b := []byte("abc")
|
||
|
|
||
|
ctx := context.Background()
|
||
|
|
||
|
err := hasher.Compare(ctx, a, b)
|
||
|
|
||
|
assert.NoError(t, err)
|
||
|
}
|
||
|
|
||
|
func TestShouldRaiseErrorOnNonEqualPasswordsPlainText(t *testing.T) {
|
||
|
hasher := AutheliaHasher{}
|
||
|
|
||
|
a := []byte("abc")
|
||
|
b := []byte("abcd")
|
||
|
|
||
|
ctx := context.Background()
|
||
|
|
||
|
err := hasher.Compare(ctx, a, b)
|
||
|
|
||
|
assert.Equal(t, errPasswordsDoNotMatch, err)
|
||
|
}
|
||
|
|
||
|
func TestShouldHashPassword(t *testing.T) {
|
||
|
hasher := AutheliaHasher{}
|
||
|
|
||
|
data := []byte("abc")
|
||
|
|
||
|
ctx := context.Background()
|
||
|
|
||
|
hash, err := hasher.Hash(ctx, data)
|
||
|
|
||
|
assert.NoError(t, err)
|
||
|
assert.Equal(t, data, hash)
|
||
|
}
|