2023-02-02 17:15:17 -08:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2021-04-08 20:54:32 -04:00
|
|
|
package oidc
|
|
|
|
|
|
|
|
|
|
import (
|
2021-07-29 18:52:56 -06:00
|
|
|
"context"
|
2021-04-08 20:54:32 -04:00
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2023-03-10 15:06:39 -05:00
|
|
|
"github.com/hashicorp/boundary/globals"
|
2021-04-08 20:54:32 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Test_Ids(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
2021-07-29 18:52:56 -06:00
|
|
|
ctx := context.TODO()
|
2023-03-10 15:06:39 -05:00
|
|
|
t.Run(globals.OidcAuthMethodPrefix, func(t *testing.T) {
|
2021-07-29 18:52:56 -06:00
|
|
|
id, err := newAuthMethodId(ctx)
|
2021-04-08 20:54:32 -04:00
|
|
|
require.NoError(t, err)
|
2023-03-10 15:06:39 -05:00
|
|
|
assert.True(t, strings.HasPrefix(id, globals.OidcAuthMethodPrefix+"_"))
|
2021-04-08 20:54:32 -04:00
|
|
|
})
|
2023-03-10 15:06:39 -05:00
|
|
|
t.Run(globals.OidcAccountPrefix, func(t *testing.T) {
|
2021-07-29 18:52:56 -06:00
|
|
|
id, err := newAccountId(ctx, "public-id", "test-issuer", "test-subject")
|
2021-04-08 20:54:32 -04:00
|
|
|
require.NoError(t, err)
|
2023-03-10 15:06:39 -05:00
|
|
|
assert.True(t, strings.HasPrefix(id, globals.OidcAccountPrefix+"_"))
|
2021-04-08 20:54:32 -04:00
|
|
|
})
|
|
|
|
|
}
|