1
// Copyright 2014 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"github.com/juju/juju/cmd/modelcmd"
10
"github.com/juju/juju/juju"
11
"github.com/juju/juju/jujuclient"
14
type AddCommand struct {
18
type RemoveCommand struct {
22
type ChangePasswordCommand struct {
23
*changePasswordCommand
26
type LoginCommand struct {
30
type LogoutCommand struct {
34
type DisenableUserBase struct {
38
func NewAddCommandForTest(api AddUserAPI, store jujuclient.ClientStore, modelApi modelcmd.ModelAPI) (cmd.Command, *AddCommand) {
39
c := &addCommand{api: api}
40
c.SetClientStore(store)
41
c.SetModelApi(modelApi)
42
return modelcmd.WrapController(c), &AddCommand{c}
45
func NewRemoveCommandForTest(api RemoveUserAPI, store jujuclient.ClientStore) (cmd.Command, *RemoveCommand) {
46
c := &removeCommand{api: api}
47
c.SetClientStore(store)
48
return modelcmd.WrapController(c), &RemoveCommand{c}
51
func NewShowUserCommandForTest(api UserInfoAPI, store jujuclient.ClientStore) cmd.Command {
52
cmd := &infoCommand{infoCommandBase: infoCommandBase{api: api}}
53
cmd.SetClientStore(store)
54
return modelcmd.WrapController(cmd)
57
// NewChangePasswordCommand returns a ChangePasswordCommand with the api
58
// and writer provided as specified.
59
func NewChangePasswordCommandForTest(api ChangePasswordAPI, store jujuclient.ClientStore) (cmd.Command, *ChangePasswordCommand) {
60
c := &changePasswordCommand{api: api}
61
c.SetClientStore(store)
62
return modelcmd.WrapController(c), &ChangePasswordCommand{c}
65
// NewLoginCommand returns a LoginCommand with the api
66
// and writer provided as specified.
67
func NewLoginCommandForTest(
68
newLoginAPI func(juju.NewAPIConnectionParams) (LoginAPI, error),
69
store jujuclient.ClientStore,
70
) (cmd.Command, *LoginCommand) {
71
c := &loginCommand{newLoginAPI: newLoginAPI}
72
c.SetClientStore(store)
73
return modelcmd.WrapController(c), &LoginCommand{c}
76
// NewLogoutCommand returns a LogoutCommand with the api
77
// and writer provided as specified.
78
func NewLogoutCommandForTest(store jujuclient.ClientStore) (cmd.Command, *LogoutCommand) {
80
c.SetClientStore(store)
81
return modelcmd.WrapController(c), &LogoutCommand{c}
84
// NewDisableCommand returns a DisableCommand with the api provided as
86
func NewDisableCommandForTest(api disenableUserAPI, store jujuclient.ClientStore) (cmd.Command, *DisenableUserBase) {
87
c := &disableCommand{disenableUserBase{api: api}}
88
c.SetClientStore(store)
89
return modelcmd.WrapController(c), &DisenableUserBase{&c.disenableUserBase}
92
// NewEnableCommand returns a EnableCommand with the api provided as
94
func NewEnableCommandForTest(api disenableUserAPI, store jujuclient.ClientStore) (cmd.Command, *DisenableUserBase) {
95
c := &enableCommand{disenableUserBase{api: api}}
96
c.SetClientStore(store)
97
return modelcmd.WrapController(c), &DisenableUserBase{&c.disenableUserBase}
100
// NewListCommand returns a ListCommand with the api provided as specified.
101
func NewListCommandForTest(api UserInfoAPI, store jujuclient.ClientStore) cmd.Command {
102
c := &listCommand{infoCommandBase: infoCommandBase{api: api}}
103
c.SetClientStore(store)
104
return modelcmd.WrapController(c)