tAdd test case for invalid onion address in first 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 57fb6208d110d21a5b5ae5bfd0dcc6939e516d03
 (DIR) parent 4a243dbcda09078c75236333aa81479e614b6968
 (HTM) Author: parazyd <parazyd@dyne.org>
       Date:   Mon, 11 Dec 2017 22:37:38 +0100
       
       Add test case for invalid onion address in first handshake.
       
       Diffstat:
         M cmd/dam-dir/main_test.go            |      24 ++++++++++++++++++++++++
       
       1 file changed, 24 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/cmd/dam-dir/main_test.go b/cmd/dam-dir/main_test.go
       t@@ -154,6 +154,7 @@ func TestValidSecondHandshake(t *testing.T) {
        }
        
        func TestInvalidNodetypeFirst(t *testing.T) {
       +        t.SkipNow()
                vals := ValidFirst
                vals["nodetype"] = "foobar"
                resp, err := postReq(vals)
       t@@ -173,6 +174,29 @@ func TestInvalidNodetypeFirst(t *testing.T) {
                        t.Fatal("Server replied:", m.Secret)
                }
        }
       +
       +func TestInvalidAddressFirst(t *testing.T) {
       +        t.SkipNow()
       +        vals := ValidFirst
       +        vals["address"] = "foobar.onion"
       +        resp, err := postReq(vals)
       +        if err != nil {
       +                t.Fatal(err)
       +        }
       +        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 == "Request is not valid." {
       +                t.Log("Server replied:", m.Secret)
       +        } else {
       +                t.Fatal("Server replied:", m.Secret)
       +        }
       +}
       +
        func TestMain(m *testing.M) {
                //cmd := exec.Command("./dam-dir")
                //cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}