Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions acme/api/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ func NewAccount(w http.ResponseWriter, r *http.Request) {
return
}

if prov.TermsOfService != "" && !nar.TermsOfServiceAgreed {
render.Error(w, r, acme.NewError(acme.ErrorUserActionRequiredType,
"terms of service must be agreed to: %s", prov.TermsOfService))
return
}

jwk, err := jwkFromContext(ctx)
if err != nil {
render.Error(w, r, err)
Expand Down
17 changes: 17 additions & 0 deletions acme/api/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,23 @@ func TestHandler_NewAccount(t *testing.T) {
err: acme.NewError(acme.ErrorAccountDoesNotExistType, "account does not exist"),
}
},
"fail/terms-of-service-not-agreed": func(t *testing.T) test {
nar := &NewAccountRequest{
Contact: []string{"foo", "bar"},
}
b, err := json.Marshal(nar)
assert.FatalError(t, err)
p := newACMEProv(t)
p.TermsOfService = "https://terms.ca.local/"
ctx := context.WithValue(context.Background(), payloadContextKey, &payloadInfo{value: b})
ctx = acme.NewProvisionerContext(ctx, p)
return test{
db: &acme.MockDB{},
ctx: ctx,
statusCode: 400,
err: acme.NewError(acme.ErrorUserActionRequiredType, "terms of service must be agreed to: https://terms.ca.local/"),
}
},
"fail/no-jwk": func(t *testing.T) test {
nar := &NewAccountRequest{
Contact: []string{"foo", "bar"},
Expand Down
Loading