...
1
2
3 package integration
4
5 import (
6 "bytes"
7 "os"
8 "os/exec"
9 "strings"
10 "testing"
11
12 "github.com/letsencrypt/boulder/test"
13 )
14
15 func TestCAALogChecker(t *testing.T) {
16 t.Parallel()
17
18 c, err := makeClient()
19 test.AssertNotError(t, err, "makeClient failed")
20
21 domains := []string{random_domain()}
22 result, err := authAndIssue(c, nil, domains, true)
23 test.AssertNotError(t, err, "authAndIssue failed")
24 test.AssertEquals(t, result.Order.Status, "valid")
25 test.AssertEquals(t, len(result.Order.Authorizations), 1)
26
27
28 cmd := exec.Command("bin/boulder", "caa-log-checker", "-ra-log", "/var/log/boulder-ra.log", "-va-logs", "/var/log/boulder-va.log")
29 stdErr := new(bytes.Buffer)
30 cmd.Stderr = stdErr
31 out, err := cmd.Output()
32 numLines := strings.Split(string(bytes.TrimSpace(out)), "\n")
33 test.AssertEquals(t, len(numLines), 1)
34 test.AssertContains(t, string(out), "Versions: caa-log-checker=(Unspecified Unspecified) Golang=(")
35 test.AssertEquals(t, stdErr.String(), "")
36 test.AssertNotError(t, err, "caa-log-checker failed")
37
38
39
40
41
42
43 tmp, err := os.CreateTemp(os.TempDir(), "boulder-va-empty")
44 test.AssertNotError(t, err, "failed to create temporary file")
45 defer os.Remove(tmp.Name())
46 cmd = exec.Command("bin/boulder", "caa-log-checker", "-ra-log", "/var/log/boulder-ra.log", "-va-logs", tmp.Name())
47 stdErr = new(bytes.Buffer)
48 cmd.Stderr = stdErr
49 out, err = cmd.Output()
50 test.AssertError(t, err, "caa-log-checker didn't fail")
51
52 if stdErr.String() == "" || string(out) == "" {
53 t.Errorf("expected caa-log-checker to emit an error on stderr and an info log on stdout. Stdout:\n%s\n\nStderr:\n%s",
54 string(out), stdErr)
55 }
56 }
57
View as plain text