Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11)

Delta Between Two Patch Sets: cmd/juju/authorisedkeys_test.go

Issue 70190050: Update and Validate Environ Config in State
Left Patch Set: Update and validate environ config in state Created 11 years, 1 month ago
Right Patch Set: Update and Validate Environ Config in State Created 11 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « [revision details] ('k') | cmd/juju/environment.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package main 4 package main
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 "strings" 8 "strings"
9 9
10 gc "launchpad.net/gocheck" 10 gc "launchpad.net/gocheck"
11 11
12 "launchpad.net/juju-core/juju/osenv" 12 "launchpad.net/juju-core/juju/osenv"
13 jujutesting "launchpad.net/juju-core/juju/testing" 13 jujutesting "launchpad.net/juju-core/juju/testing"
14 keymanagerserver "launchpad.net/juju-core/state/apiserver/keymanager" 14 keymanagerserver "launchpad.net/juju-core/state/apiserver/keymanager"
15 keymanagertesting "launchpad.net/juju-core/state/apiserver/keymanager/te sting" 15 keymanagertesting "launchpad.net/juju-core/state/apiserver/keymanager/te sting"
16 statetesting "launchpad.net/juju-core/state/testing"
17 coretesting "launchpad.net/juju-core/testing" 16 coretesting "launchpad.net/juju-core/testing"
18 "launchpad.net/juju-core/testing/testbase" 17 "launchpad.net/juju-core/testing/testbase"
19 sshtesting "launchpad.net/juju-core/utils/ssh/testing" 18 sshtesting "launchpad.net/juju-core/utils/ssh/testing"
20 ) 19 )
21 20
22 type AuthorisedKeysSuite struct { 21 type AuthorisedKeysSuite struct {
23 testbase.LoggingSuite 22 testbase.LoggingSuite
24 jujuHome *coretesting.FakeHome 23 jujuHome *coretesting.FakeHome
25 } 24 }
26 25
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 jujutesting.JujuConnSuite 95 jujutesting.JujuConnSuite
97 } 96 }
98 97
99 func (s *keySuiteBase) SetUpSuite(c *gc.C) { 98 func (s *keySuiteBase) SetUpSuite(c *gc.C) {
100 s.JujuConnSuite.SetUpSuite(c) 99 s.JujuConnSuite.SetUpSuite(c)
101 s.PatchEnvironment(osenv.JujuEnvEnvKey, "dummyenv") 100 s.PatchEnvironment(osenv.JujuEnvEnvKey, "dummyenv")
102 } 101 }
103 102
104 func (s *keySuiteBase) setAuthorisedKeys(c *gc.C, keys ...string) { 103 func (s *keySuiteBase) setAuthorisedKeys(c *gc.C, keys ...string) {
105 keyString := strings.Join(keys, "\n") 104 keyString := strings.Join(keys, "\n")
106 » err := statetesting.UpdateConfig(s.State, map[string]interface{}{"author ized-keys": keyString}) 105 » err := s.State.UpdateEnvironConfig(map[string]interface{}{"authorized-ke ys": keyString}, nil, nil)
107 c.Assert(err, gc.IsNil) 106 c.Assert(err, gc.IsNil)
108 envConfig, err := s.State.EnvironConfig() 107 envConfig, err := s.State.EnvironConfig()
109 c.Assert(err, gc.IsNil) 108 c.Assert(err, gc.IsNil)
110 c.Assert(envConfig.AuthorizedKeys(), gc.Equals, keyString) 109 c.Assert(envConfig.AuthorizedKeys(), gc.Equals, keyString)
111 } 110 }
112 111
113 func (s *keySuiteBase) assertEnvironKeys(c *gc.C, expected ...string) { 112 func (s *keySuiteBase) assertEnvironKeys(c *gc.C, expected ...string) {
114 envConfig, err := s.State.EnvironConfig() 113 envConfig, err := s.State.EnvironConfig()
115 c.Assert(err, gc.IsNil) 114 c.Assert(err, gc.IsNil)
116 keys := envConfig.AuthorizedKeys() 115 keys := envConfig.AuthorizedKeys()
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 key1 := sshtesting.ValidKeyOne.Key + " user@host" 252 key1 := sshtesting.ValidKeyOne.Key + " user@host"
254 s.setAuthorisedKeys(c, key1) 253 s.setAuthorisedKeys(c, key1)
255 _, err := s.State.AddUser("fred", "password") 254 _, err := s.State.AddUser("fred", "password")
256 c.Assert(err, gc.IsNil) 255 c.Assert(err, gc.IsNil)
257 256
258 context, err := coretesting.RunCommand(c, &ImportKeysCommand{}, []string {"--user", "fred", "lp:validuser"}) 257 context, err := coretesting.RunCommand(c, &ImportKeysCommand{}, []string {"--user", "fred", "lp:validuser"})
259 c.Assert(err, gc.IsNil) 258 c.Assert(err, gc.IsNil)
260 c.Assert(coretesting.Stderr(context), gc.Equals, "") 259 c.Assert(coretesting.Stderr(context), gc.Equals, "")
261 s.assertEnvironKeys(c, key1, sshtesting.ValidKeyThree.Key) 260 s.assertEnvironKeys(c, key1, sshtesting.ValidKeyThree.Key)
262 } 261 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b