Changeset 47122 for trunk/tests/phpunit/tests/auth.php
- Timestamp:
- 01/29/2020 12:43:23 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/auth.php
r46650 r47122 12 12 13 13 /** 14 * action hook14 * Action hook. 15 15 */ 16 16 protected $nonce_failure_hook = 'wp_verify_nonce_failed'; … … 58 58 59 59 function test_auth_cookie_scheme() { 60 // arbitrary scheme name60 // Arbitrary scheme name. 61 61 $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' ); 62 62 $this->assertEquals( self::$user_id, wp_validate_auth_cookie( $cookie, 'foo' ) ); 63 63 64 // wrong scheme name - should fail64 // Wrong scheme name - should fail. 65 65 $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' ); 66 66 $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'bar' ) ); … … 158 158 $this->setExpectedIncorrectUsage( 'check_admin_referer' ); 159 159 160 // A valid nonce needs to be set so the check doesn't die() 160 // A valid nonce needs to be set so the check doesn't die(). 161 161 $_REQUEST['_wpnonce'] = wp_create_nonce( -1 ); 162 162 $result = check_admin_referer(); … … 167 167 168 168 public function test_check_admin_referer_with_default_action_as_string_not_doing_it_wrong() { 169 // A valid nonce needs to be set so the check doesn't die() 169 // A valid nonce needs to be set so the check doesn't die(). 170 170 $_REQUEST['_wpnonce'] = wp_create_nonce( '-1' ); 171 171 $result = check_admin_referer( '-1' ); … … 181 181 $this->setExpectedIncorrectUsage( 'check_ajax_referer' ); 182 182 183 // A valid nonce needs to be set so the check doesn't die() 183 // A valid nonce needs to be set so the check doesn't die(). 184 184 $_REQUEST['_wpnonce'] = wp_create_nonce( -1 ); 185 185 $result = check_ajax_referer(); … … 193 193 194 194 wp_set_password( $limit, self::$user_id ); 195 // phpass hashed password 195 // phpass hashed password. 196 196 $this->assertStringStartsWith( '$P$', $this->user->data->user_pass ); 197 197 198 198 $user = wp_authenticate( $this->user->user_login, 'aaaaaaaa' ); 199 // Wrong Password199 // Wrong password. 200 200 $this->assertInstanceOf( 'WP_Error', $user ); 201 201 … … 204 204 $this->assertEquals( self::$user_id, $user->ID ); 205 205 206 // one char too many206 // One char too many. 207 207 $user = wp_authenticate( $this->user->user_login, $limit . 'a' ); 208 // Wrong Password208 // Wrong password. 209 209 $this->assertInstanceOf( 'WP_Error', $user ); 210 210 … … 224 224 225 225 $user = wp_authenticate( $this->user->user_login, 'aaaaaaaa' ); 226 // Wrong Password226 // Wrong password. 227 227 $this->assertInstanceOf( 'WP_Error', $user ); 228 228 229 229 $user = wp_authenticate( $this->user->user_login, $limit ); 230 // Wrong Password230 // Wrong password. 231 231 $this->assertInstanceOf( 'WP_Error', $user ); 232 232 … … 243 243 $key = get_password_reset_key( $user ); 244 244 245 // A correctly saved key should be accepted 245 // A correctly saved key should be accepted. 246 246 $check = check_password_reset_key( $key, $this->user->user_login ); 247 247 $this->assertNotWPError( $check ); … … 268 268 clean_user_cache( $this->user ); 269 269 270 // A valid key should be accepted 270 // A valid key should be accepted. 271 271 $check = check_password_reset_key( $key, $this->user->user_login ); 272 272 $this->assertNotWPError( $check ); … … 274 274 $this->assertSame( $this->user->ID, $check->ID ); 275 275 276 // An invalid key should be rejected 276 // An invalid key should be rejected. 277 277 $check = check_password_reset_key( 'key', $this->user->user_login ); 278 278 $this->assertInstanceOf( 'WP_Error', $check ); 279 279 280 // An empty key should be rejected 280 // An empty key should be rejected. 281 281 $check = check_password_reset_key( '', $this->user->user_login ); 282 282 $this->assertInstanceOf( 'WP_Error', $check ); 283 283 284 // A truncated key should be rejected 284 // A truncated key should be rejected. 285 285 $partial = substr( $key, 0, 10 ); 286 286 $check = check_password_reset_key( $partial, $this->user->user_login ); … … 306 306 clean_user_cache( $this->user ); 307 307 308 // An expired but otherwise valid key should be rejected 308 // An expired but otherwise valid key should be rejected. 309 309 $check = check_password_reset_key( $key, $this->user->user_login ); 310 310 $this->assertInstanceOf( 'WP_Error', $check ); … … 315 315 */ 316 316 function test_empty_user_activation_key_fails_key_check() { 317 // An empty user_activation_key should not allow any key to be accepted 317 // An empty user_activation_key should not allow any key to be accepted. 318 318 $check = check_password_reset_key( 'key', $this->user->user_login ); 319 319 $this->assertInstanceOf( 'WP_Error', $check ); 320 320 321 // An empty user_activation_key should not allow an empty key to be accepted 321 // An empty user_activation_key should not allow an empty key to be accepted. 322 322 $check = check_password_reset_key( '', $this->user->user_login ); 323 323 $this->assertInstanceOf( 'WP_Error', $check ); … … 344 344 clean_user_cache( $this->user ); 345 345 346 // A legacy user_activation_key should not be accepted 346 // A legacy user_activation_key should not be accepted. 347 347 $check = check_password_reset_key( $key, $this->user->user_login ); 348 348 $this->assertInstanceOf( 'WP_Error', $check ); 349 349 350 // An empty key with a legacy user_activation_key should be rejected 350 // An empty key with a legacy user_activation_key should be rejected. 351 351 $check = check_password_reset_key( '', $this->user->user_login ); 352 352 $this->assertInstanceOf( 'WP_Error', $check ); … … 374 374 clean_user_cache( $this->user ); 375 375 376 // A plaintext user_activation_key should not allow an otherwise valid key to be accepted 376 // A plaintext user_activation_key should not allow an otherwise valid key to be accepted. 377 377 $check = check_password_reset_key( $key, $this->user->user_login ); 378 378 $this->assertInstanceOf( 'WP_Error', $check ); 379 379 380 // A plaintext user_activation_key should not allow an empty key to be accepted 380 // A plaintext user_activation_key should not allow an empty key to be accepted. 381 381 $check = check_password_reset_key( '', $this->user->user_login ); 382 382 $this->assertInstanceOf( 'WP_Error', $check );
Note: See TracChangeset
for help on using the changeset viewer.