|
|
@@ -65,3 +65,18 @@ func TestPrintRelaysReportsErrorsAsText(t *testing.T) {
|
|
|
delete(hm.Relays, 1)
|
|
|
assert.Contains(t, marshal(), `"Error":"hostmap LocalIndex '7' does not match RelayState LocalIndex"`)
|
|
|
}
|
|
|
+
|
|
|
+// TestPrintCertOfATunnelWithoutACertificate: a tunnel still handshaking, or one being
|
|
|
+// torn down, has no certificate, and print-cert refuses rather than panicking.
|
|
|
+func TestPrintCertOfATunnelWithoutACertificate(t *testing.T) {
|
|
|
+ f, _ := identityFixture(t)
|
|
|
+
|
|
|
+ r, err := runPrintCert(f, &printCertFlags{}, []string{"10.0.0.3"})
|
|
|
+ require.NoError(t, err)
|
|
|
+ assert.False(t, r.OK)
|
|
|
+ assert.Equal(t, "Could not find tunnel for vpn addr: 10.0.0.3", r.Reason)
|
|
|
+
|
|
|
+ r, err = runPrintCert(f, &printCertFlags{}, []string{"10.0.0.2"})
|
|
|
+ require.NoError(t, err)
|
|
|
+ assert.True(t, r.OK, "a tunnel with a certificate is printed")
|
|
|
+}
|