2021-06-08 11:31:58 -05:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-02-02 17:15:17 -08:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2020-07-24 10:23:35 -04:00
|
|
|
package password
|
|
|
|
|
|
|
|
|
|
import (
|
2023-06-06 17:09:08 -04:00
|
|
|
"context"
|
2020-07-24 10:23:35 -04:00
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2023-03-10 15:06:39 -05:00
|
|
|
"github.com/hashicorp/boundary/globals"
|
2020-07-24 10:23:35 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Test_PublicIds(t *testing.T) {
|
2023-06-06 17:09:08 -04:00
|
|
|
ctx := context.Background()
|
2020-07-24 10:23:35 -04:00
|
|
|
t.Run("authMethod", func(t *testing.T) {
|
2023-06-06 17:09:08 -04:00
|
|
|
id, err := newAuthMethodId(ctx)
|
2020-07-24 10:23:35 -04:00
|
|
|
require.NoError(t, err)
|
2023-03-10 15:06:39 -05:00
|
|
|
assert.True(t, strings.HasPrefix(id, globals.PasswordAuthMethodPrefix+"_"))
|
2020-07-24 10:23:35 -04:00
|
|
|
})
|
|
|
|
|
t.Run("account", func(t *testing.T) {
|
2023-06-06 17:09:08 -04:00
|
|
|
id, err := newAccountId(ctx)
|
2020-07-24 10:23:35 -04:00
|
|
|
require.NoError(t, err)
|
2023-03-10 15:06:39 -05:00
|
|
|
assert.True(t, strings.HasPrefix(id, globals.PasswordAccountPrefix+"_"))
|
2020-07-24 10:23:35 -04:00
|
|
|
})
|
|
|
|
|
}
|