Merge lp:~jameinel/juju-core/1.18-authorized-keys-1312537 into lp:juju-core/1.18

Proposed by John A Meinel
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 2277
Proposed branch: lp:~jameinel/juju-core/1.18-authorized-keys-1312537
Merge into: lp:juju-core/1.18
Diff against target: 390 lines (+73/-43)
11 files modified
cmd/juju/authorizedkeys.go (+7/-6)
cmd/juju/authorizedkeys_add.go (+1/-1)
cmd/juju/authorizedkeys_delete.go (+1/-1)
cmd/juju/authorizedkeys_import.go (+1/-1)
cmd/juju/authorizedkeys_list.go (+2/-2)
cmd/juju/authorizedkeys_test.go (+23/-23)
cmd/juju/help_topics.go (+5/-5)
cmd/juju/main.go (+2/-2)
cmd/juju/main_test.go (+2/-1)
cmd/supercommand.go (+6/-1)
cmd/supercommand_test.go (+23/-0)
To merge this branch: bzr merge lp:~jameinel/juju-core/1.18-authorized-keys-1312537
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+217203@code.launchpad.net

Commit message

Rename authorised-keys to authorized-keys, but keep the other as an alias.

This makes us a bit more consistent with the value in environments.yaml.
(Addresses bug #1312537)
https://codereview.appspot.com/93800043/

Description of the change

Retarget the "authorized-keys" switch to 1.18 where it was developed.

Self approving because the patch has already been approved for Trunk, and I got acceptance to put it into 1.18 as well.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== renamed file 'cmd/juju/authorisedkeys.go' => 'cmd/juju/authorizedkeys.go'
--- cmd/juju/authorisedkeys.go 2013-12-13 06:53:01 +0000
+++ cmd/juju/authorizedkeys.go 2014-04-25 11:00:53 +0000
@@ -15,17 +15,18 @@
1515
16`16`
1717
18type AuthorisedKeysCommand struct {18type AuthorizedKeysCommand struct {
19 *cmd.SuperCommand19 *cmd.SuperCommand
20}20}
2121
22func NewAuthorisedKeysCommand() cmd.Command {22func NewAuthorizedKeysCommand() cmd.Command {
23 sshkeyscmd := &AuthorisedKeysCommand{23 sshkeyscmd := &AuthorizedKeysCommand{
24 SuperCommand: cmd.NewSuperCommand(cmd.SuperCommandParams{24 SuperCommand: cmd.NewSuperCommand(cmd.SuperCommandParams{
25 Name: "authorised-keys",25 Name: "authorized-keys",
26 Doc: authKeysDoc,26 Doc: authKeysDoc,
27 UsagePrefix: "juju",27 UsagePrefix: "juju",
28 Purpose: "manage authorised ssh keys",28 Purpose: "manage authorized ssh keys",
29 Aliases: []string{"authorised-keys"},
29 }),30 }),
30 }31 }
31 sshkeyscmd.Register(&AddKeysCommand{})32 sshkeyscmd.Register(&AddKeysCommand{})
@@ -35,6 +36,6 @@
35 return sshkeyscmd36 return sshkeyscmd
36}37}
3738
38func (c *AuthorisedKeysCommand) SetFlags(f *gnuflag.FlagSet) {39func (c *AuthorizedKeysCommand) SetFlags(f *gnuflag.FlagSet) {
39 c.SetCommonFlags(f)40 c.SetCommonFlags(f)
40}41}
4142
=== renamed file 'cmd/juju/authorisedkeys_add.go' => 'cmd/juju/authorizedkeys_add.go'
--- cmd/juju/authorisedkeys_add.go 2013-12-13 06:53:01 +0000
+++ cmd/juju/authorizedkeys_add.go 2014-04-25 11:00:53 +0000
@@ -14,7 +14,7 @@
14)14)
1515
16var addKeysDoc = `16var addKeysDoc = `
17Add new authorised ssh keys to allow the holder of those keys to log on to Juju nodes or machines.17Add new authorized ssh keys to allow the holder of those keys to log on to Juju nodes or machines.
18`18`
1919
20// AddKeysCommand is used to add a new authorized ssh key for a user.20// AddKeysCommand is used to add a new authorized ssh key for a user.
2121
=== renamed file 'cmd/juju/authorisedkeys_delete.go' => 'cmd/juju/authorizedkeys_delete.go'
--- cmd/juju/authorisedkeys_delete.go 2013-12-13 06:53:01 +0000
+++ cmd/juju/authorizedkeys_delete.go 2014-04-25 11:00:53 +0000
@@ -14,7 +14,7 @@
14)14)
1515
16var deleteKeysDoc = `16var deleteKeysDoc = `
17Delete existing authorised ssh keys to remove ssh access for the holder of those keys.17Delete existing authorized ssh keys to remove ssh access for the holder of those keys.
18The keys to delete are found by specifying either the "comment" portion of the ssh key,18The keys to delete are found by specifying either the "comment" portion of the ssh key,
19typically something like "user@host", or the key fingerprint found by using ssh-keygen.19typically something like "user@host", or the key fingerprint found by using ssh-keygen.
20`20`
2121
=== renamed file 'cmd/juju/authorisedkeys_import.go' => 'cmd/juju/authorizedkeys_import.go'
--- cmd/juju/authorisedkeys_import.go 2013-12-13 06:53:01 +0000
+++ cmd/juju/authorizedkeys_import.go 2014-04-25 11:00:53 +0000
@@ -14,7 +14,7 @@
14)14)
1515
16var importKeysDoc = `16var importKeysDoc = `
17Import new authorised ssh keys to allow the holder of those keys to log on to Juju nodes or machines.17Import new authorized ssh keys to allow the holder of those keys to log on to Juju nodes or machines.
18The keys are imported using ssh-import-id.18The keys are imported using ssh-import-id.
19`19`
2020
2121
=== renamed file 'cmd/juju/authorisedkeys_list.go' => 'cmd/juju/authorizedkeys_list.go'
--- cmd/juju/authorisedkeys_list.go 2013-12-12 22:14:52 +0000
+++ cmd/juju/authorizedkeys_list.go 2014-04-25 11:00:53 +0000
@@ -15,7 +15,7 @@
15)15)
1616
17var listKeysDoc = `17var listKeysDoc = `
18List a user's authorised ssh keys, allowing the holders of those keys to log on to Juju nodes.18List a user's authorized ssh keys, allowing the holders of those keys to log on to Juju nodes.
19By default, just the key fingerprint is printed. Use --full to display the entire key.19By default, just the key fingerprint is printed. Use --full to display the entire key.
2020
21`21`
@@ -31,7 +31,7 @@
31 return &cmd.Info{31 return &cmd.Info{
32 Name: "list",32 Name: "list",
33 Doc: listKeysDoc,33 Doc: listKeysDoc,
34 Purpose: "list authorised ssh keys for a specified user",34 Purpose: "list authorized ssh keys for a specified user",
35 }35 }
36}36}
3737
3838
=== renamed file 'cmd/juju/authorisedkeys_test.go' => 'cmd/juju/authorizedkeys_test.go'
--- cmd/juju/authorisedkeys_test.go 2014-03-12 22:33:09 +0000
+++ cmd/juju/authorizedkeys_test.go 2014-04-25 11:00:53 +0000
@@ -18,12 +18,12 @@
18 sshtesting "launchpad.net/juju-core/utils/ssh/testing"18 sshtesting "launchpad.net/juju-core/utils/ssh/testing"
19)19)
2020
21type AuthorisedKeysSuite struct {21type AuthorizedKeysSuite struct {
22 testbase.LoggingSuite22 testbase.LoggingSuite
23 jujuHome *coretesting.FakeHome23 jujuHome *coretesting.FakeHome
24}24}
2525
26var _ = gc.Suite(&AuthorisedKeysSuite{})26var _ = gc.Suite(&AuthorizedKeysSuite{})
2727
28var authKeysCommandNames = []string{28var authKeysCommandNames = []string{
29 "add",29 "add",
@@ -33,20 +33,20 @@
33 "list",33 "list",
34}34}
3535
36func (s *AuthorisedKeysSuite) SetUpTest(c *gc.C) {36func (s *AuthorizedKeysSuite) SetUpTest(c *gc.C) {
37 s.LoggingSuite.SetUpTest(c)37 s.LoggingSuite.SetUpTest(c)
38 s.jujuHome = coretesting.MakeEmptyFakeHome(c)38 s.jujuHome = coretesting.MakeEmptyFakeHome(c)
39}39}
4040
41func (s *AuthorisedKeysSuite) TearDownTest(c *gc.C) {41func (s *AuthorizedKeysSuite) TearDownTest(c *gc.C) {
42 s.jujuHome.Restore()42 s.jujuHome.Restore()
43 s.LoggingSuite.TearDownTest(c)43 s.LoggingSuite.TearDownTest(c)
44}44}
4545
46func (s *AuthorisedKeysSuite) TestHelpCommands(c *gc.C) {46func (s *AuthorizedKeysSuite) TestHelpCommands(c *gc.C) {
47 // Check that we have correctly registered all the sub commands47 // Check that we have correctly registered all the sub commands
48 // by checking the help output.48 // by checking the help output.
49 out := badrun(c, 0, "authorised-keys", "--help")49 out := badrun(c, 0, "authorized-keys", "--help")
50 lines := strings.Split(out, "\n")50 lines := strings.Split(out, "\n")
51 var names []string51 var names []string
52 subcommandsFound := false52 subcommandsFound := false
@@ -65,29 +65,29 @@
65 c.Assert(names, gc.DeepEquals, authKeysCommandNames)65 c.Assert(names, gc.DeepEquals, authKeysCommandNames)
66}66}
6767
68func (s *AuthorisedKeysSuite) assertHelpOutput(c *gc.C, cmd, args string) {68func (s *AuthorizedKeysSuite) assertHelpOutput(c *gc.C, cmd, args string) {
69 if args != "" {69 if args != "" {
70 args = " " + args70 args = " " + args
71 }71 }
72 expected := fmt.Sprintf("usage: juju authorised-keys %s [options]%s", cmd, args)72 expected := fmt.Sprintf("usage: juju authorized-keys %s [options]%s", cmd, args)
73 out := badrun(c, 0, "authorised-keys", cmd, "--help")73 out := badrun(c, 0, "authorized-keys", cmd, "--help")
74 lines := strings.Split(out, "\n")74 lines := strings.Split(out, "\n")
75 c.Assert(lines[0], gc.Equals, expected)75 c.Assert(lines[0], gc.Equals, expected)
76}76}
7777
78func (s *AuthorisedKeysSuite) TestHelpList(c *gc.C) {78func (s *AuthorizedKeysSuite) TestHelpList(c *gc.C) {
79 s.assertHelpOutput(c, "list", "")79 s.assertHelpOutput(c, "list", "")
80}80}
8181
82func (s *AuthorisedKeysSuite) TestHelpAdd(c *gc.C) {82func (s *AuthorizedKeysSuite) TestHelpAdd(c *gc.C) {
83 s.assertHelpOutput(c, "add", "<ssh key> [...]")83 s.assertHelpOutput(c, "add", "<ssh key> [...]")
84}84}
8585
86func (s *AuthorisedKeysSuite) TestHelpDelete(c *gc.C) {86func (s *AuthorizedKeysSuite) TestHelpDelete(c *gc.C) {
87 s.assertHelpOutput(c, "delete", "<ssh key id> [...]")87 s.assertHelpOutput(c, "delete", "<ssh key id> [...]")
88}88}
8989
90func (s *AuthorisedKeysSuite) TestHelpImport(c *gc.C) {90func (s *AuthorizedKeysSuite) TestHelpImport(c *gc.C) {
91 s.assertHelpOutput(c, "import", "<ssh key id> [...]")91 s.assertHelpOutput(c, "import", "<ssh key id> [...]")
92}92}
9393
@@ -100,7 +100,7 @@
100 s.PatchEnvironment(osenv.JujuEnvEnvKey, "dummyenv")100 s.PatchEnvironment(osenv.JujuEnvEnvKey, "dummyenv")
101}101}
102102
103func (s *keySuiteBase) setAuthorisedKeys(c *gc.C, keys ...string) {103func (s *keySuiteBase) setAuthorizedKeys(c *gc.C, keys ...string) {
104 keyString := strings.Join(keys, "\n")104 keyString := strings.Join(keys, "\n")
105 err := s.State.UpdateEnvironConfig(map[string]interface{}{"authorized-keys": keyString}, nil, nil)105 err := s.State.UpdateEnvironConfig(map[string]interface{}{"authorized-keys": keyString}, nil, nil)
106 c.Assert(err, gc.IsNil)106 c.Assert(err, gc.IsNil)
@@ -125,7 +125,7 @@
125func (s *ListKeysSuite) TestListKeys(c *gc.C) {125func (s *ListKeysSuite) TestListKeys(c *gc.C) {
126 key1 := sshtesting.ValidKeyOne.Key + " user@host"126 key1 := sshtesting.ValidKeyOne.Key + " user@host"
127 key2 := sshtesting.ValidKeyTwo.Key + " another@host"127 key2 := sshtesting.ValidKeyTwo.Key + " another@host"
128 s.setAuthorisedKeys(c, key1, key2)128 s.setAuthorizedKeys(c, key1, key2)
129129
130 context, err := coretesting.RunCommand(c, &ListKeysCommand{}, []string{})130 context, err := coretesting.RunCommand(c, &ListKeysCommand{}, []string{})
131 c.Assert(err, gc.IsNil)131 c.Assert(err, gc.IsNil)
@@ -137,7 +137,7 @@
137func (s *ListKeysSuite) TestListFullKeys(c *gc.C) {137func (s *ListKeysSuite) TestListFullKeys(c *gc.C) {
138 key1 := sshtesting.ValidKeyOne.Key + " user@host"138 key1 := sshtesting.ValidKeyOne.Key + " user@host"
139 key2 := sshtesting.ValidKeyTwo.Key + " another@host"139 key2 := sshtesting.ValidKeyTwo.Key + " another@host"
140 s.setAuthorisedKeys(c, key1, key2)140 s.setAuthorizedKeys(c, key1, key2)
141141
142 context, err := coretesting.RunCommand(c, &ListKeysCommand{}, []string{"--full"})142 context, err := coretesting.RunCommand(c, &ListKeysCommand{}, []string{"--full"})
143 c.Assert(err, gc.IsNil)143 c.Assert(err, gc.IsNil)
@@ -149,7 +149,7 @@
149func (s *ListKeysSuite) TestListKeysNonDefaultUser(c *gc.C) {149func (s *ListKeysSuite) TestListKeysNonDefaultUser(c *gc.C) {
150 key1 := sshtesting.ValidKeyOne.Key + " user@host"150 key1 := sshtesting.ValidKeyOne.Key + " user@host"
151 key2 := sshtesting.ValidKeyTwo.Key + " another@host"151 key2 := sshtesting.ValidKeyTwo.Key + " another@host"
152 s.setAuthorisedKeys(c, key1, key2)152 s.setAuthorizedKeys(c, key1, key2)
153 _, err := s.State.AddUser("fred", "password")153 _, err := s.State.AddUser("fred", "password")
154 c.Assert(err, gc.IsNil)154 c.Assert(err, gc.IsNil)
155155
@@ -173,7 +173,7 @@
173173
174func (s *AddKeySuite) TestAddKey(c *gc.C) {174func (s *AddKeySuite) TestAddKey(c *gc.C) {
175 key1 := sshtesting.ValidKeyOne.Key + " user@host"175 key1 := sshtesting.ValidKeyOne.Key + " user@host"
176 s.setAuthorisedKeys(c, key1)176 s.setAuthorizedKeys(c, key1)
177177
178 key2 := sshtesting.ValidKeyTwo.Key + " another@host"178 key2 := sshtesting.ValidKeyTwo.Key + " another@host"
179 context, err := coretesting.RunCommand(c, &AddKeysCommand{}, []string{key2, "invalid-key"})179 context, err := coretesting.RunCommand(c, &AddKeysCommand{}, []string{key2, "invalid-key"})
@@ -184,7 +184,7 @@
184184
185func (s *AddKeySuite) TestAddKeyNonDefaultUser(c *gc.C) {185func (s *AddKeySuite) TestAddKeyNonDefaultUser(c *gc.C) {
186 key1 := sshtesting.ValidKeyOne.Key + " user@host"186 key1 := sshtesting.ValidKeyOne.Key + " user@host"
187 s.setAuthorisedKeys(c, key1)187 s.setAuthorizedKeys(c, key1)
188 _, err := s.State.AddUser("fred", "password")188 _, err := s.State.AddUser("fred", "password")
189 c.Assert(err, gc.IsNil)189 c.Assert(err, gc.IsNil)
190190
@@ -204,7 +204,7 @@
204func (s *DeleteKeySuite) TestDeleteKeys(c *gc.C) {204func (s *DeleteKeySuite) TestDeleteKeys(c *gc.C) {
205 key1 := sshtesting.ValidKeyOne.Key + " user@host"205 key1 := sshtesting.ValidKeyOne.Key + " user@host"
206 key2 := sshtesting.ValidKeyTwo.Key + " another@host"206 key2 := sshtesting.ValidKeyTwo.Key + " another@host"
207 s.setAuthorisedKeys(c, key1, key2)207 s.setAuthorizedKeys(c, key1, key2)
208208
209 context, err := coretesting.RunCommand(209 context, err := coretesting.RunCommand(
210 c, &DeleteKeysCommand{}, []string{sshtesting.ValidKeyTwo.Fingerprint, "invalid-key"})210 c, &DeleteKeysCommand{}, []string{sshtesting.ValidKeyTwo.Fingerprint, "invalid-key"})
@@ -216,7 +216,7 @@
216func (s *DeleteKeySuite) TestDeleteKeyNonDefaultUser(c *gc.C) {216func (s *DeleteKeySuite) TestDeleteKeyNonDefaultUser(c *gc.C) {
217 key1 := sshtesting.ValidKeyOne.Key + " user@host"217 key1 := sshtesting.ValidKeyOne.Key + " user@host"
218 key2 := sshtesting.ValidKeyTwo.Key + " another@host"218 key2 := sshtesting.ValidKeyTwo.Key + " another@host"
219 s.setAuthorisedKeys(c, key1, key2)219 s.setAuthorizedKeys(c, key1, key2)
220 _, err := s.State.AddUser("fred", "password")220 _, err := s.State.AddUser("fred", "password")
221 c.Assert(err, gc.IsNil)221 c.Assert(err, gc.IsNil)
222222
@@ -240,7 +240,7 @@
240240
241func (s *ImportKeySuite) TestImportKeys(c *gc.C) {241func (s *ImportKeySuite) TestImportKeys(c *gc.C) {
242 key1 := sshtesting.ValidKeyOne.Key + " user@host"242 key1 := sshtesting.ValidKeyOne.Key + " user@host"
243 s.setAuthorisedKeys(c, key1)243 s.setAuthorizedKeys(c, key1)
244244
245 context, err := coretesting.RunCommand(c, &ImportKeysCommand{}, []string{"lp:validuser", "invalid-key"})245 context, err := coretesting.RunCommand(c, &ImportKeysCommand{}, []string{"lp:validuser", "invalid-key"})
246 c.Assert(err, gc.IsNil)246 c.Assert(err, gc.IsNil)
@@ -250,7 +250,7 @@
250250
251func (s *ImportKeySuite) TestImportKeyNonDefaultUser(c *gc.C) {251func (s *ImportKeySuite) TestImportKeyNonDefaultUser(c *gc.C) {
252 key1 := sshtesting.ValidKeyOne.Key + " user@host"252 key1 := sshtesting.ValidKeyOne.Key + " user@host"
253 s.setAuthorisedKeys(c, key1)253 s.setAuthorizedKeys(c, key1)
254 _, err := s.State.AddUser("fred", "password")254 _, err := s.State.AddUser("fred", "password")
255 c.Assert(err, gc.IsNil)255 c.Assert(err, gc.IsNil)
256256
257257
=== modified file 'cmd/juju/help_topics.go'
--- cmd/juju/help_topics.go 2014-03-17 20:03:47 +0000
+++ cmd/juju/help_topics.go 2014-04-25 11:00:53 +0000
@@ -50,14 +50,14 @@
50const helpLocalProvider = `50const helpLocalProvider = `
51The local provider is a Linux-only Juju environment that uses LXC containers as51The local provider is a Linux-only Juju environment that uses LXC containers as
52a virtual cloud on the local machine. Because of this, lxc and mongodb are52a virtual cloud on the local machine. Because of this, lxc and mongodb are
53required for the local provider to work. If you don't already have lxc and53required for the local provider to work. All of these dependencies are tracked
54mongodb installed, run the following commands:54in the 'juju-local' package. You can install that with:
5555
56 sudo apt-get update56 sudo apt-get update
57 sudo apt-get install lxc mongodb-server57 sudo apt-get install juju-local
5858
59After that you might get error for SSH authorized/public key not found. ERROR59After that you might get error for SSH authorised/public key not found. ERROR
60SSH authorized/public key not found.60SSH authorised/public key not found.
6161
62 ssh-keygen -t rsa62 ssh-keygen -t rsa
6363
6464
=== modified file 'cmd/juju/main.go'
--- cmd/juju/main.go 2014-03-26 13:40:28 +0000
+++ cmd/juju/main.go 2014-04-25 11:00:53 +0000
@@ -122,8 +122,8 @@
122 // Charm tool commands.122 // Charm tool commands.
123 jujucmd.Register(wrap(&HelpToolCommand{}))123 jujucmd.Register(wrap(&HelpToolCommand{}))
124124
125 // Manage authorised ssh keys.125 // Manage authorized ssh keys.
126 jujucmd.Register(wrap(NewAuthorisedKeysCommand()))126 jujucmd.Register(wrap(NewAuthorizedKeysCommand()))
127127
128 // Common commands.128 // Common commands.
129 jujucmd.Register(wrap(&cmd.VersionCommand{}))129 jujucmd.Register(wrap(&cmd.VersionCommand{}))
130130
=== modified file 'cmd/juju/main_test.go'
--- cmd/juju/main_test.go 2014-03-26 13:40:28 +0000
+++ cmd/juju/main_test.go 2014-04-25 11:00:53 +0000
@@ -213,7 +213,8 @@
213 "add-relation",213 "add-relation",
214 "add-unit",214 "add-unit",
215 "api-endpoints",215 "api-endpoints",
216 "authorised-keys",216 "authorised-keys", // alias for authorized-keys
217 "authorized-keys",
217 "bootstrap",218 "bootstrap",
218 "debug-hooks",219 "debug-hooks",
219 "debug-log",220 "debug-log",
220221
=== modified file 'cmd/supercommand.go'
--- cmd/supercommand.go 2014-03-20 06:01:50 +0000
+++ cmd/supercommand.go 2014-04-25 11:00:53 +0000
@@ -48,6 +48,7 @@
48 Doc string48 Doc string
49 Log *Log49 Log *Log
50 MissingCallback MissingCallback50 MissingCallback MissingCallback
51 Aliases []string
51}52}
5253
53// NewSuperCommand creates and initializes a new `SuperCommand`, and returns54// NewSuperCommand creates and initializes a new `SuperCommand`, and returns
@@ -59,7 +60,9 @@
59 Doc: params.Doc,60 Doc: params.Doc,
60 Log: params.Log,61 Log: params.Log,
61 usagePrefix: params.UsagePrefix,62 usagePrefix: params.UsagePrefix,
62 missingCallback: params.MissingCallback}63 missingCallback: params.MissingCallback,
64 Aliases: params.Aliases,
65 }
63 command.init()66 command.init()
64 return command67 return command
65}68}
@@ -74,6 +77,7 @@
74 Purpose string77 Purpose string
75 Doc string78 Doc string
76 Log *Log79 Log *Log
80 Aliases []string
77 usagePrefix string81 usagePrefix string
78 subcmds map[string]Command82 subcmds map[string]Command
79 commonflags *gnuflag.FlagSet83 commonflags *gnuflag.FlagSet
@@ -186,6 +190,7 @@
186 Args: "<command> ...",190 Args: "<command> ...",
187 Purpose: c.Purpose,191 Purpose: c.Purpose,
188 Doc: strings.Join(docParts, "\n\n"),192 Doc: strings.Join(docParts, "\n\n"),
193 Aliases: c.Aliases,
189 }194 }
190}195}
191196
192197
=== modified file 'cmd/supercommand_test.go'
--- cmd/supercommand_test.go 2014-03-20 09:12:53 +0000
+++ cmd/supercommand_test.go 2014-04-25 11:00:53 +0000
@@ -264,3 +264,26 @@
264 c.Assert(testing.Stdout(ctx), gc.Equals, "this is std out")264 c.Assert(testing.Stdout(ctx), gc.Equals, "this is std out")
265 c.Assert(testing.Stderr(ctx), gc.Equals, "this is std err")265 c.Assert(testing.Stderr(ctx), gc.Equals, "this is std err")
266}266}
267
268func (s *SuperCommandSuite) TestSupercommandAliases(c *gc.C) {
269 jc := cmd.NewSuperCommand(cmd.SuperCommandParams{
270 Name: "jujutest",
271 UsagePrefix: "juju",
272 })
273 sub := cmd.NewSuperCommand(cmd.SuperCommandParams{
274 Name: "jubar",
275 UsagePrefix: "juju jujutest",
276 Aliases: []string{"jubaz", "jubing"},
277 })
278 info := sub.Info()
279 c.Check(info.Aliases, gc.DeepEquals, []string{"jubaz", "jubing"})
280 jc.Register(sub)
281 for _, name := range []string{"jubar", "jubaz", "jubing"} {
282 c.Logf("testing command name %q", name)
283 ctx := testing.Context(c)
284 code := cmd.Main(jc, ctx, []string{name, "--help"})
285 c.Assert(code, gc.Equals, 0)
286 stripped := strings.Replace(bufferString(ctx.Stdout), "\n", "", -1)
287 c.Assert(stripped, gc.Matches, ".*usage: juju jujutest jubar.*aliases: jubaz, jubing")
288 }
289}

Subscribers

People subscribed via source and target branches

to all changes: