Skip to content

Commit

Permalink
Add key migration integration test
Browse files Browse the repository at this point in the history
Signed-off-by: Derek McGowan <[email protected]> (github: dmcgowan)
  • Loading branch information
dmcgowan committed Jan 22, 2015
1 parent a34a793 commit 42612ff
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"

Expand Down Expand Up @@ -374,3 +375,31 @@ func TestDaemonKeyGeneration(t *testing.T) {

logDone("daemon - key generation")
}

func TestDaemonKeyMigration(t *testing.T) {
// TODO: skip or update for Windows daemon
os.Remove("/etc/docker/key.json")
k1, err := libtrust.GenerateECP256PrivateKey()
if err != nil {
t.Fatalf("Error generating private key: %s", err)
}
if err := libtrust.SaveKey(filepath.Join(os.Getenv("HOME"), ".docker", "key.json"), k1); err != nil {
t.Fatalf("Error saving private key: %s", err)
}

d := NewDaemon(t)
if err := d.Start(); err != nil {
t.Fatalf("Could not start daemon: %v", err)
}
d.Stop()

k2, err := libtrust.LoadKeyFile("/etc/docker/key.json")
if err != nil {
t.Fatalf("Error opening key file")
}
if k1.KeyID() != k2.KeyID() {
t.Fatalf("Key not migrated")
}

logDone("daemon - key migration")
}

0 comments on commit 42612ff

Please sign in to comment.