Ticket #24030: 24030.2.diff
File 24030.2.diff, 1.9 KB (added by , 9 years ago) |
---|
-
src/wp-includes/pluggable.php
1803 1803 return 2; 1804 1804 } 1805 1805 1806 /** 1807 * Fires when nonce verification fails. 1808 * 1809 * @since x.x.x 1810 * 1811 * @param string $nonce The invalid nonce. 1812 * @param string|int $action The nonce action. 1813 * @param WP_User $user The current user object. 1814 * @param string $token The user's session token. 1815 */ 1816 do_action( 'wp_verify_nonce_failed', $nonce, $action, $user, $token ); 1817 1806 1818 // Invalid nonce 1807 1819 return false; 1808 1820 } -
tests/phpunit/tests/auth.php
8 8 var $user_id; 9 9 var $wp_hasher; 10 10 11 /** 12 * action hook 13 */ 14 protected $nonce_failure_hook = 'wp_verify_nonce_failed'; 15 11 16 function setUp() { 12 17 parent::setUp(); 13 18 $this->user_id = $this->factory->user->create(); … … 110 115 $this->assertFalse( wp_verify_nonce( 1 ) ); 111 116 } 112 117 118 /** 119 * @ticket 24030 120 */ 121 function test_wp_nonce_verify_failed() { 122 $nonce = substr( md5( uniqid() ), 0, 10 ); 123 $count = did_action( $this->nonce_failure_hook ); 124 125 wp_verify_nonce( $nonce, 'nonce_test_action' ); 126 127 $this->assertEquals( ( $count + 1 ), did_action( $this->nonce_failure_hook ) ); 128 } 129 130 /** 131 * @ticket 24030 132 */ 133 function test_wp_nonce_verify_success() { 134 $nonce = wp_create_nonce( 'nonce_test_action' ); 135 $count = did_action( $this->nonce_failure_hook ); 136 137 wp_verify_nonce( $nonce, 'nonce_test_action' ); 138 139 $this->assertEquals( $count, did_action( $this->nonce_failure_hook ) ); 140 } 141 113 142 function test_password_length_limit() { 114 143 $passwords = array( 115 144 str_repeat( 'a', 4095 ), // short