github.com/argoproj/argo-cd/v2@v2.10.5/test/e2e/fixture/account/actions.go (about) 1 package project 2 3 import ( 4 "github.com/argoproj/argo-cd/v2/test/e2e/fixture" 5 ) 6 7 // this implements the "when" part of given/when/then 8 // 9 // none of the func implement error checks, and that is complete intended, you should check for errors 10 // using the Then() 11 type Actions struct { 12 context *Context 13 ignoreErrors bool 14 lastOutput string 15 lastError error 16 } 17 18 func (a *Actions) prepareCanIGetLogsArgs() []string { 19 a.context.t.Helper() 20 return []string{ 21 "account", "can-i", "get", "logs", a.context.project + "/*", 22 } 23 } 24 25 func (a *Actions) CanIGetLogs() *Actions { 26 a.context.t.Helper() 27 a.runCli(a.prepareCanIGetLogsArgs()...) 28 return a 29 } 30 31 func (a *Actions) IgnoreErrors() *Actions { 32 a.ignoreErrors = true 33 return a 34 } 35 36 func (a *Actions) DoNotIgnoreErrors() *Actions { 37 a.ignoreErrors = false 38 return a 39 } 40 41 func (a *Actions) prepareSetPasswordArgs(account string) []string { 42 a.context.t.Helper() 43 return []string{ 44 "account", "update-password", "--account", account, "--current-password", fixture.AdminPassword, "--new-password", fixture.DefaultTestUserPassword, 45 } 46 } 47 48 func (a *Actions) Create() *Actions { 49 fixture.SetAccounts(map[string][]string{ 50 a.context.name: {"login"}, 51 }) 52 _, _ = fixture.RunCli(a.prepareSetPasswordArgs(a.context.name)...) 53 return a 54 } 55 56 func (a *Actions) SetPermissions(permissions []fixture.ACL, roleName string) *Actions { 57 fixture.SetPermissions(permissions, a.context.name, roleName) 58 return a 59 } 60 61 func (a *Actions) SetParamInSettingConfigMap(key, value string) *Actions { 62 fixture.SetParamInSettingConfigMap(key, value) 63 return a 64 } 65 66 func (a *Actions) Login() *Actions { 67 fixture.LoginAs(a.context.name) 68 return a 69 } 70 71 func (a *Actions) runCli(args ...string) { 72 a.context.t.Helper() 73 a.lastOutput, a.lastError = fixture.RunCli(args...) 74 } 75 76 func (a *Actions) Then() *Consequences { 77 a.context.t.Helper() 78 return &Consequences{a.context, a} 79 }