Skip to content

Commit 5527716

Browse files
authored
Port v1 integration tests to v2. (letsencrypt#4807)
As of this change, each test case in v1_integration.py has an equivalent in v2_integration.py. This mostly involved copying the test cases and tweaking them to use chisel2.py. I had to add support for updating email addresses in chisel2.py (copied from chisel.py) in order to support one of the test cases. The VA was not yet configured to recognize account paths that start with the ACMEv2 path, so I added that configuration. The most useful way to see what's changed in porting the test cases is to check out this branch and then do a diff between v1_integration.py and v2_integration.py.
1 parent 57ee154 commit 5527716

File tree

8 files changed

+400
-10
lines changed

8 files changed

+400
-10
lines changed

test.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ if [[ "$RUN" =~ "integration" ]] ; then
101101
args+=("--filter" "${INT_FILTER}")
102102
fi
103103

104-
DIRECTORY=http://boulder:4000/directory \
105-
python3 test/integration-test.py --chisel --gotest "${args[@]}"
104+
python3 test/integration-test.py --chisel --gotest "${args[@]}"
106105
fi
107106

108107
# Test that just ./start.py works, which is a proxy for testing that

test/chisel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
logging.basicConfig()
3838
logger.setLevel(int(os.getenv('LOGLEVEL', 20)))
3939

40-
DIRECTORY = os.getenv('DIRECTORY', 'http://localhost:4000/directory')
40+
DIRECTORY = os.getenv('DIRECTORY', 'http://boulder:4000/directory')
4141

4242
os.environ.setdefault('REQUESTS_CA_BUNDLE', 'test/wfe-tls/minica.pem')
4343

test/chisel2.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
logger = logging.getLogger()
3636
logger.setLevel(int(os.getenv('LOGLEVEL', 20)))
3737

38-
DIRECTORY_V2 = os.getenv('DIRECTORY_V2', 'http://localhost:4001/directory')
38+
DIRECTORY_V2 = os.getenv('DIRECTORY_V2', 'http://boulder:4001/directory')
3939
ACCEPTABLE_TOS = os.getenv('ACCEPTABLE_TOS',"https://boulder:4431/terms/v7")
4040
PORT = os.getenv('PORT', '5002')
4141

@@ -62,6 +62,34 @@ def make_client(email=None):
6262
raise Exception("Unrecognized terms of service URL %s" % tos)
6363
return client
6464

65+
class NoClientError(ValueError):
66+
"""
67+
An error that occurs when no acme.Client is provided to a function that
68+
requires one.
69+
"""
70+
pass
71+
72+
class EmailRequiredError(ValueError):
73+
"""
74+
An error that occurs when a None email is provided to update_email.
75+
"""
76+
77+
def update_email(client, email):
78+
"""
79+
Use a provided acme.Client to update the client's account to the specified
80+
email.
81+
"""
82+
if client is None:
83+
raise(NoClientError("update_email requires a valid acme.Client argument"))
84+
if email is None:
85+
raise(EmailRequiredError("update_email requires an email argument"))
86+
if not email.startswith("mailto:"):
87+
email = "mailto:"+ email
88+
acct = client.net.account
89+
updatedAcct = acct.update(body=acct.body.update(contact=(email,)))
90+
return client.update_registration(updatedAcct)
91+
92+
6593
def get_chall(authz, typ):
6694
for chall_body in authz.body.challenges:
6795
if isinstance(chall_body.chall, typ):
@@ -103,6 +131,9 @@ def auth_and_issue(domains, chall_type="dns-01", email=None, cert_output=None, c
103131

104132
try:
105133
order = client.poll_and_finalize(order)
134+
if cert_output is not None:
135+
with open(cert_output, "w") as f:
136+
f.write(order.fullchain_pem)
106137
finally:
107138
cleanup()
108139

@@ -171,7 +202,7 @@ def expect_problem(problem_type, func):
171202
if e.typ == problem_type:
172203
ok = True
173204
else:
174-
raise Exception("Expected %s, got %s" % (problem_type, error.__str__()))
205+
raise Exception("Expected %s, got %s" % (problem_type, e.__str__()))
175206
except acme_errors.ValidationError as e:
176207
for authzr in e.failed_authzrs:
177208
for chall in authzr.body.challenges:

test/config-next/va-remote-a.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"CAAAccountURI": true
3131
},
3232
"accountURIPrefixes": [
33-
"http://boulder:4000/acme/reg/"
33+
"http://boulder:4000/acme/reg/",
34+
"http://boulder:4001/acme/acct/"
3435
]
3536
},
3637

test/config-next/va-remote-b.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"CAAAccountURI": true
3131
},
3232
"accountURIPrefixes": [
33-
"http://boulder:4000/acme/reg/"
33+
"http://boulder:4000/acme/reg/",
34+
"http://boulder:4001/acme/acct/"
3435
]
3536
},
3637

test/config-next/va.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"maxRemoteValidationFailures": 1,
4545
"multiVAPolicyFile": "test/example-multiva-policy.yaml",
4646
"accountURIPrefixes": [
47-
"http://boulder:4000/acme/reg/"
47+
"http://boulder:4000/acme/reg/",
48+
"http://boulder:4001/acme/acct/"
4849
]
4950
},
5051

test/config/va.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"features": {
2929
},
3030
"accountURIPrefixes": [
31-
"http://boulder:4000/acme/reg/"
31+
"http://boulder:4000/acme/reg/",
32+
"http://boulder:4001/acme/acct/"
3233
]
3334
},
3435

0 commit comments

Comments
 (0)