AuthToken Tests now use recently added TestAuthMethod and TestAccount (#226)

This commit is contained in:
Todd Knight authored and GitHub committed 2020-07-31 11:43:03 -07:00
1 parent 5ceb335466
commit 41b2d36d98
13 files changed
+207 -176

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
package password
import (
"testing"
"github.com/hashicorp/watchtower/internal/db"
"github.com/hashicorp/watchtower/internal/iam"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_TestAuthMethods(t *testing.T) {
assert, require := assert.New(t), require.New(t)
conn, _ := db.TestSetup(t, "postgres")
org, _ := iam.TestScopes(t, conn)
require.NotNil(org)
assert.NotEmpty(org.GetPublicId())
count := 4
ams := TestAuthMethods(t, conn, org.GetPublicId(), count)
assert.Len(ams, count)
for _, am := range ams {
assert.NotEmpty(am.GetPublicId())
}
}
func Test_TestAccounts(t *testing.T) {
t.Helper()
assert, require := assert.New(t), require.New(t)
conn, _ := db.TestSetup(t, "postgres")
org, _ := iam.TestScopes(t, conn)
require.NotNil(org)
assert.NotEmpty(org.GetPublicId())
am := TestAuthMethods(t, conn, org.GetPublicId(), 1)[0]
count := 4
accounts := TestAccounts(t, conn, am.GetPublicId(), count)
assert.Len(accounts, count)
for _, a := range accounts {
assert.NotEmpty(a.GetPublicId())
}
}