These two parts of contact module need tests:
Attempting to submit an invalid email.
Flood control for contact form.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | contact-test-296495-10.patch | 1.65 KB | mcjim |
| #2 | testing_party_contact_test.patch | 1.84 KB | jpetso |
| #1 | testing_party_contact_test.patch | 1.84 KB | mcjim |
Comments
Comment #1
mcjim commentedAdded test for flood control on personal contact form.
As a user has to be logged in to use a personal contact form, their email address is validated when setting up/editing their account, so a test for this has not been added.
Most of the work done by Robert Castelo and Dan Smith.
Comment #2
jpetso commentedSame patch, but with tabs removed in favor of nice spaces.
Comment #3
jpetso commentedStill applies and works on current HEAD. In fact, since I have only touched the formatting, I think I'm allowed to push this to RTBC. Small, clean and easy to look at.
Comment #4
dries commentedI've committed this patch. I'm marking this back to 'active' so we can implement the second half of the missing tests. Thanks!
Comment #5
dave reidThis is all finished because invalid e-mail testing is already done in the sitewide contact test, and user e-mail addresses are tested on registration/insert and there is no form element to insert an e-mail address on the personal contact form.
Comment #6
catchMarking fixed then, I think.
Comment #7
catchNope, looks like contact_admin_edit_validate() does the recipient e-mail rather than the user's e-mail, so we still need a test for it.
Comment #8
dave reidIsn't that already covered by user_validate_mail, which is called at user registration or changes made to user account?
See user_user and _user_edit_validate.
Comment #9
catchQuite possibly, but we'd want coverage of this particular function to make sure nothing comes along and breaks it later. It might also be an opportunity to consolidate some code (although I didn't look).
Comment #10
mcjim commentedI've been working on adding a test for whether the sender's email is valid on the personal contact form.
The attached patch is currently broken, though I'm not sure why and nor is catch, who's already had a look at it for me.
I've tested what the test should be testing (!) manually by:
1) Changing the logged-in user's email address in the database to something invalid, e.g "@example.com"
2) Going to another user's personal contact page at /user/[uid]/contact
3) The result is the text: "You need to provide a valid e-mail address to contact other users. Please update your user information and try again." which is produced by contact_user_page() in contact.pages.inc
The attached patch is testing for this (or parts of this text: there are commented-out variations in there) but failing.
(Line 324 is just a sanity check for myself
$this->assertResponse(200, t('A page is returned. Email: ') . $web_user1->mail);and is returning what I'd expect.)
Comment #11
lilou commentedOther invalid senders :
Comment #12
lilou commented... strange, there seems to be a bug in
<code>(turn the 3rd email into link)Comment #13
catchlilou, it's more likely the url filter playing up - see #161217: URL filter breaks generated href tags
Comment #14
mcjim commentedRelated to this, I noticed that on line 125 of contact.test, only one type of invalid email address is being tested for on submission of the sitewide contact form. Is this correct? Shouldn't we loop through the $invalid_recipients array and test them all?
Comment #15
dave reidNow that we have a revamped valid_email_address(), we're now looping through the whole array of invalid e-mails. I'm going to mark this as fixed since I'm re-working part of these tests as part of #58224: Allow anonymous users access to a members personal contact form.