From 012967e91b9917519fb7062ee353299cfb3254f0 Mon Sep 17 00:00:00 2001 From: Todd Knight Date: Wed, 12 Aug 2020 08:27:19 -0700 Subject: [PATCH] Adding DefaultAuthMethod, DefaultLoginName, DefaultPassword to exported testing test controller. (#258) --- testing/controller/controller.go | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/testing/controller/controller.go b/testing/controller/controller.go index 573c0c53ba..af31772129 100644 --- a/testing/controller/controller.go +++ b/testing/controller/controller.go @@ -29,6 +29,9 @@ type option struct { setWithConfigText bool setDisableDatabaseCreation bool setDefaultOrgId bool + setDefaultAuthMethodId bool + setDefaultLoginName bool + setDefaultPassword bool } type Option func(*option) error @@ -92,6 +95,39 @@ func WithDefaultOrgId(id string) Option { } } +func WithDefaultAuthMethodId(id string) Option { + return func(c *option) error { + if c.setDefaultAuthMethodId { + return fmt.Errorf("WithDefaultAuthMethodId provided more than once.") + } + c.setDefaultAuthMethodId = true + c.tcOptions.DefaultAuthMethodId = id + return nil + } +} + +func WithDefaultLoginName(ln string) Option { + return func(c *option) error { + if c.setDefaultLoginName { + return fmt.Errorf("WithDefaultLoginName provided more than once.") + } + c.setDefaultLoginName = true + c.tcOptions.DefaultLoginName = ln + return nil + } +} + +func WithDefaultPassword(pw string) Option { + return func(c *option) error { + if c.setDefaultPassword { + return fmt.Errorf("WithDefaultPassword provided more than once.") + } + c.setDefaultPassword = true + c.tcOptions.DefaultPassword = pw + return nil + } +} + // NewTestController blocks until a new TestController is created, returns the url for the TestController and a function // that can be called to tear down the controller after it has been used for testing. func NewTestController(t *testing.T, opt ...Option) *TestController {