(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestHTTPGetIndex(t *testing.T) { |
| 25 | p := startInstance(t, 2) |
| 26 | defer checkedStop(t, p) |
| 27 | |
| 28 | // Check for explicit index.html |
| 29 | |
| 30 | res, err := http.Get("http://localhost:8082/index.html") |
| 31 | if err != nil { |
| 32 | t.Fatal(err) |
| 33 | } |
| 34 | if res.StatusCode != 200 { |
| 35 | t.Errorf("Status %d != 200", res.StatusCode) |
| 36 | } |
| 37 | bs, err := io.ReadAll(res.Body) |
| 38 | if err != nil { |
| 39 | t.Fatal(err) |
| 40 | } |
| 41 | if len(bs) < 1024 { |
| 42 | t.Errorf("Length %d < 1024", len(bs)) |
| 43 | } |
| 44 | if !bytes.Contains(bs, []byte("</html>")) { |
| 45 | t.Error("Incorrect response") |
| 46 | } |
| 47 | if res.Header.Get("Set-Cookie") == "" { |
| 48 | t.Error("No set-cookie header") |
| 49 | } |
| 50 | res.Body.Close() |
| 51 | |
| 52 | // Check for implicit index.html |
| 53 | |
| 54 | res, err = http.Get("http://localhost:8082/") |
| 55 | if err != nil { |
| 56 | t.Fatal(err) |
| 57 | } |
| 58 | if res.StatusCode != 200 { |
| 59 | t.Errorf("Status %d != 200", res.StatusCode) |
| 60 | } |
| 61 | bs, err = io.ReadAll(res.Body) |
| 62 | if err != nil { |
| 63 | t.Fatal(err) |
| 64 | } |
| 65 | if len(bs) < 1024 { |
| 66 | t.Errorf("Length %d < 1024", len(bs)) |
| 67 | } |
| 68 | if !bytes.Contains(bs, []byte("</html>")) { |
| 69 | t.Error("Incorrect response") |
| 70 | } |
| 71 | if res.Header.Get("Set-Cookie") == "" { |
| 72 | t.Error("No set-cookie header") |
| 73 | } |
| 74 | res.Body.Close() |
| 75 | } |
| 76 | |
| 77 | func TestHTTPGetIndexAuth(t *testing.T) { |
| 78 | p := startInstance(t, 1) |
nothing calls this directly
no test coverage detected