| func TestNewPersistentPrincipal(t *testing.T) { |
| // Persistence of the BlessingRoots and BlessingStore objects is |
| // tested in other files. Here just test the persistence of the key. |
| dir, err := ioutil.TempDir("", "TestNewPersistentPrincipal") |
| p, existed, err := NewPersistentPrincipal(dir) |
| t.Fatalf("%q already has data", existed) |
| message := []byte("this is a test message") |
| sig, err := p.Sign(message) |
| p2, _, err := NewPersistentPrincipal(dir) |
| if !sig.Verify(p2.PublicKey(), message) { |
| t.Errorf("p.PublicKey=%v, p2.PublicKey=%v", p.PublicKey(), p2.PublicKey()) |