func TestAuth(t *testing.T) { debug = testing.Verbose() // Do it a few times... for i := 0; i < 3; i++ { c1, c2 := ch.NewPipePair(5) ec := make(chan error, 1) go func() { _, err := AtClient(c1, "", "foo") ec <- err }() if _, err := AtServer(c2, "", "foo"); err != nil { t.Fatal(err) } if err := <-ec; err != nil { t.Fatal(err) } c1.Out <- []byte("hi") c2.Out <- []byte("there") d := string((<-c2.In).([]byte)) if string(d) != "hi" { t.Fatal("bad msg") } d = string((<-c1.In).([]byte)) if string(d) != "there" { t.Fatal("bad msg") } } }
func TestBadAuth(t *testing.T) { debug = testing.Verbose() c1, c2 := ch.NewPipePair(5) go func() { var nb [8]byte binary.LittleEndian.PutUint64(nb[0:], 33) c1.Out <- nb[:] c1.Out <- nb[:] }() _, err := AtClient(c2, "", "foo") if err == nil { t.Fatal("didn't fail") } printf("err is %v\n", err) if cerror(c2.In) == nil || cerror(c2.Out) == nil { t.Fatal("chans are ok") } }