tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit 0ba25233d58c34d9c68993f11c9ca302a959e15c
parent 43eb442184673b5e515cd0b300647a528365f1b3
Author: parazyd <parazyd@dyne.org>
Date:   Tue, 12 Dec 2017 01:43:27 +0100

Add incomplete test for invalid second handshake.

Diffstat:
Mcmd/dam-dir/main_test.go | 37+++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/cmd/dam-dir/main_test.go b/cmd/dam-dir/main_test.go @@ -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) @@ -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) @@ -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}