mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
16c34b627f
* define auth endpoints * add intercepter with tests * auth functions * fix up the auth functions * add functions for storing and saving the hashed password from the validator db * validate strong password input and simplify jwt claims * tests for db funcs * comments for db funcs * wrap up the authentication tests * register auth srv * use proper db iface package and check if existing password * fix broken tests and add new test to check if password already exists * use roughtime * rlock to check the auth paths * Merge refs/heads/master into auth-rpc * Merge refs/heads/master into auth-rpc * Merge refs/heads/master into auth-rpc * leave out the stream interceptor * resolve confs * Merge branch 'master' into auth-rpc * confs * Merge branch 'auth-rpc' of github.com:prysmaticlabs/prysm into auth-rpc * Merge refs/heads/master into auth-rpc * Merge refs/heads/master into auth-rpc * Merge refs/heads/master into auth-rpc * Merge refs/heads/master into auth-rpc
27 lines
783 B
Go
27 lines
783 B
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestStore_HashedPasswordForAPI_SaveAndRetrieve(t *testing.T) {
|
|
db := setupDB(t, [][48]byte{})
|
|
hashedPassword := []byte("2093402934902839489238492")
|
|
ctx := context.Background()
|
|
// Assert we have no hashed password stored.
|
|
res, err := db.HashedPasswordForAPI(ctx)
|
|
require.NoError(t, err)
|
|
assert.DeepEqual(t, 0, len(res))
|
|
|
|
// Save the hashed password and attempt to refetch it.
|
|
require.NoError(t, db.SaveHashedPasswordForAPI(ctx, hashedPassword))
|
|
res, err = db.HashedPasswordForAPI(ctx)
|
|
require.NoError(t, err)
|
|
// Assert the retrieves value equals what we saved.
|
|
assert.DeepEqual(t, hashedPassword, res)
|
|
}
|