Add initial SQL for managed groups (#1253)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2021-05-26 20:43:36 -04:00
1 parent ed5e34082c
commit 15bd1a5245
11 files changed
+1258 -464

No files matched your search

+31 -17
View File
@@ -27,7 +27,8 @@ import (
)
const (
DefaultTestAuthMethodId = "ampw_1234567890"
DefaultTestPasswordAuthMethodId = "ampw_1234567890"
DefaultTestOidcAuthMethodId = "amoidc_1234567890"
DefaultTestLoginName = "admin"
DefaultTestUnprivilegedLoginName = "user"
DefaultTestPassword = "passpass"
@@ -280,8 +281,11 @@ type TestControllerOpts struct {
// set.
Config *config.Config
// DefaultAuthMethodId is the default auth method ID to use, if set.
DefaultAuthMethodId string
// DefaultPasswordAuthMethodId is the default password method ID to use, if set.
DefaultPasswordAuthMethodId string
// DefaultOidcAuthMethodId is the default OIDC method ID to use, if set.
DefaultOidcAuthMethodId string
// DefaultLoginName is the login name used when creating the default admin account.
DefaultLoginName string
@@ -394,10 +398,15 @@ func NewTestController(t *testing.T, opts *TestControllerOpts) *TestController {
opts.Config.Controller.Name = opts.Name
}
if opts.DefaultAuthMethodId != "" {
tc.b.DevPasswordAuthMethodId = opts.DefaultAuthMethodId
if opts.DefaultPasswordAuthMethodId != "" {
tc.b.DevPasswordAuthMethodId = opts.DefaultPasswordAuthMethodId
} else {
tc.b.DevPasswordAuthMethodId = DefaultTestAuthMethodId
tc.b.DevPasswordAuthMethodId = DefaultTestPasswordAuthMethodId
}
if opts.DefaultOidcAuthMethodId != "" {
tc.b.DevOidcAuthMethodId = opts.DefaultOidcAuthMethodId
} else {
tc.b.DevOidcAuthMethodId = DefaultTestOidcAuthMethodId
}
if opts.DefaultLoginName != "" {
tc.b.DevLoginName = opts.DefaultLoginName
@@ -440,6 +449,7 @@ func NewTestController(t *testing.T, opts *TestControllerOpts) *TestController {
if opts.InitialResourcesSuffix != "" {
suffix := opts.InitialResourcesSuffix
tc.b.DevPasswordAuthMethodId = "ampw_" + suffix
tc.b.DevOidcAuthMethodId = "amoidc_" + suffix
tc.b.DevHostCatalogId = "hcst_" + suffix
tc.b.DevHostId = "hst_" + suffix
tc.b.DevHostSetId = "hsst_" + suffix
@@ -500,6 +510,9 @@ func NewTestController(t *testing.T, opts *TestControllerOpts) *TestController {
if _, _, err := tc.b.CreateInitialPasswordAuthMethod(ctx); err != nil {
t.Fatal(err)
}
if err := tc.b.CreateDevOidcAuthMethod(ctx); err != nil {
t.Fatal(err)
}
if !opts.DisableScopesCreation {
if _, _, err := tc.b.CreateInitialScopes(ctx); err != nil {
t.Fatal(err)
@@ -557,17 +570,18 @@ func (tc *TestController) AddClusterControllerMember(t *testing.T, opts *TestCon
opts = new(TestControllerOpts)
}
nextOpts := &TestControllerOpts{
DatabaseUrl: tc.c.conf.DatabaseUrl,
DefaultAuthMethodId: tc.c.conf.DevPasswordAuthMethodId,
RootKms: tc.c.conf.RootKms,
WorkerAuthKms: tc.c.conf.WorkerAuthKms,
RecoveryKms: tc.c.conf.RecoveryKms,
Name: opts.Name,
Logger: tc.c.conf.Logger,
DefaultLoginName: tc.b.DevLoginName,
DefaultPassword: tc.b.DevPassword,
DisableKmsKeyCreation: true,
DisableAuthMethodCreation: true,
DatabaseUrl: tc.c.conf.DatabaseUrl,
DefaultPasswordAuthMethodId: tc.c.conf.DevPasswordAuthMethodId,
DefaultOidcAuthMethodId: tc.c.conf.DevOidcAuthMethodId,
RootKms: tc.c.conf.RootKms,
WorkerAuthKms: tc.c.conf.WorkerAuthKms,
RecoveryKms: tc.c.conf.RecoveryKms,
Name: opts.Name,
Logger: tc.c.conf.Logger,
DefaultLoginName: tc.b.DevLoginName,
DefaultPassword: tc.b.DevPassword,
DisableKmsKeyCreation: true,
DisableAuthMethodCreation: true,
}
if opts.Logger != nil {
nextOpts.Logger = opts.Logger