non security modules update

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-20 16:32:07 +02:00
parent 6a8d30db08
commit 37fbabab56
466 changed files with 32690 additions and 9652 deletions

View File

@@ -2,8 +2,7 @@
/**
* @file
*
* Honeypot administration form.
* Honeypot administration forms.
*/
/**
@@ -17,37 +16,37 @@ function honeypot_admin_form($form, &$form_state) {
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['configuration']['honeypot_protect_all_forms'] = array(
'#type' => 'checkbox',
'#title' => t('Protect all forms with Honeypot'),
'#description' => t('Enable Honeypot protection for ALL forms on this site (it is best to only enable Honeypot for the forms you need below).'),
'#default_value' => variable_get('honeypot_protect_all_forms', 0),
);
$form['configuration']['honeypot_protect_all_forms']['#description'] .= '<br />' . t('<strong>Page caching will be disabled on any page where a form is present if the Honeypot time limit is not set to 0.</strong>');
$form['configuration']['honeypot_log'] = array(
'#type' => 'checkbox',
'#title' => t('Log blocked form submissions'),
'#description' => t('Log submissions that are blocked due to Honeypot protection.'),
'#default_value' => variable_get('honeypot_log', 0),
);
$form['configuration']['honeypot_element_name'] = array(
'#type' => 'textfield',
'#title' => t('Honeypot element name'),
'#description' => t("The name of the Honeypot form field. It's usually most effective to use a generic name like email, homepage, or name, but this should be changed if it interferes with fields that are already in your forms. Must not contain spaces or special characters."),
'#default_value' => variable_get('honeypot_element_name', 'url'),
'#required' => TRUE,
'#size' => 30,
);
$form['configuration']['honeypot_time_limit'] = array(
'#type' => 'textfield',
'#title' => t('Honeypot time limit'),
'#description' => t('Minimum time required before form should be considered entered by a human instead of a bot. Set to 0 to disable.'),
'#default_value' => variable_get('honeypot_time_limit', 5),
'#required' => TRUE,
'#size' => 5,
'#field_suffix' => t('seconds'),
);
$form['configuration']['honeypot_time_limit']['#description'] .= '<br />' . t('<strong>Page caching will be disabled if there is a form protected by time limit on the page.</strong>');
$form['configuration']['honeypot_protect_all_forms'] = array(
'#type' => 'checkbox',
'#title' => t('Protect all forms with Honeypot'),
'#description' => t('Enable Honeypot protection for ALL forms on this site (it is best to only enable Honeypot for the forms you need below).'),
'#default_value' => variable_get('honeypot_protect_all_forms', 0),
);
$form['configuration']['honeypot_protect_all_forms']['#description'] .= '<br />' . t('<strong>Page caching will be disabled on any page where a form is present if the Honeypot time limit is not set to 0.</strong>');
$form['configuration']['honeypot_log'] = array(
'#type' => 'checkbox',
'#title' => t('Log blocked form submissions'),
'#description' => t('Log submissions that are blocked due to Honeypot protection.'),
'#default_value' => variable_get('honeypot_log', 0),
);
$form['configuration']['honeypot_element_name'] = array(
'#type' => 'textfield',
'#title' => t('Honeypot element name'),
'#description' => t("The name of the Honeypot form field. It's usually most effective to use a generic name like email, homepage, or name, but this should be changed if it interferes with fields that are already in your forms. Must not contain spaces or special characters."),
'#default_value' => variable_get('honeypot_element_name', 'url'),
'#required' => TRUE,
'#size' => 30,
);
$form['configuration']['honeypot_time_limit'] = array(
'#type' => 'textfield',
'#title' => t('Honeypot time limit'),
'#description' => t('Minimum time required before form should be considered entered by a human instead of a bot. Set to 0 to disable.'),
'#default_value' => variable_get('honeypot_time_limit', 5),
'#required' => TRUE,
'#size' => 5,
'#field_suffix' => t('seconds'),
);
$form['configuration']['honeypot_time_limit']['#description'] .= '<br />' . t('<strong>Page caching will be disabled if there is a form protected by time limit on the page.</strong>');
// Honeypot Enabled forms.
$form['enabled_forms'] = array(
@@ -64,84 +63,84 @@ function honeypot_admin_form($form, &$form_state) {
),
);
// Generic forms.
$form['enabled_forms']['general_forms'] = array('#markup' => '<h5>' . t('General Forms') . '</h5>');
// User register form.
$form['enabled_forms']['honeypot_form_user_register_form'] = array(
// Generic forms.
$form['enabled_forms']['general_forms'] = array('#markup' => '<h5>' . t('General Forms') . '</h5>');
// User register form.
$form['enabled_forms']['honeypot_form_user_register_form'] = array(
'#type' => 'checkbox',
'#title' => t('User Registration form'),
'#default_value' => variable_get('honeypot_form_user_register_form', 0),
);
// User password form.
$form['enabled_forms']['honeypot_form_user_pass'] = array(
'#type' => 'checkbox',
'#title' => t('User Password Reset form'),
'#default_value' => variable_get('honeypot_form_user_pass', 0),
);
// If webform.module enabled, add webforms.
if (module_exists('webform')) {
$form['enabled_forms']['honeypot_form_webforms'] = array(
'#type' => 'checkbox',
'#title' => t('User Registration form'),
'#default_value' => variable_get('honeypot_form_user_register_form', 0),
'#title' => t('Webforms (all)'),
'#default_value' => variable_get('honeypot_form_webforms', 0),
);
// User password form.
$form['enabled_forms']['honeypot_form_user_pass'] = array(
}
// If contact.module enabled, add contact forms.
if (module_exists('contact')) {
$form['enabled_forms']['contact_forms'] = array('#markup' => '<h5>' . t('Contact Forms') . '</h5>');
// Sitewide contact form.
$form['enabled_forms']['honeypot_form_contact_site_form'] = array(
'#type' => 'checkbox',
'#title' => t('User Password Reset form'),
'#default_value' => variable_get('honeypot_form_user_pass', 0),
'#title' => t('Sitewide Contact form'),
'#default_value' => variable_get('honeypot_form_contact_site_form', 0),
);
// Sitewide personal form.
$form['enabled_forms']['honeypot_form_contact_personal_form'] = array(
'#type' => 'checkbox',
'#title' => t('Personal Contact forms'),
'#default_value' => variable_get('honeypot_form_contact_personal_form', 0),
);
}
// If webform.module enabled, add webforms.
if (module_exists('webform')) {
$form['enabled_forms']['honeypot_form_webforms'] = array(
// If profile.module enabled, add profile forms.
if (module_exists('profile')) {
$form['enabled_forms']['profile_forms'] = array('#value' => '<h5>' . t('Profile Forms') . '</h5>');
$form['enabled_forms']['honeypot_form_user_profile_form'] = array(
'#type' => 'checkbox',
'#title' => t('Profile forms (all)'),
'#default_value' => variable_get('honeypot_form_user_profile_form', 0),
);
}
// Get node types for node forms and node comment forms.
$types = node_type_get_types();
if (!empty($types)) {
// Node forms.
$form['enabled_forms']['node_forms'] = array('#markup' => '<h5>' . t('Node Forms') . '</h5>');
foreach ($types as $type) {
$id = 'honeypot_form_' . $type->type . '_node_form';
$form['enabled_forms'][$id] = array(
'#type' => 'checkbox',
'#title' => t('Webforms (all)'),
'#default_value' => variable_get('honeypot_form_webforms', 0),
'#title' => t('@name node form', array('@name' => $type->name)),
'#default_value' => variable_get($id, 0),
);
}
// If contact.module enabled, add contact forms.
if (module_exists('contact')) {
$form['enabled_forms']['contact_forms'] = array('#markup' => '<h5>' . t('Contact Forms') . '</h5>');
// Sitewide contact form.
$form['enabled_forms']['honeypot_form_contact_site_form'] = array(
'#type' => 'checkbox',
'#title' => t('Sitewide Contact form'),
'#default_value' => variable_get('honeypot_form_contact_site_form', 0),
);
// Sitewide personal form.
$form['enabled_forms']['honeypot_form_contact_personal_form'] = array(
'#type' => 'checkbox',
'#title' => t('Personal Contact forms'),
'#default_value' => variable_get('honeypot_form_contact_personal_form', 0),
);
}
// If profile.module enabled, add profile forms.
if (module_exists('profile')) {
$form['enabled_forms']['profile_forms'] = array('#value' => '<h5>' . t('Profile Forms') . '</h5>');
$form['enabled_forms']['honeypot_form_user_profile_form'] = array(
'#type' => 'checkbox',
'#title' => t('Profile forms (all)'),
'#default_value' => variable_get('honeypot_form_user_profile_form', 0),
);
}
// Get node types for node forms and node comment forms.
$types = node_type_get_types();
if (!empty($types)) {
// Node forms.
$form['enabled_forms']['node_forms'] = array('#markup' => '<h5>' . t('Node Forms') . '</h5>');
// Comment forms.
if (module_exists('comment')) {
$form['enabled_forms']['comment_forms'] = array('#markup' => '<h5>' . t('Comment Forms') . '</h5>');
foreach ($types as $type) {
$id = 'honeypot_form_' . $type->type . '_node_form';
$id = 'honeypot_form_comment_node_' . $type->type . '_form';
$form['enabled_forms'][$id] = array(
'#type' => 'checkbox',
'#title' => t('@name node form', array('@name' => $type->name)),
'#title' => t('@name comment form', array('@name' => $type->name)),
'#default_value' => variable_get($id, 0),
);
}
// Comment forms.
if (module_exists('comment')) {
$form['enabled_forms']['comment_forms'] = array('#markup' => '<h5>' . t('Comment Forms') . '</h5>');
foreach ($types as $type) {
$id = 'honeypot_form_comment_node_' . $type->type . '_form';
$form['enabled_forms'][$id] = array(
'#type' => 'checkbox',
'#title' => t('@name comment form', array('@name' => $type->name)),
'#default_value' => variable_get($id, 0),
);
}
}
}
}
// Add our own submit handler to clear honeypot's form cache on save.
$form['#submit'][] = 'honeypot_admin_form_submit';

View File

@@ -2,7 +2,6 @@
/**
* @file
*
* API Functionality for Honeypot module.
*/
@@ -14,10 +13,10 @@
/**
* Alter the honeypot protections added to a particular form.
*
* @param (array) $options
* @param array $options
* Protections that will be applied to the form. May be empty, or may include
* 'honeypot' and/or 'time_restriction'.
* @param (array) $form
* @param array $form
* The Form API form to which protections will be added.
*/
function hook_honeypot_form_protections_alter(&$options, $form) {
@@ -34,10 +33,10 @@ function hook_honeypot_form_protections_alter(&$options, $form) {
* You can use this hook to track when and how many times certain protected
* forms are displayed to certain users, or for other tracking purposes.
*
* @param (array) $options
* @param array $options
* Protections that were applied to the form. Includes 'honeypot' and/or
* 'time_restriction'.
* @param (array) $form
* @param array $form
* The Form API form to which protections were added.
*/
function hook_honeypot_add_form_protection($options, $form) {
@@ -53,11 +52,11 @@ function hook_honeypot_add_form_protection($options, $form) {
* the user ID (0 if anonymous) of the user that was disallowed from submitting
* the form, and the reason (type) for the rejection of the form submission.
*
* @param (string) $form_id
* @param string $form_id
* Form ID of the form the user was disallowed from submitting.
* @param (int) $uid
* @param int $uid
* 0 for anonymous users, otherwise the user ID of the user.
* @param (string) $type
* @param string $type
* String indicating the reason the submission was blocked. Allowed values:
* - honeypot: If honeypot field was filled in.
* - honeypot_time: If form was completed before the configured time limit.
@@ -76,15 +75,15 @@ function hook_honeypot_reject($form_id, $uid, $type) {
* hook to return additional time (in seconds) to honeypot when it is calculates
* the time limit for a particular form.
*
* @param (int) $honeypot_time_limit
* @param int $honeypot_time_limit
* The current honeypot time limit (in seconds), to which any additions you
* return will be added.
* @param (array) $form_values
* @param array $form_values
* Array of form values (may be empty).
* @param (int) $number
* @param int $number
* Number of times the current user has already fallen into the honeypot trap.
*
* @return (int) $additions
* @return int
* Additional time to add to the honeypot_time_limit, in seconds (integer).
*/
function hook_honeypot_time_limit($honeypot_time_limit, $form_values, $number) {

View File

@@ -6,9 +6,9 @@ package = "Spam control"
files[] = honeypot.test
; Information added by drupal.org packaging script on 2013-09-13
version = "7.x-1.15"
; Information added by Drupal.org packaging script on 2014-05-30
version = "7.x-1.17"
core = "7.x"
project = "honeypot"
datestamp = "1379087801"
datestamp = "1401478128"

View File

@@ -2,7 +2,6 @@
/**
* @file
*
* Install, update and uninstall functions for the Honeypot module.
*/
@@ -38,8 +37,9 @@ function honeypot_schema() {
* Implements hook_install().
*/
function honeypot_install() {
drupal_set_message(st("Honeypot installed successfully. Please !link to protect your forms from spam bots.", array(
'!link' => l(st('configure Honeypot'), 'admin/config/content/honeypot')
$t = get_t();
drupal_set_message($t("Honeypot installed successfully. Please !link to protect your forms from spam bots.", array(
'!link' => l($t('configure Honeypot'), 'admin/config/content/honeypot'),
)));
}
@@ -65,7 +65,6 @@ function honeypot_update_7001() {
$ret = array();
// Leaving this in because I had it in version 1.3. Silly me.
return $ret;
}

View File

@@ -2,7 +2,6 @@
/**
* @file
*
* Honeypot module, for deterring spam bots from completing Drupal forms.
*/
@@ -92,6 +91,43 @@ function honeypot_form_alter(&$form, &$form_state, $form_id) {
}
}
/**
* Implements hook_trigger_info().
*/
function honeypot_trigger_info() {
return array(
'honeypot' => array(
'honeypot_reject' => array(
'label' => t('Honeypot rejection'),
),
),
);
}
/**
* Implements hook_rules_event_info()
*/
function honeypot_rules_event_info() {
return array(
'honeypot_reject' => array(
'label' => t('Honeypot rejection'),
'group' => t('Honeypot'),
'variables' => array(
'form_id' => array(
'type' => 'text',
'label' => t('Form ID of the form the user was disallowed from submitting.'),
),
// Don't provide 'uid' in context because it is available as
// site:current-user:uid.
'type' => array(
'type' => 'text',
'label' => t('String indicating the reason the submission was blocked.'),
),
),
),
);
}
/**
* Build an array of all the protected forms on the site, by form_id.
*
@@ -126,11 +162,11 @@ function honeypot_get_protected_forms() {
/**
* Form builder function to add different types of protection to forms.
*
* @param $options (array)
* @param array $options
* Array of options to be added to form. Currently accepts 'honeypot' and
* 'time_restriction'.
*
* @return $form_elements
* @return array
* Returns elements to be placed in a form's elements array to prevent spam.
*/
function honeypot_add_form_protection(&$form, &$form_state, $options = array()) {
@@ -160,9 +196,10 @@ function honeypot_add_form_protection(&$form, &$form_state, $options = array())
'#element_validate' => array('_honeypot_honeypot_validate'),
'#prefix' => '<div class="' . $honeypot_class . '">',
'#suffix' => '</div>',
// Hide honeypot.
'#attached' => array(
'css' => array(
'.' . $honeypot_class . ' { display: none !important; }' => array('type' => 'inline'), // Hide honeypot.
'.' . $honeypot_class . ' { display: none !important; }' => array('type' => 'inline'),
),
),
);
@@ -207,7 +244,12 @@ function _honeypot_honeypot_validate($element, &$form_state) {
/**
* Validate honeypot's time restriction field.
*/
function _honeypot_time_restriction_validate($form, &$form_state) {
function _honeypot_time_restriction_validate($element, &$form_state) {
// Don't do anything if the triggering element is a preview button.
if ($form_state['triggering_element']['#value'] == t('Preview')) {
return;
}
// Get the time value.
$honeypot_time = $form_state['values']['honeypot_time'];
@@ -218,7 +260,8 @@ function _honeypot_time_restriction_validate($form, &$form_state) {
// If not, throw an error.
if (time() < ($honeypot_time + $time_limit)) {
_honeypot_log($form_state['values']['form_id'], 'honeypot_time');
$time_limit = honeypot_get_time_limit();
// Get the time limit again, since it increases after first failure.
$time_limit = honeypot_get_time_limit($form_state['values']);
$form_state['values']['honeypot_time'] = time();
form_set_error('', t('There was a problem with your form submission. Please wait @limit seconds and try again.', array('@limit' => $time_limit)));
}
@@ -227,9 +270,9 @@ function _honeypot_time_restriction_validate($form, &$form_state) {
/**
* Log blocked form submissions.
*
* @param $form_id
* @param string $form_id
* Form ID for the form on which submission was blocked.
* @param $type
* @param string $type
* String indicating the reason the submission was blocked. Allowed values:
* - honeypot: If honeypot field was filled in.
* - honeypot_time: If form was completed before the configured time limit.
@@ -238,18 +281,17 @@ function _honeypot_log($form_id, $type) {
honeypot_log_failure($form_id, $type);
if (variable_get('honeypot_log', 0)) {
$variables = array(
'%form' => $form_id,
'@cause' => ($type == 'honeypot') ? t('submission of a value in the honeypot field') : t('submission of the form in less than minimum required time'),
'%form' => $form_id,
'@cause' => ($type == 'honeypot') ? t('submission of a value in the honeypot field') : t('submission of the form in less than minimum required time'),
);
watchdog('honeypot', 'Blocked submission of %form due to @cause.', $variables);
}
return;
}
/**
* Look up the time limit for the current user.
*
* @param $form_values
* @param array $form_values
* Array of form values (optional).
*/
function honeypot_get_time_limit($form_values = array()) {
@@ -271,7 +313,7 @@ function honeypot_get_time_limit($form_values = array()) {
))->fetchField();
}
// Don't add more than 30 days' worth of extra time.
$honeypot_time_limit = $honeypot_time_limit + (int) min($honeypot_time_limit + exp($number), 2592000);
$honeypot_time_limit = (int) min($honeypot_time_limit + exp($number) - 1, 2592000);
$additions = module_invoke_all('honeypot_time_limit', $honeypot_time_limit, $form_values, $number);
if (count($additions)) {
$honeypot_time_limit += array_sum($additions);
@@ -283,9 +325,9 @@ function honeypot_get_time_limit($form_values = array()) {
/**
* Log the failed submision with timestamp.
*
* @param $form_id
* @param string $form_id
* Form ID for the rejected form submission.
* @param $type
* @param string $type
* String indicating the reason the submission was blocked. Allowed values:
* - honeypot: If honeypot field was filled in.
* - honeypot_time: If form was completed before the configured time limit.
@@ -309,4 +351,24 @@ function honeypot_log_failure($form_id, $type) {
// Allow other modules to react to honeypot rejections.
module_invoke_all('honeypot_reject', $form_id, $user->uid, $type);
// Trigger honeypot_reject action.
if (module_exists('trigger')) {
$aids = trigger_get_assigned_actions('honeypot_reject');
$context = array(
'group' => 'honeypot',
'hook' => 'honeypot_reject',
'form_id' => $form_id,
// Do not provide $user in context because it is available as a global.
'type' => $type,
);
// Honeypot does not act on any specific object.
$object = NULL;
actions_do(array_keys($aids), $object, $context);
}
// Trigger rules honeypot_reject event.
if (module_exists('rules')) {
rules_invoke_event('honeypot_reject', $form_id, $type);
}
}

View File

@@ -9,8 +9,8 @@
* Test the functionality of the Honeypot module for an admin user.
*/
class HoneypotFormTestCase extends DrupalWebTestCase {
protected $admin_user;
protected $web_user;
protected $adminUser;
protected $webUser;
protected $node;
public static function getInfo() {
@@ -27,8 +27,10 @@ class HoneypotFormTestCase extends DrupalWebTestCase {
// Set up required Honeypot variables.
variable_set('honeypot_element_name', 'url');
variable_set('honeypot_time_limit', 0); // Disable time_limit protection.
variable_set('honeypot_protect_all_forms', TRUE); // Test protecting all forms.
// Disable time_limit protection.
variable_set('honeypot_time_limit', 0);
// Test protecting all forms.
variable_set('honeypot_protect_all_forms', TRUE);
variable_set('honeypot_log', FALSE);
// Set up other required variables.
@@ -36,7 +38,7 @@ class HoneypotFormTestCase extends DrupalWebTestCase {
variable_set('user_register', USER_REGISTER_VISITORS);
// Set up admin user.
$this->admin_user = $this->drupalCreateUser(array(
$this->adminUser = $this->drupalCreateUser(array(
'administer honeypot',
'bypass honeypot protection',
'administer content types',
@@ -48,7 +50,7 @@ class HoneypotFormTestCase extends DrupalWebTestCase {
));
// Set up web user.
$this->web_user = $this->drupalCreateUser(array(
$this->webUser = $this->drupalCreateUser(array(
'access comments',
'post comments',
'create article content',
@@ -58,7 +60,7 @@ class HoneypotFormTestCase extends DrupalWebTestCase {
$this->node = $this->drupalCreateNode(array(
'type' => 'article',
'promote' => 1,
'uid' => $this->web_user->uid,
'uid' => $this->webUser->uid,
));
}
@@ -96,9 +98,12 @@ class HoneypotFormTestCase extends DrupalWebTestCase {
$this->drupalPost('user/register', $edit, t('Create new account'));
// Form should have error message.
$this->assertText(t('There was a problem with your form submission. Please wait'), 'Registration form protected by time limit.');
$this->assertText(t('There was a problem with your form submission. Please wait 6 seconds and try again.'), 'Registration form protected by time limit.');
}
/**
* Test comment form protection.
*/
public function testProtectCommentFormNormal() {
$comment = 'Test comment.';
@@ -106,7 +111,7 @@ class HoneypotFormTestCase extends DrupalWebTestCase {
variable_set('honeypot_time_limit', 0);
// Log in the web user.
$this->drupalLogin($this->web_user);
$this->drupalLogin($this->webUser);
// Set up form and submit it.
$edit['comment_body[' . LANGUAGE_NONE . '][0][value]'] = $comment;
@@ -118,7 +123,7 @@ class HoneypotFormTestCase extends DrupalWebTestCase {
$comment = 'Test comment.';
// Log in the web user.
$this->drupalLogin($this->web_user);
$this->drupalLogin($this->webUser);
// Set up form and submit it.
$edit['comment_body[' . LANGUAGE_NONE . '][0][value]'] = $comment;
@@ -129,10 +134,96 @@ class HoneypotFormTestCase extends DrupalWebTestCase {
public function testProtectCommentFormHoneypotBypass() {
// Log in the admin user.
$this->drupalLogin($this->admin_user);
$this->drupalLogin($this->adminUser);
// Get the comment reply form and ensure there's no 'url' field.
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertNoText('id="edit-url" name="url"', 'Honeypot home page field not shown.');
}
/**
* Test node form protection.
*/
public function testProtectNodeFormTooFast() {
// Log in the admin user.
$this->drupalLogin($this->webUser);
// Reset the time limit to 5 seconds.
variable_set('honeypot_time_limit', 5);
// Set up the form and submit it.
$edit["title"] = 'Test Page';
$this->drupalPost('node/add/article', $edit, t('Save'));
$this->assertText(t('There was a problem with your form submission.'), 'Honeypot node form timestamp protection works.');
}
/**
* Test node form protection.
*/
public function testProtectNodeFormPreviewPassthru() {
// Log in the admin user.
$this->drupalLogin($this->webUser);
// Post a node form using the 'Preview' button and make sure it's allowed.
$edit["title"] = 'Test Page';
$this->drupalPost('node/add/article', $edit, t('Preview'));
$this->assertNoText(t('There was a problem with your form submission.'), 'Honeypot not blocking node form previews.');
}
}
/**
* Test the functionality of the Honeypot module's integration with Trigger.
*/
class HoneypotTriggerTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Honeypot Trigger integration',
'description' => 'Ensure that Honeypot triggers events correctly.',
'group' => 'Form API',
);
}
public function setUp() {
// Enable modules required for this test.
parent::setUp(array('honeypot', 'trigger'));
// Set up required Honeypot variables.
variable_set('honeypot_element_name', 'url');
// Disable time_limit protection.
variable_set('honeypot_time_limit', 0);
// Test protecting all forms.
variable_set('honeypot_protect_all_forms', TRUE);
variable_set('honeypot_log', FALSE);
// Set up other required variables.
variable_set('user_email_verification', TRUE);
variable_set('user_register', USER_REGISTER_VISITORS);
// Assign new action to Honeypot form rejection Trigger.
db_insert('trigger_assignments')
->fields(array(
'hook' => 'honeypot_reject',
'aid' => 'system_block_ip_action',
'weight' => 1,
))
->execute();
}
/**
* Test trigger integration.
*/
public function testHoneypotTriggerIntegration() {
// Set up form and submit it.
$edit['name'] = $this->randomName();
$edit['mail'] = $edit['name'] . '@example.com';
$edit['url'] = 'http://www.example.com/';
$this->drupalPost('user/register', $edit, t('Create new account'));
// Make sure Honeypot is working.
$this->assertText(t('There was a problem with your form submission.'), 'Honeypot working correctly.');
// Visit the home page and make sure the user is banned.
$this->drupalGet('node');
$this->assertText(t('has been banned'), 'User banned successfully.');
}
}