...
1
2
3 package integration
4
5 import (
6 "fmt"
7 "os"
8 "os/exec"
9 "testing"
10
11 "github.com/eggsampler/acme/v3"
12 _ "github.com/go-sql-driver/mysql"
13 "github.com/letsencrypt/boulder/test"
14 )
15
16 func TestAdminClearEmail(t *testing.T) {
17 t.Parallel()
18 os.Setenv("DIRECTORY", "http://boulder.service.consul:4001/directory")
19
20
21
22
23 client1, err := makeClient("mailto:example@mail.example.letsencrypt.org", "mailto:long-example@mail.example.letsencrypt.org", "mailto:third-example@mail.example.letsencrypt.org")
24 test.AssertNotError(t, err, "creating first acme client")
25
26 client2, err := makeClient("mailto:example@mail.example.letsencrypt.org")
27 test.AssertNotError(t, err, "creating second acme client")
28
29 client3, err := makeClient("mailto:other@mail.example.letsencrypt.org")
30 test.AssertNotError(t, err, "creating second acme client")
31
32 deleteMe := "example@mail.example.letsencrypt.org"
33 config := fmt.Sprintf("%s/%s", os.Getenv("BOULDER_CONFIG_DIR"), "admin-revoker.json")
34 cmd := exec.Command("./bin/admin", "clear-email",
35 "-config", config,
36 deleteMe)
37 output, err := cmd.CombinedOutput()
38 test.AssertNotError(t, err, fmt.Sprintf("clearing email via admin tool (%s): %s", cmd, string(output)))
39 t.Logf("clear-email output: %s\n", string(output))
40
41 updatedAccount1, err := client1.NewAccountOptions(client1.PrivateKey, acme.NewAcctOptOnlyReturnExisting())
42 test.AssertNotError(t, err, "fetching updated account for first client")
43
44 t.Log(updatedAccount1.Contact)
45 test.AssertDeepEquals(t, updatedAccount1.Contact,
46 []string{"mailto:long-example@mail.example.letsencrypt.org", "mailto:third-example@mail.example.letsencrypt.org"})
47
48 updatedAccount2, err := client2.NewAccountOptions(client2.PrivateKey, acme.NewAcctOptOnlyReturnExisting())
49 test.AssertNotError(t, err, "fetching updated account for second client")
50 test.AssertDeepEquals(t, updatedAccount2.Contact, []string(nil))
51
52 updatedAccount3, err := client3.NewAccountOptions(client3.PrivateKey, acme.NewAcctOptOnlyReturnExisting())
53 test.AssertNotError(t, err, "fetching updated account for third client")
54 test.AssertDeepEquals(t, updatedAccount3.Contact, []string{"mailto:other@mail.example.letsencrypt.org"})
55 }
56
View as plain text