Tools for auth token interception and authentication (#152)
This commit is contained in:
1 parent
f69d6b9952
commit
c44a4c4795
14 files changed
+445
-11
No files matched your search
@@ -94,7 +94,7 @@ func TestAuthToken_DbUpdate(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
w := db.New(conn)
|
||||
|
||||
authTok := testAuthToken(t, conn, wrapper)
|
||||
authTok := TestAuthToken(t, conn, wrapper)
|
||||
proto.Merge(authTok.AuthToken, tt.args.authTok)
|
||||
|
||||
err := authTok.encrypt(context.Background(), wrapper)
|
||||
@@ -119,7 +119,7 @@ func TestAuthToken_DbCreate(t *testing.T) {
|
||||
u := iam.TestUser(t, conn, org.GetPublicId())
|
||||
amId := setupAuthMethod(t, conn, org.GetPublicId())
|
||||
acct := setupAuthAccount(t, conn, org.GetPublicId(), amId, u.GetPublicId())
|
||||
createdAuthToken := testAuthToken(t, conn, wrapper)
|
||||
createdAuthToken := TestAuthToken(t, conn, wrapper)
|
||||
|
||||
testAuthTokenId := func() string {
|
||||
id, err := newAuthTokenId()
|
||||
@@ -177,7 +177,7 @@ func TestAuthToken_DbDelete(t *testing.T) {
|
||||
}
|
||||
|
||||
wrapper := db.TestWrapper(t)
|
||||
existingAuthTok := testAuthToken(t, conn, wrapper)
|
||||
existingAuthTok := TestAuthToken(t, conn, wrapper)
|
||||
|
||||
var tests = []struct {
|
||||
name string
|
||||
|
||||
@@ -196,7 +196,7 @@ func TestRepository_LookupAuthToken(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
|
||||
at := testAuthToken(t, conn, wrapper)
|
||||
at := TestAuthToken(t, conn, wrapper)
|
||||
at.Token = ""
|
||||
at.CtToken = nil
|
||||
|
||||
@@ -262,7 +262,7 @@ func TestRepository_ValidateToken(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, repo)
|
||||
|
||||
at := testAuthToken(t, conn, wrapper)
|
||||
at := TestAuthToken(t, conn, wrapper)
|
||||
atToken := at.GetToken()
|
||||
at.Token = ""
|
||||
at.CtToken = nil
|
||||
@@ -362,7 +362,7 @@ func TestRepository_ValidateToken_expired(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, repo)
|
||||
|
||||
baseAT := testAuthToken(t, conn, wrapper)
|
||||
baseAT := TestAuthToken(t, conn, wrapper)
|
||||
baseAT.GetAuthAccountId()
|
||||
aAcct := &iam.AuthAccount{AuthAccount: &iamStore.AuthAccount{PublicId: baseAT.GetAuthAccountId()}}
|
||||
require.NoError(t, rw.LookupByPublicId(context.Background(), aAcct))
|
||||
@@ -430,7 +430,7 @@ func TestRepository_DeleteAuthToken(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
|
||||
at := testAuthToken(t, conn, wrapper)
|
||||
at := TestAuthToken(t, conn, wrapper)
|
||||
badId, err := newAuthTokenId()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, badId)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func testAuthToken(t *testing.T, conn *gorm.DB, wrapper wrapping.Wrapper) *AuthToken {
|
||||
func TestAuthToken(t *testing.T, conn *gorm.DB, wrapper wrapping.Wrapper) *AuthToken {
|
||||
t.Helper()
|
||||
require := require.New(t)
|
||||
org, _ := iam.TestScopes(t, conn)
|
||||
|
||||
Reference in new issue
Block a user