2026-04-06 15:48:37 +05:30
|
|
|
// Copyright IBM Corp. 2020, 2026
|
2023-02-02 17:15:17 -08:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2020-07-31 11:43:03 -07:00
|
|
|
package password
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
2020-08-10 17:15:02 -04:00
|
|
|
"github.com/hashicorp/boundary/internal/db"
|
|
|
|
|
"github.com/hashicorp/boundary/internal/iam"
|
2020-07-31 11:43:03 -07:00
|
|
|
"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")
|
2020-08-19 16:47:18 -04:00
|
|
|
wrapper := db.TestWrapper(t)
|
|
|
|
|
org, _ := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
2020-07-31 11:43:03 -07:00
|
|
|
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())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-20 20:33:56 -04:00
|
|
|
func Test_TestMultipleAccounts(t *testing.T) {
|
2020-07-31 11:43:03 -07:00
|
|
|
assert, require := assert.New(t), require.New(t)
|
|
|
|
|
conn, _ := db.TestSetup(t, "postgres")
|
2020-08-19 16:47:18 -04:00
|
|
|
wrapper := db.TestWrapper(t)
|
|
|
|
|
org, _ := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper))
|
2020-07-31 11:43:03 -07:00
|
|
|
|
|
|
|
|
require.NotNil(org)
|
|
|
|
|
assert.NotEmpty(org.GetPublicId())
|
|
|
|
|
|
|
|
|
|
am := TestAuthMethods(t, conn, org.GetPublicId(), 1)[0]
|
|
|
|
|
|
|
|
|
|
count := 4
|
2021-04-20 20:33:56 -04:00
|
|
|
accounts := TestMultipleAccounts(t, conn, am.GetPublicId(), count)
|
2020-07-31 11:43:03 -07:00
|
|
|
assert.Len(accounts, count)
|
|
|
|
|
for _, a := range accounts {
|
|
|
|
|
assert.NotEmpty(a.GetPublicId())
|
|
|
|
|
}
|
|
|
|
|
}
|