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

Unified Diff: state/api/keymanager/client_test.go

Issue 68990043: System SSH key upgrader (Closed)
Patch Set: System SSH key upgrader Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « state/api/apiclient.go ('k') | state/api/params/internal.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: state/api/keymanager/client_test.go
=== modified file 'state/api/keymanager/client_test.go'
--- state/api/keymanager/client_test.go 2013-12-13 05:46:37 +0000
+++ state/api/keymanager/client_test.go 2014-02-27 03:17:45 +0000
@@ -9,6 +9,7 @@
gc "launchpad.net/gocheck"
jujutesting "launchpad.net/juju-core/juju/testing"
+ "launchpad.net/juju-core/state"
"launchpad.net/juju-core/state/api/keymanager"
"launchpad.net/juju-core/state/api/params"
keymanagerserver "launchpad.net/juju-core/state/apiserver/keymanager"
@@ -89,6 +90,33 @@
s.assertEnvironKeys(c, append([]string{key1}, newKeys[:2]...))
}
+func (s *keymanagerSuite) TestAddSystemKey(c *gc.C) {
+ key1 := sshtesting.ValidKeyOne.Key + " user@host"
+ s.setAuthorisedKeys(c, key1)
+
+ apiState, _ := s.OpenAPIAsNewMachine(c, state.JobManageEnviron)
+ keyManager := keymanager.NewClient(apiState)
+ newKey := sshtesting.ValidKeyTwo.Key
+ errResults, err := keyManager.AddKeys("juju-system-key", newKey)
+ c.Assert(err, gc.IsNil)
+ c.Assert(errResults, gc.DeepEquals, []params.ErrorResult{
+ {Error: nil},
+ })
+ s.assertEnvironKeys(c, []string{key1, newKey})
+}
+
+func (s *keymanagerSuite) TestAddSystemKeyWrongUser(c *gc.C) {
+ key1 := sshtesting.ValidKeyOne.Key + " user@host"
+ s.setAuthorisedKeys(c, key1)
+
+ apiState, _ := s.OpenAPIAsNewMachine(c, state.JobManageEnviron)
+ keyManager := keymanager.NewClient(apiState)
+ newKey := sshtesting.ValidKeyTwo.Key
+ _, err := keyManager.AddKeys("some-user", newKey)
+ c.Assert(err, gc.ErrorMatches, "permission denied")
+ s.assertEnvironKeys(c, []string{key1})
+}
+
func (s *keymanagerSuite) TestDeleteKeys(c *gc.C) {
key1 := sshtesting.ValidKeyOne.Key + " user@host"
key2 := sshtesting.ValidKeyTwo.Key
« no previous file with comments | « state/api/apiclient.go ('k') | state/api/params/internal.go » ('j') | no next file with comments »

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