WordPress.org

Make WordPress Core

Changeset 642 in tests


Ignore:
Timestamp:
04/08/12 03:06:40 (2 years ago)
Author:
nacin
Message:

Check a cookie expired for > 3600 seconds in TestAuthFunctions::test_auth_cookie_invalid(). When the full test suite is run, DOING_AJAX may have been defined, in which case wp_validate_auth_cookie() provides a 3600-second grace period. Then the test would fail as the cookie is invalid.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_pluggable.php

    r581 r642  
    2020 
    2121    function test_auth_cookie_invalid() { 
    22         // expired 
    23         $cookie = wp_generate_auth_cookie( $this->user_id, time() - 3600, 'auth' ); 
    24         $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'auth' ) ); 
    25  
    26         // wrong auth scheme 
     22        // 3600 or less and +3600 may occur in wp_validate_auth_cookie(), 
     23        // as an ajax test may have defined DOING_AJAX, failing the test. 
     24 
     25        $cookie = wp_generate_auth_cookie( $this->user_id, time() - 7200, 'auth' ); 
     26        $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'auth' ), 'expired cookie' ); 
     27 
    2728        $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'auth' ); 
    28         $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'logged_in' ) ); 
    29  
    30         // altered 
     29        $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'logged_in' ), 'wrong auth scheme' ); 
     30 
    3131        $cookie = wp_generate_auth_cookie( $this->user_id, time() + 3600, 'auth' ); 
    3232        list($a, $b, $c) = explode('|', $cookie); 
    3333        $cookie = $a . '|' . ($b + 1) . '|' . $c; 
    34         $this->assertEquals( false, wp_validate_auth_cookie( $this->user_id, 'auth' ) ); 
     34        $this->assertEquals( false, wp_validate_auth_cookie( $this->user_id, 'auth' ), 'altered cookie' ); 
    3535    } 
    3636 
Note: See TracChangeset for help on using the changeset viewer.