tAdd incomplete test for invalid second handshake. - tordam - A library for peer discovery inside the Tor network (HTM) git clone https://git.parazyd.org/tordam (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 0ba25233d58c34d9c68993f11c9ca302a959e15c (DIR) parent 43eb442184673b5e515cd0b300647a528365f1b3 (HTM) Author: parazyd <parazyd@dyne.org> Date: Tue, 12 Dec 2017 01:43:27 +0100 Add incomplete test for invalid second handshake. Diffstat: M cmd/dam-dir/main_test.go | 37 +++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) --- (DIR) diff --git a/cmd/dam-dir/main_test.go b/cmd/dam-dir/main_test.go t@@ -61,7 +61,7 @@ func firstAnnValid() (*http.Response, error) { } func TestValidFirstHandshake(t *testing.T) { - t.SkipNow() + //t.SkipNow() resp, err := firstAnnValid() if err != nil { t.Fatal(err) t@@ -92,7 +92,7 @@ func TestValidFirstHandshake(t *testing.T) { } func TestValidSecondHandshake(t *testing.T) { - t.SkipNow() + //t.SkipNow() resp, err := firstAnnValid() if err != nil { t.Fatal(err) t@@ -243,6 +243,39 @@ func TestInvalidSignatureFirst(t *testing.T) { } } +func TestInvalidSecond(t *testing.T) { + t.SkipNow() + // Try to jump in the second handshake without doing the first. + // The values below are valid. + vals := ValidFirst + vals["message"] = "ZShhYHYsRGNLOTZ6YUwwP3ZXPnxhQiR9UFVWfmk5TG56TEtLb04vMms+OTIrLlQ7aS4rflR3V041RG5Je0tnYw==" + vals["secret"] = "ZShhYHYsRGNLOTZ6YUwwP3ZXPnxhQiR9UFVWfmk5TG56TEtLb04vMms+OTIrLlQ7aS4rflR3V041RG5Je0tnYw==" + vals["signature"] = "L1N+VEi3T3aZaYksAy1+0UMoYn7B3Gapfk0dJzOUxUtUYVhj84TgfYeDnADNYrt5UK9hN/lCTIhsM6zPO7mSjQI43l3dKvMIikqQDwNey/XaokyPI4/oKrMoGQnu8E8UmHmI1pFvwdO5EQQaKbi90qWNj93KB/NlTwqD9Ir4blY=" + resp, err := postReq(vals) + if err != nil { + t.Fatal(err) + } + if resp.StatusCode == 500 { + // Couldn't get a descriptor. + m, err := getRespText(resp) + if err != nil { + t.Fatal(err) + } + t.Skipf("Server replied: %s\n", m.Secret) + } else if resp.StatusCode != 400 { + // t.Fatal("Server did not respond with HTTP 400") + } + + m, err := getRespText(resp) + if err != nil { + t.Fatal(err) + } + if m.Secret != "Verification Failed. Bye." { + t.Fatal("Server replied:", m.Secret) + } + t.Log("Server replied:", m.Secret) +} + func TestMain(m *testing.M) { //cmd := exec.Command("./dam-dir") //cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}