authelia/internal/oidc/hasher_test.go
James Elliott 0a970aef8a
feat(oidc): persistent storage (#2965)
This moves the OpenID Connect storage from memory into the SQL storage, making it persistent and allowing it to be used with clustered deployments like the rest of Authelia.
2022-04-07 15:33:53 +10:00

48 lines
797 B
Go

package oidc
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestShouldNotRaiseErrorOnEqualPasswordsPlainText(t *testing.T) {
hasher := PlainTextHasher{}
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 := PlainTextHasher{}
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 := PlainTextHasher{}
data := []byte("abc")
ctx := context.Background()
hash, err := hasher.Hash(ctx, data)
assert.NoError(t, err)
assert.Equal(t, data, hash)
}