* Add argon2 credentials * Verify oplog in tests * Refactor: rename field * Update internal/auth/password/repository_account.go Co-authored-by: Todd Knight <T.Alan.Knight@gmail.com> * Add inline comments to SQL query to doc mapping to structure * Refactor: move authentication query to query.go file * Replace immutable_create_time_func with immutable_columns Co-authored-by: Todd Knight <T.Alan.Knight@gmail.com>
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package password
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test_GetOpts(t *testing.T) {
|
|
t.Parallel()
|
|
t.Run("WithName", func(t *testing.T) {
|
|
opts := getOpts(WithName("test"))
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withName = "test"
|
|
assert.Equal(t, opts, testOpts)
|
|
})
|
|
t.Run("WithDescription", func(t *testing.T) {
|
|
opts := getOpts(WithDescription("test desc"))
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withDescription = "test desc"
|
|
assert.Equal(t, opts, testOpts)
|
|
})
|
|
t.Run("WithLimit", func(t *testing.T) {
|
|
opts := getOpts(WithLimit(5))
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withLimit = 5
|
|
assert.Equal(t, opts, testOpts)
|
|
})
|
|
t.Run("WithPassword", func(t *testing.T) {
|
|
opts := getOpts(WithPassword("test password"))
|
|
testOpts := getDefaultOptions()
|
|
testOpts.password = "test password"
|
|
testOpts.withPassword = true
|
|
assert.Equal(t, opts, testOpts)
|
|
})
|
|
t.Run("WithConfiguration", func(t *testing.T) {
|
|
conf := NewArgon2Configuration()
|
|
conf.KeyLength = conf.KeyLength * 2
|
|
opts := getOpts(WithConfiguration(conf))
|
|
testOpts := getDefaultOptions()
|
|
c, ok := testOpts.withConfig.(*Argon2Configuration)
|
|
require.True(t, ok, "need an Argon2Configuration")
|
|
c.KeyLength = c.KeyLength * 2
|
|
testOpts.withConfig = c
|
|
assert.Equal(t, opts, testOpts)
|
|
})
|
|
}
|