- Timestamp:
- 01/23/12 07:00:46 (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Release01x01/UnitTestContrib/test/unit/ClientTests.pm
r13729 r13794 1 package ClientTests; 1 2 use strict; 2 3 package ClientTests; 3 use warnings; 4 4 5 5 # This is woefully incomplete, but it does at least check that 6 6 # LoginManager.pm compiles okay. 7 7 8 use FoswikiFnTestCase ;8 use FoswikiFnTestCase(); 9 9 our @ISA = qw( FoswikiFnTestCase ); 10 10 11 use Unit::Request; 11 use Foswiki(); 12 use Foswiki::LoginManager(); 13 use Unit::Request(); 12 14 use Error qw( :try ); 13 14 use Foswiki;15 use Foswiki::LoginManager;16 15 17 16 my $agent = $Foswiki::cfg{Register}{RegistrationAgentWikiName}; … … 29 28 my $topicObject = Foswiki::Meta->new( 30 29 $this->{session}, $this->{test_web}, 31 $this->{test_topic}, << CONSTRAINT);30 $this->{test_topic}, <<'CONSTRAINT'); 32 31 * Set ALLOWTOPICCHANGE = AdminGroup 33 32 CONSTRAINT 34 33 $topicObject->save(); 34 35 return; 35 36 } 36 37 37 38 sub TemplateLoginManager { 38 39 $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::TemplateLogin'; 40 41 return; 39 42 } 40 43 41 44 sub ApacheLoginManager { 42 45 $Foswiki::cfg{LoginManager} = 'Foswiki::LoginManager::ApacheLogin'; 46 47 return; 43 48 } 44 49 45 50 sub NoLoginManager { 46 51 $Foswiki::cfg{LoginManager} = 'none'; 52 53 return; 47 54 } 48 55 … … 51 58 $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::BaseUserMapping'; 52 59 $this->set_up_for_verify(); 60 61 return; 53 62 } 54 63 … … 57 66 $Foswiki::cfg{UserMappingManager} = 'Foswiki::Users::TopicUserMapping'; 58 67 $this->set_up_for_verify(); 68 69 return; 59 70 } 60 71 … … 70 81 my $this = shift; 71 82 72 $this->{session}->finish() if $this->{session}; 73 $this->{session} = new Foswiki( undef, new Unit::Request() ); 83 $this->createNewFoswikiSession( undef, Unit::Request->new() ); 74 84 $this->assert( $Foswiki::cfg{TempfileDir} 75 85 && -d $Foswiki::cfg{TempfileDir} ); … … 80 90 $Foswiki::cfg{Register}{EnableNewUserRegistration} = 1; 81 91 $Foswiki::cfg{UsersWebName} = $this->{users_web}; 92 93 return; 82 94 } 83 95 … … 101 113 102 114 #print STDERR "\n------------- set_up_user (login: $userLogin) (cUID:$user_id) -----------------\n"; 115 116 return; 103 117 } 104 118 105 119 sub capture { 106 my $this = shift; 107 my ( $proc, $session ) = @_; 120 my ( $this, $proc, $session, @args ) = @_; 108 121 $session->getLoginManager()->checkAccess(); 109 $this->SUPER::capture(@_); 122 $this->SUPER::capture( $proc, $session, @args ); 123 124 return; 110 125 } 111 126 … … 118 133 119 134 #close this Foswiki session - its using the wrong mapper and login 120 $this->{session}->finish(); 121 122 $query = new Unit::Request(); 135 136 $query = Unit::Request->new(); 123 137 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 124 $this-> {session} = new Foswiki( undef, $query );138 $this->createNewFoswikiSession( undef, $query ); 125 139 126 140 $this->set_up_user(); … … 135 149 }; 136 150 137 $query = new Unit::Request();151 $query = Unit::Request->new(); 138 152 $query->path_info("/$this->{test_web}/$this->{test_topic}?breaklock=1"); 139 $this->{session}->finish(); 140 141 $this->{session} = new Foswiki( undef, $query ); 153 154 $this->createNewFoswikiSession( undef, $query ); 142 155 143 156 try { … … 156 169 }; 157 170 158 $query = new Unit::Request();171 $query = Unit::Request->new(); 159 172 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 160 $this->{session}->finish();161 173 162 174 $this->annotate("new session using $userLogin\n"); 163 175 164 $this-> {session} = new Foswiki( $userLogin, $query );176 $this->createNewFoswikiSession( $userLogin, $query ); 165 177 166 178 #clear the lease - one of the previous tests may have different usermapper & thus different user 167 179 Foswiki::Func::setTopicEditLock( $this->{test_web}, $this->{test_topic}, 168 180 0 ); 181 182 return; 169 183 } 170 184 … … 175 189 return; 176 190 } 177 $this->{session}->finish();178 191 my $secret = "a big mole on my left buttock"; 179 192 my $crypted = crypt( $secret, "12" ); 180 193 $Foswiki::cfg{Password} = $crypted; 181 194 182 my $query = new Unit::Request(195 my $query = Unit::Request->new( 183 196 { 184 197 username => [ $Foswiki::cfg{AdminUserLogin} ], … … 190 203 $query->path_info("/$this->{test_web}/$this->{test_topic}"); 191 204 192 $this-> {session} = new Foswiki( undef, $query );205 $this->createNewFoswikiSession( undef, $query ); 193 206 $this->{session}->getLoginManager()->login( $query, $this->{session} ); 194 207 my $script = $Foswiki::cfg{LoginManager} =~ /Apache/ ? 'viewauth' : 'view'; … … 199 212 $this->assert_matches( qr/^$surly/, 200 213 $this->{session}->{response}->headers()->{Location} ); 214 215 return; 201 216 } 202 217
Note: See TracChangeset
for help on using the changeset viewer.
