diff --git a/client/client_test.go b/client/client_test.go index bdee339040..897969af8a 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -2554,7 +2554,7 @@ func TestRotateKeyInvalidRole(t *testing.T) { repo, _ := initializeRepo(t, data.ECDSAKey, "docker.com/notary", ts.URL, false) defer os.RemoveAll(repo.baseDir) - // the equivalent of: remotely remotely rotating the root key + // the equivalent of: remotely rotating the root key // (RotateKey("root", true)), locally rotating the root key (RotateKey("root", false)), // locally rotating the timestamp key (RotateKey("timestamp", false)), // and remotely rotating the targets key (RotateKey(targets, true)), all of which should diff --git a/cmd/notary/keys.go b/cmd/notary/keys.go index f4df2c7082..f4debba3bf 100644 --- a/cmd/notary/keys.go +++ b/cmd/notary/keys.go @@ -430,7 +430,11 @@ func (k *keyCommander) keysRotate(cmd *cobra.Command, args []string) error { if err != nil { return err } - return nRepo.RotateKey(rotateKeyRole, k.rotateKeyServerManaged) + err = nRepo.RotateKey(rotateKeyRole, k.rotateKeyServerManaged) + if err == nil && k.rotateKeyServerManaged { + err = nRepo.Publish() + } + return err } func removeKeyInteractively(keyStores []trustmanager.KeyStore, keyID string, diff --git a/cmd/notary/keys_test.go b/cmd/notary/keys_test.go index 62d1c0b90d..6e61b9aaca 100644 --- a/cmd/notary/keys_test.go +++ b/cmd/notary/keys_test.go @@ -366,9 +366,7 @@ func TestRotateKeyRemoteServerManagesKey(t *testing.T) { cl, err := repo.GetChangelist() assert.NoError(t, err, "unable to get changelist: %v", err) - assert.Len(t, cl.List(), 1, "expected a single key rotation change") - - assert.NoError(t, repo.Publish()) + assert.Len(t, cl.List(), 0, "expected the changes to have been published") finalKeys := repo.CryptoService.ListAllKeys() assert.Len(t, initialKeys, 3)