Changeset 13946


Ignore:
Timestamp:
02/11/12 04:20:24 (3 months ago)
Author:
GeorgeClark
Message:

Item11517: Unit test for the admin sudo password

Update to new encoding.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UnitTestContrib/test/unit/ClientTests.pm

    r13846 r13946  
    1313use Unit::Request(); 
    1414use Error qw( :try ); 
     15use Digest::MD5 qw(md5_hex); 
    1516 
    1617my $agent = $Foswiki::cfg{Register}{RegistrationAgentWikiName}; 
     
    190191    } 
    191192    my $secret = "a big mole on my left buttock"; 
    192     my $crypted = crypt( $secret, "12" ); 
     193 
     194    # Test new style MD5 hashed password 
     195    my $crypted = '$1234asdf$' . Digest::MD5::md5_hex( '$1234asdf$' . $secret ); 
    193196    $Foswiki::cfg{Password} = $crypted; 
    194197 
     
    213216        $this->{session}->{response}->headers()->{Location} ); 
    214217 
     218    # Verify that old crypted password works 
     219    $crypted = crypt( $secret, "12" ); 
     220    $Foswiki::cfg{Password} = $crypted; 
     221 
     222    # SMELL: 8 character truncated password will match. 
     223    $secret = substr( $secret, 0, 8 ); 
     224 
     225    $query = Unit::Request->new( 
     226        { 
     227            username => [ $Foswiki::cfg{AdminUserLogin} ], 
     228            password => [$secret], 
     229            Logon    => [1], 
     230            skin     => ['none'], 
     231        } 
     232    ); 
     233    $query->path_info("/$this->{test_web}/$this->{test_topic}"); 
     234 
     235    $this->createNewFoswikiSession( undef, $query ); 
     236    $this->{session}->getLoginManager()->login( $query, $this->{session} ); 
     237    $script = $Foswiki::cfg{LoginManager} =~ /Apache/ ? 'viewauth' : 'view'; 
     238    $surly = 
     239      $this->{session} 
     240      ->getScriptUrl( 0, $script, $this->{test_web}, $this->{test_topic} ); 
     241    $this->assert_matches( qr/^302/, $this->{session}->{response}->status() ); 
     242    $this->assert_matches( qr/^$surly/, 
     243        $this->{session}->{response}->headers()->{Location} ); 
     244 
    215245    return; 
    216246} 
Note: See TracChangeset for help on using the changeset viewer.