...
1
2
3 package integration
4
5 import (
6 "io"
7 "net/http"
8 "testing"
9
10 "github.com/letsencrypt/boulder/test"
11 )
12
13
14
15
16 func TestWFECORS(t *testing.T) {
17
18
19 getReq, _ := http.NewRequest("GET", "http://boulder.service.consul:4001/directory", nil)
20 getReq.Header.Set("Origin", "*")
21
22
23 client := &http.Client{}
24 resp, err := client.Do(getReq)
25 test.AssertNotError(t, err, "GET directory")
26 test.AssertEquals(t, resp.StatusCode, http.StatusOK)
27
28
29
30 corsAllowOrigin := resp.Header.Get("Access-Control-Allow-Origin")
31 test.AssertEquals(t, corsAllowOrigin, "*")
32 }
33
34
35
36
37
38 func TestWFEHTTPMetrics(t *testing.T) {
39
40 resp, err := http.Get("http://boulder.service.consul:4001/directory")
41 test.AssertNotError(t, err, "GET boulder-wfe2 directory")
42 test.AssertEquals(t, resp.StatusCode, http.StatusOK)
43 resp.Body.Close()
44
45 resp, err = http.Get("http://boulder.service.consul:8013/metrics")
46 test.AssertNotError(t, err, "GET boulder-wfe2 metrics")
47 test.AssertEquals(t, resp.StatusCode, http.StatusOK)
48 body, err := io.ReadAll(resp.Body)
49 test.AssertNotError(t, err, "Reading boulder-wfe2 metrics response")
50 test.AssertContains(t, string(body), `response_time_count{code="200",endpoint="/directory",method="GET"}`)
51 resp.Body.Close()
52 }
53
View as plain text