-
-
Notifications
You must be signed in to change notification settings - Fork 611
Confine contact addresses to the WFE #8245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
25043f8
Ignore contact field of account-update requests
aarongable 20bb35e
Mostly ignore contact field of new-account requests
aarongable a27296e
RA: add TODOs
aarongable fb31ed6
Update integration tests
aarongable a0eac53
Validate contact addresses in the WFE before account creation
aarongable a47fd5a
Appease typocheck
aarongable 13ce1ed
Allow max contacts per reg to be configured, and enforce it
aarongable 77500bd
Add unit tests
aarongable 44d4347
Fix typo
aarongable File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ import ( | |
"fmt" | ||
"io" | ||
"net/http" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/eggsampler/acme/v3" | ||
|
@@ -39,126 +38,6 @@ func TestTooBigOrderError(t *testing.T) { | |
test.AssertContains(t, prob.Detail, "Order cannot contain more than 100 identifiers") | ||
} | ||
|
||
// TestAccountEmailError tests that registering a new account, or updating an | ||
// account, with invalid contact information produces the expected problem | ||
// result to ACME clients. | ||
func TestAccountEmailError(t *testing.T) { | ||
t.Parallel() | ||
|
||
// The registrations.contact field is VARCHAR(191). 175 'a' characters plus | ||
// the prefix "mailto:" and the suffix "@a.com" makes exactly 191 bytes of | ||
// encoded JSON. The correct size to hit our maximum DB field length. | ||
var longStringBuf strings.Builder | ||
longStringBuf.WriteString("mailto:") | ||
for range 175 { | ||
longStringBuf.WriteRune('a') | ||
} | ||
longStringBuf.WriteString("@a.com") | ||
|
||
createErrorPrefix := "Error creating new account :: " | ||
updateErrorPrefix := "Unable to update account :: invalid contact: " | ||
|
||
testCases := []struct { | ||
name string | ||
contacts []string | ||
expectedProbType string | ||
expectedProbDetail string | ||
}{ | ||
{ | ||
name: "empty contact", | ||
contacts: []string{"mailto:[email protected]", ""}, | ||
expectedProbType: "urn:ietf:params:acme:error:invalidContact", | ||
expectedProbDetail: `empty contact`, | ||
}, | ||
{ | ||
name: "empty proto", | ||
contacts: []string{"mailto:[email protected]", " "}, | ||
expectedProbType: "urn:ietf:params:acme:error:unsupportedContact", | ||
expectedProbDetail: `only contact scheme 'mailto:' is supported`, | ||
}, | ||
{ | ||
name: "empty mailto", | ||
contacts: []string{"mailto:[email protected]", "mailto:"}, | ||
expectedProbType: "urn:ietf:params:acme:error:invalidContact", | ||
expectedProbDetail: `unable to parse email address`, | ||
}, | ||
{ | ||
name: "non-ascii mailto", | ||
contacts: []string{"mailto:[email protected]", "mailto:cpu@l̴etsencrypt.org"}, | ||
expectedProbType: "urn:ietf:params:acme:error:invalidContact", | ||
expectedProbDetail: `contact email contains non-ASCII characters`, | ||
}, | ||
{ | ||
name: "too many contacts", | ||
contacts: []string{"a", "b", "c", "d"}, | ||
expectedProbType: "urn:ietf:params:acme:error:malformed", | ||
expectedProbDetail: `too many contacts provided: 4 > 3`, | ||
}, | ||
{ | ||
name: "invalid contact", | ||
contacts: []string{"mailto:[email protected]", "mailto:a@"}, | ||
expectedProbType: "urn:ietf:params:acme:error:invalidContact", | ||
expectedProbDetail: `unable to parse email address`, | ||
}, | ||
{ | ||
name: "forbidden contact domain", | ||
contacts: []string{"mailto:[email protected]", "mailto:[email protected]"}, | ||
expectedProbType: "urn:ietf:params:acme:error:invalidContact", | ||
expectedProbDetail: "contact email has forbidden domain \"example.com\"", | ||
}, | ||
{ | ||
name: "contact domain invalid TLD", | ||
contacts: []string{"mailto:[email protected]", "mailto:[email protected]"}, | ||
expectedProbType: "urn:ietf:params:acme:error:invalidContact", | ||
expectedProbDetail: `contact email has invalid domain: Domain name does not end with a valid public suffix (TLD)`, | ||
}, | ||
{ | ||
name: "contact domain invalid", | ||
contacts: []string{"mailto:[email protected]", "mailto:a@example./.com"}, | ||
expectedProbType: "urn:ietf:params:acme:error:invalidContact", | ||
expectedProbDetail: "contact email has invalid domain: Domain name contains an invalid character", | ||
}, | ||
{ | ||
name: "too long contact", | ||
contacts: []string{ | ||
longStringBuf.String(), | ||
}, | ||
expectedProbType: "urn:ietf:params:acme:error:invalidContact", | ||
expectedProbDetail: `too many/too long contact(s). Please use shorter or fewer email addresses`, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
// First try registering a new account and ensuring the expected problem occurs | ||
var prob acme.Problem | ||
_, err := makeClient(tc.contacts...) | ||
if err != nil { | ||
test.AssertErrorWraps(t, err, &prob) | ||
test.AssertEquals(t, prob.Type, tc.expectedProbType) | ||
test.AssertEquals(t, prob.Detail, createErrorPrefix+tc.expectedProbDetail) | ||
} else { | ||
t.Errorf("expected %s type problem for %q, got nil", | ||
tc.expectedProbType, strings.Join(tc.contacts, ",")) | ||
} | ||
|
||
// Next try making a client with a good contact and updating with the test | ||
// case contact info. The same problem should occur. | ||
c, err := makeClient("mailto:[email protected]") | ||
test.AssertNotError(t, err, "failed to create account with valid contact") | ||
_, err = c.UpdateAccount(c.Account, tc.contacts...) | ||
if err != nil { | ||
test.AssertErrorWraps(t, err, &prob) | ||
test.AssertEquals(t, prob.Type, tc.expectedProbType) | ||
test.AssertEquals(t, prob.Detail, updateErrorPrefix+tc.expectedProbDetail) | ||
} else { | ||
t.Errorf("expected %s type problem after updating account to %q, got nil", | ||
tc.expectedProbType, strings.Join(tc.contacts, ",")) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestRejectedIdentifier(t *testing.T) { | ||
t.Parallel() | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.