1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add key migration integration test

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2015-01-22 10:51:04 -08:00
parent a34a7930b5
commit 42612ff6db

View file

@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
@ -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")
}