[Httpunit-commit] CVS: httpunit/doc/tutorial/src/tutorial PoolEditorTest.java,1.1,1.2
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2001-11-27 16:40:51
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial/src/tutorial
In directory usw-pr-cvs1:/tmp/cvs-serv25123/doc/tutorial/src/tutorial
Modified Files:
PoolEditorTest.java
Log Message:
Added security to servlet unit tutorial
Index: PoolEditorTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/tutorial/src/tutorial/PoolEditorTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PoolEditorTest.java 2001/11/12 20:43:51 1.1
+++ PoolEditorTest.java 2001/11/27 16:40:47 1.2
@@ -11,7 +11,7 @@
public class PoolEditorTest extends TestCase {
- public static void main(String args[]) {
+ public static void main( String args[] ) {
junit.textui.TestRunner.run( suite() );
}
@@ -31,8 +31,15 @@
public void testGetForm() throws Exception {
ServletRunner sr = new ServletRunner( "web.xml" );
-
ServletUnitClient client = sr.newClient();
+
+ try {
+ client.getResponse( "http://localhost/PoolEditor" );
+ fail( "PoolEditor is not protected" );
+ } catch (AuthorizationRequiredException e) {
+ }
+
+ client.setAuthorization( "aUser", "pool-admin" );
client.getResponse( "http://localhost/PoolEditor" );
}
@@ -121,7 +128,7 @@
response = client.getResponse( request );
form = response.getFormWithID( "pool" );
- assertEquals( "Away team 0", "", form.getParameterValue( "home0" ) );
+ assertEquals( "Away team 0", "", form.getParameterValue( "away0" ) );
assertEquals( "Home team 0", "", form.getParameterValue( "home0" ) );
assertEquals( "Away team 1", "Detroit Lions", form.getParameterValue( "away1" ) );
assertEquals( "Home team 1", "Denver Broncos", form.getParameterValue( "home1" ) );
@@ -198,4 +205,5 @@
fail( "Could still edit the pool" );
} catch (IllegalRequestParameterException e) {}
}
+
}
|