Source Code Cross Referenced for TestEngineExpressionRoleUser.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » engine » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » rife 1.6.1 » com.uwyn.rife.engine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
0003:         * Distributed under the terms of either:
0004:         * - the common development and distribution license (CDDL), v1.0; or
0005:         * - the GNU Lesser General Public License, v2.1 or later
0006:         * $Id: TestEngineExpressionRoleUser.java 3643 2007-01-12 15:29:45Z gbevin $
0007:         */
0008:        package com.uwyn.rife.engine;
0009:
0010:        import com.meterware.httpunit.GetMethodWebRequest;
0011:        import com.meterware.httpunit.WebConversation;
0012:        import com.meterware.httpunit.WebRequest;
0013:        import com.meterware.httpunit.WebResponse;
0014:        import com.uwyn.rife.TestCaseServerside;
0015:        import com.uwyn.rife.authentication.credentialsmanagers.DatabaseUsers;
0016:        import com.uwyn.rife.authentication.credentialsmanagers.DatabaseUsersFactory;
0017:        import com.uwyn.rife.authentication.credentialsmanagers.RoleUserAttributes;
0018:        import com.uwyn.rife.authentication.exceptions.CredentialsManagerException;
0019:        import com.uwyn.rife.authentication.exceptions.SessionManagerException;
0020:        import com.uwyn.rife.authentication.sessionmanagers.DatabaseSessions;
0021:        import com.uwyn.rife.authentication.sessionmanagers.DatabaseSessionsFactory;
0022:        import com.uwyn.rife.authentication.sessionmanagers.SessionManagerFactoryFactory;
0023:        import com.uwyn.rife.config.Config;
0024:        import com.uwyn.rife.database.Datasource;
0025:        import com.uwyn.rife.database.Datasources;
0026:        import com.uwyn.rife.ioc.HierarchicalProperties;
0027:        import com.uwyn.rife.tools.ExceptionUtils;
0028:        import com.uwyn.rife.tools.StringEncryptor;
0029:        import com.uwyn.rife.tools.StringUtils;
0030:
0031:        public class TestEngineExpressionRoleUser extends TestCaseServerside {
0032:            private Datasource mDatasource = null;
0033:            private HierarchicalProperties mProperties = null;
0034:
0035:            public TestEngineExpressionRoleUser(int siteType, String name) {
0036:                super (siteType, name);
0037:            }
0038:
0039:            public void setUp() throws Exception {
0040:                super .setUp();
0041:
0042:                Config.getRepInstance().setParameter("unittestsdatasource",
0043:                        "unittestsderby");
0044:
0045:                mDatasource = Datasources.getRepInstance().getDatasource(
0046:                        "unittestsderby");
0047:                mProperties = new HierarchicalProperties();
0048:                mProperties.put("datasource", mDatasource);
0049:                mProperties
0050:                        .put(
0051:                                SessionManagerFactoryFactory.PROPERTYNAME_FACTORY_CLASS,
0052:                                DatabaseSessionsFactory.class.getName());
0053:
0054:                DatabaseUsers users = DatabaseUsersFactory
0055:                        .getInstance(mDatasource);
0056:                try {
0057:                    users.install();
0058:
0059:                    users.addRole("admin");
0060:                    users.addRole("maint");
0061:
0062:                    users.addUser("guest", new RoleUserAttributes(43,
0063:                            "guestpass"));
0064:                    users.addUser("gbevin", new RoleUserAttributes(1,
0065:                            "yeolpass", new String[] { "admin", "maint" }));
0066:                    users.addUser("johndoe", new RoleUserAttributes(174,
0067:                            "thepassofbass", new String[] { "maint" }));
0068:                    users.setPasswordEncryptor(StringEncryptor.SHA);
0069:                    users.addUser("guestencrypted", new RoleUserAttributes(44,
0070:                            "guestpass"));
0071:                    users.addUser("gbevinencrypted", new RoleUserAttributes(3,
0072:                            "yeolpass", new String[] { "admin", "maint" }));
0073:                    users.setPasswordEncryptor(null);
0074:                } catch (CredentialsManagerException e) {
0075:                    try {
0076:                        users.remove();
0077:                    } catch (CredentialsManagerException e2) {
0078:                        assertTrue(ExceptionUtils.getExceptionStackTrace(e2),
0079:                                false);
0080:                    }
0081:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0082:                }
0083:
0084:                DatabaseSessions sessions = (DatabaseSessions) SessionManagerFactoryFactory
0085:                        .getManager(mProperties);
0086:
0087:                try {
0088:                    sessions.install();
0089:                } catch (SessionManagerException e) {
0090:                    try {
0091:                        sessions.remove();
0092:                    } catch (SessionManagerException e2) {
0093:                        assertTrue(ExceptionUtils.getExceptionStackTrace(e2),
0094:                                false);
0095:                    }
0096:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0097:                }
0098:            }
0099:
0100:            public void tearDown() throws Exception {
0101:                DatabaseUsers users = DatabaseUsersFactory
0102:                        .getInstance(mDatasource);
0103:
0104:                try {
0105:                    users.remove();
0106:                } catch (CredentialsManagerException e) {
0107:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0108:                }
0109:
0110:                DatabaseSessions sessions = (DatabaseSessions) SessionManagerFactoryFactory
0111:                        .getManager(mProperties);
0112:
0113:                try {
0114:                    sessions.remove();
0115:                } catch (SessionManagerException e) {
0116:                    assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
0117:                }
0118:
0119:                Config.getRepInstance().removeParameter("unittestsdatasource");
0120:
0121:                super .tearDown();
0122:            }
0123:
0124:            public void testMemoryRoleAdminOgnl() throws Exception {
0125:                setupSite("site/roleuser_ognl.xml");
0126:
0127:                WebConversation conversation = new WebConversation();
0128:                WebRequest request = null;
0129:                WebResponse response = null;
0130:                String[] lines = null;
0131:
0132:                request = new GetMethodWebRequest(
0133:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevin&password=yeolpass");
0134:                response = conversation.getResponse(request);
0135:                assertEquals(0, response.getForms().length);
0136:                lines = StringUtils.splitToArray(response.getText(), "\n");
0137:                assertEquals("matching login", lines[0]);
0138:                assertEquals("matching password1", lines[1]);
0139:                assertEquals("not matching password2", lines[2]);
0140:                assertEquals("matching role1", lines[3]);
0141:                assertEquals("matching role2", lines[4]);
0142:                assertEquals("matching role3", lines[5]);
0143:                assertEquals("matching userid1", lines[6]);
0144:                assertEquals("not matching userid2", lines[7]);
0145:
0146:                request = new GetMethodWebRequest(
0147:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevinencrypted&password=yeolpass");
0148:                response = conversation.getResponse(request);
0149:                assertEquals(0, response.getForms().length);
0150:                lines = StringUtils.splitToArray(response.getText(), "\n");
0151:                assertEquals("not matching login", lines[0]);
0152:                assertEquals("not matching password1", lines[1]);
0153:                assertEquals("matching password2", lines[2]);
0154:                assertEquals("matching role1", lines[3]);
0155:                assertEquals("matching role2", lines[4]);
0156:                assertEquals("matching role3", lines[5]);
0157:                assertEquals("not matching userid1", lines[6]);
0158:                assertEquals("matching userid2", lines[7]);
0159:
0160:                request = new GetMethodWebRequest(
0161:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=johndoe&password=thepassofbass");
0162:                response = conversation.getResponse(request);
0163:                assertEquals(1, response.getForms().length);
0164:
0165:                request = new GetMethodWebRequest(
0166:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=guest&password=guestpass");
0167:                response = conversation.getResponse(request);
0168:                assertEquals(1, response.getForms().length);
0169:            }
0170:
0171:            public void testMemoryRoleMaintOgnl() throws Exception {
0172:                setupSite("site/roleuser_ognl.xml");
0173:
0174:                WebConversation conversation = new WebConversation();
0175:                WebRequest request = null;
0176:                WebResponse response = null;
0177:                String[] lines = null;
0178:
0179:                request = new GetMethodWebRequest(
0180:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=gbevin&password=yeolpass");
0181:                response = conversation.getResponse(request);
0182:                assertEquals(0, response.getForms().length);
0183:                lines = StringUtils.splitToArray(response.getText(), "\n");
0184:                assertEquals("matching login", lines[0]);
0185:                assertEquals("matching password1", lines[1]);
0186:                assertEquals("not matching password2", lines[2]);
0187:                assertEquals("matching role1", lines[3]);
0188:                assertEquals("matching role2", lines[4]);
0189:                assertEquals("matching role3", lines[5]);
0190:                assertEquals("matching userid1", lines[6]);
0191:                assertEquals("not matching userid2", lines[7]);
0192:
0193:                request = new GetMethodWebRequest(
0194:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=gbevinencrypted&password=yeolpass");
0195:                response = conversation.getResponse(request);
0196:                assertEquals(0, response.getForms().length);
0197:                lines = StringUtils.splitToArray(response.getText(), "\n");
0198:                assertEquals("not matching login", lines[0]);
0199:                assertEquals("not matching password1", lines[1]);
0200:                assertEquals("matching password2", lines[2]);
0201:                assertEquals("matching role1", lines[3]);
0202:                assertEquals("matching role2", lines[4]);
0203:                assertEquals("matching role3", lines[5]);
0204:                assertEquals("not matching userid1", lines[6]);
0205:                assertEquals("matching userid2", lines[7]);
0206:
0207:                request = new GetMethodWebRequest(
0208:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=johndoe&password=thepassofbass");
0209:                response = conversation.getResponse(request);
0210:                assertEquals(0, response.getForms().length);
0211:                lines = StringUtils.splitToArray(response.getText(), "\n");
0212:                assertEquals("not matching login", lines[0]);
0213:                assertEquals("not matching password1", lines[1]);
0214:                assertEquals("not matching password2", lines[2]);
0215:                assertEquals("not matching role1", lines[3]);
0216:                assertEquals("matching role2", lines[4]);
0217:                assertEquals("matching role3", lines[5]);
0218:                assertEquals("not matching userid1", lines[6]);
0219:                assertEquals("not matching userid2", lines[7]);
0220:
0221:                request = new GetMethodWebRequest(
0222:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=guest&password=guestpass");
0223:                response = conversation.getResponse(request);
0224:                assertEquals(1, response.getForms().length);
0225:            }
0226:
0227:            public void testIdentifiedOgnl() throws Exception {
0228:                setupSite("site/roleuser_ognl.xml");
0229:
0230:                WebConversation conversation = new WebConversation();
0231:                WebRequest request = null;
0232:                WebResponse response = null;
0233:                String[] lines = null;
0234:                String authid = null;
0235:
0236:                request = new GetMethodWebRequest(
0237:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevin&password=yeolpass");
0238:                response = conversation.getResponse(request);
0239:                lines = StringUtils.splitToArray(response.getText(), "\n");
0240:                authid = lines[8];
0241:                request = new GetMethodWebRequest(
0242:                        "http://localhost:8181/identified?authid=" + authid);
0243:                assertEquals(0, response.getForms().length);
0244:                lines = StringUtils.splitToArray(response.getText(), "\n");
0245:                assertEquals("matching login", lines[0]);
0246:                assertEquals("matching password1", lines[1]);
0247:                assertEquals("not matching password2", lines[2]);
0248:                assertEquals("matching role1", lines[3]);
0249:                assertEquals("matching role2", lines[4]);
0250:                assertEquals("matching role3", lines[5]);
0251:                assertEquals("matching userid1", lines[6]);
0252:                assertEquals("not matching userid2", lines[7]);
0253:
0254:                request = new GetMethodWebRequest(
0255:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevinencrypted&password=yeolpass");
0256:                response = conversation.getResponse(request);
0257:                lines = StringUtils.splitToArray(response.getText(), "\n");
0258:                authid = lines[8];
0259:                request = new GetMethodWebRequest(
0260:                        "http://localhost:8181/identified?authid=" + authid);
0261:                response = conversation.getResponse(request);
0262:                assertEquals(0, response.getForms().length);
0263:                lines = StringUtils.splitToArray(response.getText(), "\n");
0264:                assertEquals("not matching login", lines[0]);
0265:                assertEquals("not matching password1", lines[1]);
0266:                assertEquals("matching password2", lines[2]);
0267:                assertEquals("matching role1", lines[3]);
0268:                assertEquals("matching role2", lines[4]);
0269:                assertEquals("matching role3", lines[5]);
0270:                assertEquals("not matching userid1", lines[6]);
0271:                assertEquals("matching userid2", lines[7]);
0272:
0273:                request = new GetMethodWebRequest(
0274:                        "http://localhost:8181/identified?authid=blargh");
0275:                response = conversation.getResponse(request);
0276:                assertEquals(0, response.getForms().length);
0277:                lines = StringUtils.splitToArray(response.getText(), "\n");
0278:                assertEquals("not matching login", lines[0]);
0279:                assertEquals("not matching password1", lines[1]);
0280:                assertEquals("not matching password2", lines[2]);
0281:                assertEquals("not matching role1", lines[3]);
0282:                assertEquals("not matching role2", lines[4]);
0283:                assertEquals("not matching role3", lines[5]);
0284:                assertEquals("not matching userid1", lines[6]);
0285:                assertEquals("not matching userid2", lines[7]);
0286:            }
0287:
0288:            public void testExplicitEvaluationOgnl() throws Exception {
0289:                setupSite("site/roleuser_ognl.xml");
0290:
0291:                WebConversation conversation = new WebConversation();
0292:                WebRequest request = null;
0293:                WebResponse response = null;
0294:                String[] lines = null;
0295:
0296:                request = new GetMethodWebRequest(
0297:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass");
0298:                response = conversation.getResponse(request);
0299:                assertEquals(0, response.getForms().length);
0300:                lines = StringUtils.splitToArray(response.getText(), "\n");
0301:                assertEquals("not matching login", lines[0]);
0302:                assertEquals("not matching password1", lines[1]);
0303:                assertEquals("not matching password2", lines[2]);
0304:                assertEquals("not matching role1", lines[3]);
0305:                assertEquals("not matching role2", lines[4]);
0306:                assertEquals("not matching role3", lines[5]);
0307:                assertEquals("not matching userid1", lines[6]);
0308:                assertEquals("not matching userid2", lines[7]);
0309:
0310:                request = new GetMethodWebRequest(
0311:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=login");
0312:                response = conversation.getResponse(request);
0313:                assertEquals(0, response.getForms().length);
0314:                lines = StringUtils.splitToArray(response.getText(), "\n");
0315:                assertEquals("matching login", lines[0]);
0316:                assertEquals("not matching password1", lines[1]);
0317:                assertEquals("not matching password2", lines[2]);
0318:                assertEquals("not matching role1", lines[3]);
0319:                assertEquals("not matching role2", lines[4]);
0320:                assertEquals("not matching role3", lines[5]);
0321:                assertEquals("not matching userid1", lines[6]);
0322:                assertEquals("not matching userid2", lines[7]);
0323:
0324:                request = new GetMethodWebRequest(
0325:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=password1");
0326:                response = conversation.getResponse(request);
0327:                assertEquals(0, response.getForms().length);
0328:                lines = StringUtils.splitToArray(response.getText(), "\n");
0329:                assertEquals("not matching login", lines[0]);
0330:                assertEquals("matching password1", lines[1]);
0331:                assertEquals("not matching password2", lines[2]);
0332:                assertEquals("not matching role1", lines[3]);
0333:                assertEquals("not matching role2", lines[4]);
0334:                assertEquals("not matching role3", lines[5]);
0335:                assertEquals("not matching userid1", lines[6]);
0336:                assertEquals("not matching userid2", lines[7]);
0337:
0338:                request = new GetMethodWebRequest(
0339:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=password2");
0340:                response = conversation.getResponse(request);
0341:                assertEquals(0, response.getForms().length);
0342:                lines = StringUtils.splitToArray(response.getText(), "\n");
0343:                assertEquals("not matching login", lines[0]);
0344:                assertEquals("not matching password1", lines[1]);
0345:                assertEquals("not matching password2", lines[2]);
0346:                assertEquals("not matching role1", lines[3]);
0347:                assertEquals("not matching role2", lines[4]);
0348:                assertEquals("not matching role3", lines[5]);
0349:                assertEquals("not matching userid1", lines[6]);
0350:                assertEquals("not matching userid2", lines[7]);
0351:
0352:                request = new GetMethodWebRequest(
0353:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=role1&roleadmin=anotheradmin");
0354:                response = conversation.getResponse(request);
0355:                assertEquals(0, response.getForms().length);
0356:                lines = StringUtils.splitToArray(response.getText(), "\n");
0357:                assertEquals("not matching login", lines[0]);
0358:                assertEquals("not matching password1", lines[1]);
0359:                assertEquals("not matching password2", lines[2]);
0360:                assertEquals("not matching role1", lines[3]);
0361:                assertEquals("not matching role2", lines[4]);
0362:                assertEquals("not matching role3", lines[5]);
0363:                assertEquals("not matching userid1", lines[6]);
0364:                assertEquals("not matching userid2", lines[7]);
0365:
0366:                request = new GetMethodWebRequest(
0367:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=role1&roleadmin=admin");
0368:                response = conversation.getResponse(request);
0369:                assertEquals(0, response.getForms().length);
0370:                lines = StringUtils.splitToArray(response.getText(), "\n");
0371:                assertEquals("not matching login", lines[0]);
0372:                assertEquals("not matching password1", lines[1]);
0373:                assertEquals("not matching password2", lines[2]);
0374:                assertEquals("matching role1", lines[3]);
0375:                assertEquals("not matching role2", lines[4]);
0376:                assertEquals("not matching role3", lines[5]);
0377:                assertEquals("not matching userid1", lines[6]);
0378:                assertEquals("not matching userid2", lines[7]);
0379:            }
0380:
0381:            public void testDatabaseRoleAdminOgnl() throws Exception {
0382:                setupSite("site/roleuser_ognl.xml");
0383:
0384:                WebConversation conversation = new WebConversation();
0385:                WebRequest request = null;
0386:                WebResponse response = null;
0387:                String[] lines = null;
0388:
0389:                request = new GetMethodWebRequest(
0390:                        "http://localhost:8181/database/role_admin?submission=credentials&login=gbevin&password=yeolpass");
0391:                response = conversation.getResponse(request);
0392:                assertEquals(0, response.getForms().length);
0393:                lines = StringUtils.splitToArray(response.getText(), "\n");
0394:                assertEquals("matching login", lines[0]);
0395:                assertEquals("matching password1", lines[1]);
0396:                assertEquals("not matching password2", lines[2]);
0397:                assertEquals("matching role1", lines[3]);
0398:                assertEquals("matching role2", lines[4]);
0399:                assertEquals("matching role3", lines[5]);
0400:                assertEquals("matching userid1", lines[6]);
0401:                assertEquals("not matching userid2", lines[7]);
0402:
0403:                request = new GetMethodWebRequest(
0404:                        "http://localhost:8181/database/encrypted?submission=credentials&login=gbevinencrypted&password=yeolpass");
0405:                response = conversation.getResponse(request);
0406:                assertEquals(0, response.getForms().length);
0407:                lines = StringUtils.splitToArray(response.getText(), "\n");
0408:                assertEquals("not matching login", lines[0]);
0409:                assertEquals("not matching password1", lines[1]);
0410:                assertEquals("matching password2", lines[2]);
0411:                assertEquals("matching role1", lines[3]);
0412:                assertEquals("matching role2", lines[4]);
0413:                assertEquals("matching role3", lines[5]);
0414:                assertEquals("not matching userid1", lines[6]);
0415:                assertEquals("matching userid2", lines[7]);
0416:
0417:                request = new GetMethodWebRequest(
0418:                        "http://localhost:8181/database/role_admin?submission=credentials&login=johndoe&password=thepassofbass");
0419:                response = conversation.getResponse(request);
0420:                assertEquals(1, response.getForms().length);
0421:
0422:                request = new GetMethodWebRequest(
0423:                        "http://localhost:8181/database/role_admin?submission=credentials&login=guest&password=guestpass");
0424:                response = conversation.getResponse(request);
0425:                assertEquals(1, response.getForms().length);
0426:            }
0427:
0428:            public void testDatabaseRoleMaintOgnl() throws Exception {
0429:                setupSite("site/roleuser_ognl.xml");
0430:
0431:                WebConversation conversation = new WebConversation();
0432:                WebRequest request = null;
0433:                WebResponse response = null;
0434:                String[] lines = null;
0435:
0436:                request = new GetMethodWebRequest(
0437:                        "http://localhost:8181/database/role_maint?submission=credentials&login=gbevin&password=yeolpass");
0438:                response = conversation.getResponse(request);
0439:                assertEquals(0, response.getForms().length);
0440:                lines = StringUtils.splitToArray(response.getText(), "\n");
0441:                assertEquals("matching login", lines[0]);
0442:                assertEquals("matching password1", lines[1]);
0443:                assertEquals("not matching password2", lines[2]);
0444:                assertEquals("matching role1", lines[3]);
0445:                assertEquals("matching role2", lines[4]);
0446:                assertEquals("matching role3", lines[5]);
0447:                assertEquals("matching userid1", lines[6]);
0448:                assertEquals("not matching userid2", lines[7]);
0449:
0450:                request = new GetMethodWebRequest(
0451:                        "http://localhost:8181/database/encrypted?submission=credentials&login=gbevinencrypted&password=yeolpass");
0452:                response = conversation.getResponse(request);
0453:                assertEquals(0, response.getForms().length);
0454:                lines = StringUtils.splitToArray(response.getText(), "\n");
0455:                assertEquals("not matching login", lines[0]);
0456:                assertEquals("not matching password1", lines[1]);
0457:                assertEquals("matching password2", lines[2]);
0458:                assertEquals("matching role1", lines[3]);
0459:                assertEquals("matching role2", lines[4]);
0460:                assertEquals("matching role3", lines[5]);
0461:                assertEquals("not matching userid1", lines[6]);
0462:                assertEquals("matching userid2", lines[7]);
0463:
0464:                request = new GetMethodWebRequest(
0465:                        "http://localhost:8181/database/role_maint?submission=credentials&login=johndoe&password=thepassofbass");
0466:                response = conversation.getResponse(request);
0467:                assertEquals(0, response.getForms().length);
0468:                lines = StringUtils.splitToArray(response.getText(), "\n");
0469:                assertEquals("not matching login", lines[0]);
0470:                assertEquals("not matching password1", lines[1]);
0471:                assertEquals("not matching password2", lines[2]);
0472:                assertEquals("not matching role1", lines[3]);
0473:                assertEquals("matching role2", lines[4]);
0474:                assertEquals("matching role3", lines[5]);
0475:                assertEquals("not matching userid1", lines[6]);
0476:                assertEquals("not matching userid2", lines[7]);
0477:
0478:                request = new GetMethodWebRequest(
0479:                        "http://localhost:8181/database/role_admin?submission=credentials&login=guest&password=guestpass");
0480:                response = conversation.getResponse(request);
0481:                assertEquals(1, response.getForms().length);
0482:            }
0483:
0484:            public void testMemoryRoleAdminMvel() throws Exception {
0485:                setupSite("site/roleuser_mvel.xml");
0486:
0487:                WebConversation conversation = new WebConversation();
0488:                WebRequest request = null;
0489:                WebResponse response = null;
0490:                String[] lines = null;
0491:
0492:                request = new GetMethodWebRequest(
0493:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevin&password=yeolpass");
0494:                response = conversation.getResponse(request);
0495:                assertEquals(0, response.getForms().length);
0496:                lines = StringUtils.splitToArray(response.getText(), "\n");
0497:                assertEquals("matching login", lines[0]);
0498:                assertEquals("matching password1", lines[1]);
0499:                assertEquals("not matching password2", lines[2]);
0500:                assertEquals("matching role1", lines[3]);
0501:                assertEquals("matching role2", lines[4]);
0502:                assertEquals("matching role3", lines[5]);
0503:                assertEquals("matching userid1", lines[6]);
0504:                assertEquals("not matching userid2", lines[7]);
0505:
0506:                request = new GetMethodWebRequest(
0507:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevinencrypted&password=yeolpass");
0508:                response = conversation.getResponse(request);
0509:                assertEquals(0, response.getForms().length);
0510:                lines = StringUtils.splitToArray(response.getText(), "\n");
0511:                assertEquals("not matching login", lines[0]);
0512:                assertEquals("not matching password1", lines[1]);
0513:                assertEquals("matching password2", lines[2]);
0514:                assertEquals("matching role1", lines[3]);
0515:                assertEquals("matching role2", lines[4]);
0516:                assertEquals("matching role3", lines[5]);
0517:                assertEquals("not matching userid1", lines[6]);
0518:                assertEquals("matching userid2", lines[7]);
0519:
0520:                request = new GetMethodWebRequest(
0521:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=johndoe&password=thepassofbass");
0522:                response = conversation.getResponse(request);
0523:                assertEquals(1, response.getForms().length);
0524:
0525:                request = new GetMethodWebRequest(
0526:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=guest&password=guestpass");
0527:                response = conversation.getResponse(request);
0528:                assertEquals(1, response.getForms().length);
0529:            }
0530:
0531:            public void testMemoryRoleMaintMvel() throws Exception {
0532:                setupSite("site/roleuser_mvel.xml");
0533:
0534:                WebConversation conversation = new WebConversation();
0535:                WebRequest request = null;
0536:                WebResponse response = null;
0537:                String[] lines = null;
0538:
0539:                request = new GetMethodWebRequest(
0540:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=gbevin&password=yeolpass");
0541:                response = conversation.getResponse(request);
0542:                assertEquals(0, response.getForms().length);
0543:                lines = StringUtils.splitToArray(response.getText(), "\n");
0544:                assertEquals("matching login", lines[0]);
0545:                assertEquals("matching password1", lines[1]);
0546:                assertEquals("not matching password2", lines[2]);
0547:                assertEquals("matching role1", lines[3]);
0548:                assertEquals("matching role2", lines[4]);
0549:                assertEquals("matching role3", lines[5]);
0550:                assertEquals("matching userid1", lines[6]);
0551:                assertEquals("not matching userid2", lines[7]);
0552:
0553:                request = new GetMethodWebRequest(
0554:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=gbevinencrypted&password=yeolpass");
0555:                response = conversation.getResponse(request);
0556:                assertEquals(0, response.getForms().length);
0557:                lines = StringUtils.splitToArray(response.getText(), "\n");
0558:                assertEquals("not matching login", lines[0]);
0559:                assertEquals("not matching password1", lines[1]);
0560:                assertEquals("matching password2", lines[2]);
0561:                assertEquals("matching role1", lines[3]);
0562:                assertEquals("matching role2", lines[4]);
0563:                assertEquals("matching role3", lines[5]);
0564:                assertEquals("not matching userid1", lines[6]);
0565:                assertEquals("matching userid2", lines[7]);
0566:
0567:                request = new GetMethodWebRequest(
0568:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=johndoe&password=thepassofbass");
0569:                response = conversation.getResponse(request);
0570:                assertEquals(0, response.getForms().length);
0571:                lines = StringUtils.splitToArray(response.getText(), "\n");
0572:                assertEquals("not matching login", lines[0]);
0573:                assertEquals("not matching password1", lines[1]);
0574:                assertEquals("not matching password2", lines[2]);
0575:                assertEquals("not matching role1", lines[3]);
0576:                assertEquals("matching role2", lines[4]);
0577:                assertEquals("matching role3", lines[5]);
0578:                assertEquals("not matching userid1", lines[6]);
0579:                assertEquals("not matching userid2", lines[7]);
0580:
0581:                request = new GetMethodWebRequest(
0582:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=guest&password=guestpass");
0583:                response = conversation.getResponse(request);
0584:                assertEquals(1, response.getForms().length);
0585:            }
0586:
0587:            public void testIdentifiedMvel() throws Exception {
0588:                setupSite("site/roleuser_mvel.xml");
0589:
0590:                WebConversation conversation = new WebConversation();
0591:                WebRequest request = null;
0592:                WebResponse response = null;
0593:                String[] lines = null;
0594:                String authid = null;
0595:
0596:                request = new GetMethodWebRequest(
0597:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevin&password=yeolpass");
0598:                response = conversation.getResponse(request);
0599:                lines = StringUtils.splitToArray(response.getText(), "\n");
0600:                authid = lines[8];
0601:                request = new GetMethodWebRequest(
0602:                        "http://localhost:8181/identified?authid=" + authid);
0603:                assertEquals(0, response.getForms().length);
0604:                lines = StringUtils.splitToArray(response.getText(), "\n");
0605:                assertEquals("matching login", lines[0]);
0606:                assertEquals("matching password1", lines[1]);
0607:                assertEquals("not matching password2", lines[2]);
0608:                assertEquals("matching role1", lines[3]);
0609:                assertEquals("matching role2", lines[4]);
0610:                assertEquals("matching role3", lines[5]);
0611:                assertEquals("matching userid1", lines[6]);
0612:                assertEquals("not matching userid2", lines[7]);
0613:
0614:                request = new GetMethodWebRequest(
0615:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevinencrypted&password=yeolpass");
0616:                response = conversation.getResponse(request);
0617:                lines = StringUtils.splitToArray(response.getText(), "\n");
0618:                authid = lines[8];
0619:                request = new GetMethodWebRequest(
0620:                        "http://localhost:8181/identified?authid=" + authid);
0621:                response = conversation.getResponse(request);
0622:                assertEquals(0, response.getForms().length);
0623:                lines = StringUtils.splitToArray(response.getText(), "\n");
0624:                assertEquals("not matching login", lines[0]);
0625:                assertEquals("not matching password1", lines[1]);
0626:                assertEquals("matching password2", lines[2]);
0627:                assertEquals("matching role1", lines[3]);
0628:                assertEquals("matching role2", lines[4]);
0629:                assertEquals("matching role3", lines[5]);
0630:                assertEquals("not matching userid1", lines[6]);
0631:                assertEquals("matching userid2", lines[7]);
0632:
0633:                request = new GetMethodWebRequest(
0634:                        "http://localhost:8181/identified?authid=blargh");
0635:                response = conversation.getResponse(request);
0636:                assertEquals(0, response.getForms().length);
0637:                lines = StringUtils.splitToArray(response.getText(), "\n");
0638:                assertEquals("not matching login", lines[0]);
0639:                assertEquals("not matching password1", lines[1]);
0640:                assertEquals("not matching password2", lines[2]);
0641:                assertEquals("not matching role1", lines[3]);
0642:                assertEquals("not matching role2", lines[4]);
0643:                assertEquals("not matching role3", lines[5]);
0644:                assertEquals("not matching userid1", lines[6]);
0645:                assertEquals("not matching userid2", lines[7]);
0646:            }
0647:
0648:            public void testExplicitEvaluationMvel() throws Exception {
0649:                setupSite("site/roleuser_mvel.xml");
0650:
0651:                WebConversation conversation = new WebConversation();
0652:                WebRequest request = null;
0653:                WebResponse response = null;
0654:                String[] lines = null;
0655:
0656:                request = new GetMethodWebRequest(
0657:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass");
0658:                response = conversation.getResponse(request);
0659:                assertEquals(0, response.getForms().length);
0660:                lines = StringUtils.splitToArray(response.getText(), "\n");
0661:                assertEquals("not matching login", lines[0]);
0662:                assertEquals("not matching password1", lines[1]);
0663:                assertEquals("not matching password2", lines[2]);
0664:                assertEquals("not matching role1", lines[3]);
0665:                assertEquals("not matching role2", lines[4]);
0666:                assertEquals("not matching role3", lines[5]);
0667:                assertEquals("not matching userid1", lines[6]);
0668:                assertEquals("not matching userid2", lines[7]);
0669:
0670:                request = new GetMethodWebRequest(
0671:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=login");
0672:                response = conversation.getResponse(request);
0673:                assertEquals(0, response.getForms().length);
0674:                lines = StringUtils.splitToArray(response.getText(), "\n");
0675:                assertEquals("matching login", lines[0]);
0676:                assertEquals("not matching password1", lines[1]);
0677:                assertEquals("not matching password2", lines[2]);
0678:                assertEquals("not matching role1", lines[3]);
0679:                assertEquals("not matching role2", lines[4]);
0680:                assertEquals("not matching role3", lines[5]);
0681:                assertEquals("not matching userid1", lines[6]);
0682:                assertEquals("not matching userid2", lines[7]);
0683:
0684:                request = new GetMethodWebRequest(
0685:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=password1");
0686:                response = conversation.getResponse(request);
0687:                assertEquals(0, response.getForms().length);
0688:                lines = StringUtils.splitToArray(response.getText(), "\n");
0689:                assertEquals("not matching login", lines[0]);
0690:                assertEquals("matching password1", lines[1]);
0691:                assertEquals("not matching password2", lines[2]);
0692:                assertEquals("not matching role1", lines[3]);
0693:                assertEquals("not matching role2", lines[4]);
0694:                assertEquals("not matching role3", lines[5]);
0695:                assertEquals("not matching userid1", lines[6]);
0696:                assertEquals("not matching userid2", lines[7]);
0697:
0698:                request = new GetMethodWebRequest(
0699:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=password2");
0700:                response = conversation.getResponse(request);
0701:                assertEquals(0, response.getForms().length);
0702:                lines = StringUtils.splitToArray(response.getText(), "\n");
0703:                assertEquals("not matching login", lines[0]);
0704:                assertEquals("not matching password1", lines[1]);
0705:                assertEquals("not matching password2", lines[2]);
0706:                assertEquals("not matching role1", lines[3]);
0707:                assertEquals("not matching role2", lines[4]);
0708:                assertEquals("not matching role3", lines[5]);
0709:                assertEquals("not matching userid1", lines[6]);
0710:                assertEquals("not matching userid2", lines[7]);
0711:
0712:                request = new GetMethodWebRequest(
0713:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=role1&roleadmin=anotheradmin");
0714:                response = conversation.getResponse(request);
0715:                assertEquals(0, response.getForms().length);
0716:                lines = StringUtils.splitToArray(response.getText(), "\n");
0717:                assertEquals("not matching login", lines[0]);
0718:                assertEquals("not matching password1", lines[1]);
0719:                assertEquals("not matching password2", lines[2]);
0720:                assertEquals("not matching role1", lines[3]);
0721:                assertEquals("not matching role2", lines[4]);
0722:                assertEquals("not matching role3", lines[5]);
0723:                assertEquals("not matching userid1", lines[6]);
0724:                assertEquals("not matching userid2", lines[7]);
0725:
0726:                request = new GetMethodWebRequest(
0727:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=role1&roleadmin=admin");
0728:                response = conversation.getResponse(request);
0729:                assertEquals(0, response.getForms().length);
0730:                lines = StringUtils.splitToArray(response.getText(), "\n");
0731:                assertEquals("not matching login", lines[0]);
0732:                assertEquals("not matching password1", lines[1]);
0733:                assertEquals("not matching password2", lines[2]);
0734:                assertEquals("matching role1", lines[3]);
0735:                assertEquals("not matching role2", lines[4]);
0736:                assertEquals("not matching role3", lines[5]);
0737:                assertEquals("not matching userid1", lines[6]);
0738:                assertEquals("not matching userid2", lines[7]);
0739:            }
0740:
0741:            public void testDatabaseRoleAdminMvel() throws Exception {
0742:                setupSite("site/roleuser_mvel.xml");
0743:
0744:                WebConversation conversation = new WebConversation();
0745:                WebRequest request = null;
0746:                WebResponse response = null;
0747:                String[] lines = null;
0748:
0749:                request = new GetMethodWebRequest(
0750:                        "http://localhost:8181/database/role_admin?submission=credentials&login=gbevin&password=yeolpass");
0751:                response = conversation.getResponse(request);
0752:                assertEquals(0, response.getForms().length);
0753:                lines = StringUtils.splitToArray(response.getText(), "\n");
0754:                assertEquals("matching login", lines[0]);
0755:                assertEquals("matching password1", lines[1]);
0756:                assertEquals("not matching password2", lines[2]);
0757:                assertEquals("matching role1", lines[3]);
0758:                assertEquals("matching role2", lines[4]);
0759:                assertEquals("matching role3", lines[5]);
0760:                assertEquals("matching userid1", lines[6]);
0761:                assertEquals("not matching userid2", lines[7]);
0762:
0763:                request = new GetMethodWebRequest(
0764:                        "http://localhost:8181/database/encrypted?submission=credentials&login=gbevinencrypted&password=yeolpass");
0765:                response = conversation.getResponse(request);
0766:                assertEquals(0, response.getForms().length);
0767:                lines = StringUtils.splitToArray(response.getText(), "\n");
0768:                assertEquals("not matching login", lines[0]);
0769:                assertEquals("not matching password1", lines[1]);
0770:                assertEquals("matching password2", lines[2]);
0771:                assertEquals("matching role1", lines[3]);
0772:                assertEquals("matching role2", lines[4]);
0773:                assertEquals("matching role3", lines[5]);
0774:                assertEquals("not matching userid1", lines[6]);
0775:                assertEquals("matching userid2", lines[7]);
0776:
0777:                request = new GetMethodWebRequest(
0778:                        "http://localhost:8181/database/role_admin?submission=credentials&login=johndoe&password=thepassofbass");
0779:                response = conversation.getResponse(request);
0780:                assertEquals(1, response.getForms().length);
0781:
0782:                request = new GetMethodWebRequest(
0783:                        "http://localhost:8181/database/role_admin?submission=credentials&login=guest&password=guestpass");
0784:                response = conversation.getResponse(request);
0785:                assertEquals(1, response.getForms().length);
0786:            }
0787:
0788:            public void testDatabaseRoleMaintMvel() throws Exception {
0789:                setupSite("site/roleuser_mvel.xml");
0790:
0791:                WebConversation conversation = new WebConversation();
0792:                WebRequest request = null;
0793:                WebResponse response = null;
0794:                String[] lines = null;
0795:
0796:                request = new GetMethodWebRequest(
0797:                        "http://localhost:8181/database/role_maint?submission=credentials&login=gbevin&password=yeolpass");
0798:                response = conversation.getResponse(request);
0799:                assertEquals(0, response.getForms().length);
0800:                lines = StringUtils.splitToArray(response.getText(), "\n");
0801:                assertEquals("matching login", lines[0]);
0802:                assertEquals("matching password1", lines[1]);
0803:                assertEquals("not matching password2", lines[2]);
0804:                assertEquals("matching role1", lines[3]);
0805:                assertEquals("matching role2", lines[4]);
0806:                assertEquals("matching role3", lines[5]);
0807:                assertEquals("matching userid1", lines[6]);
0808:                assertEquals("not matching userid2", lines[7]);
0809:
0810:                request = new GetMethodWebRequest(
0811:                        "http://localhost:8181/database/encrypted?submission=credentials&login=gbevinencrypted&password=yeolpass");
0812:                response = conversation.getResponse(request);
0813:                assertEquals(0, response.getForms().length);
0814:                lines = StringUtils.splitToArray(response.getText(), "\n");
0815:                assertEquals("not matching login", lines[0]);
0816:                assertEquals("not matching password1", lines[1]);
0817:                assertEquals("matching password2", lines[2]);
0818:                assertEquals("matching role1", lines[3]);
0819:                assertEquals("matching role2", lines[4]);
0820:                assertEquals("matching role3", lines[5]);
0821:                assertEquals("not matching userid1", lines[6]);
0822:                assertEquals("matching userid2", lines[7]);
0823:
0824:                request = new GetMethodWebRequest(
0825:                        "http://localhost:8181/database/role_maint?submission=credentials&login=johndoe&password=thepassofbass");
0826:                response = conversation.getResponse(request);
0827:                assertEquals(0, response.getForms().length);
0828:                lines = StringUtils.splitToArray(response.getText(), "\n");
0829:                assertEquals("not matching login", lines[0]);
0830:                assertEquals("not matching password1", lines[1]);
0831:                assertEquals("not matching password2", lines[2]);
0832:                assertEquals("not matching role1", lines[3]);
0833:                assertEquals("matching role2", lines[4]);
0834:                assertEquals("matching role3", lines[5]);
0835:                assertEquals("not matching userid1", lines[6]);
0836:                assertEquals("not matching userid2", lines[7]);
0837:
0838:                request = new GetMethodWebRequest(
0839:                        "http://localhost:8181/database/role_admin?submission=credentials&login=guest&password=guestpass");
0840:                response = conversation.getResponse(request);
0841:                assertEquals(1, response.getForms().length);
0842:            }
0843:
0844:            public void testMemoryRoleAdminGroovy() throws Exception {
0845:                setupSite("site/roleuser_groovy.xml");
0846:
0847:                WebConversation conversation = new WebConversation();
0848:                WebRequest request = null;
0849:                WebResponse response = null;
0850:                String[] lines = null;
0851:
0852:                request = new GetMethodWebRequest(
0853:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevin&password=yeolpass");
0854:                response = conversation.getResponse(request);
0855:                assertEquals(0, response.getForms().length);
0856:                lines = StringUtils.splitToArray(response.getText(), "\n");
0857:                assertEquals("matching login", lines[0]);
0858:                assertEquals("matching password1", lines[1]);
0859:                assertEquals("not matching password2", lines[2]);
0860:                assertEquals("matching role1", lines[3]);
0861:                assertEquals("matching role2", lines[4]);
0862:                assertEquals("matching role3", lines[5]);
0863:                assertEquals("matching userid1", lines[6]);
0864:                assertEquals("not matching userid2", lines[7]);
0865:
0866:                request = new GetMethodWebRequest(
0867:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevinencrypted&password=yeolpass");
0868:                response = conversation.getResponse(request);
0869:                assertEquals(0, response.getForms().length);
0870:                lines = StringUtils.splitToArray(response.getText(), "\n");
0871:                assertEquals("not matching login", lines[0]);
0872:                assertEquals("not matching password1", lines[1]);
0873:                assertEquals("matching password2", lines[2]);
0874:                assertEquals("matching role1", lines[3]);
0875:                assertEquals("matching role2", lines[4]);
0876:                assertEquals("matching role3", lines[5]);
0877:                assertEquals("not matching userid1", lines[6]);
0878:                assertEquals("matching userid2", lines[7]);
0879:
0880:                request = new GetMethodWebRequest(
0881:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=johndoe&password=thepassofbass");
0882:                response = conversation.getResponse(request);
0883:                assertEquals(1, response.getForms().length);
0884:
0885:                request = new GetMethodWebRequest(
0886:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=guest&password=guestpass");
0887:                response = conversation.getResponse(request);
0888:                assertEquals(1, response.getForms().length);
0889:            }
0890:
0891:            public void testMemoryRoleMaintGroovy() throws Exception {
0892:                setupSite("site/roleuser_groovy.xml");
0893:
0894:                WebConversation conversation = new WebConversation();
0895:                WebRequest request = null;
0896:                WebResponse response = null;
0897:                String[] lines = null;
0898:
0899:                request = new GetMethodWebRequest(
0900:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=gbevin&password=yeolpass");
0901:                response = conversation.getResponse(request);
0902:                assertEquals(0, response.getForms().length);
0903:                lines = StringUtils.splitToArray(response.getText(), "\n");
0904:                assertEquals("matching login", lines[0]);
0905:                assertEquals("matching password1", lines[1]);
0906:                assertEquals("not matching password2", lines[2]);
0907:                assertEquals("matching role1", lines[3]);
0908:                assertEquals("matching role2", lines[4]);
0909:                assertEquals("matching role3", lines[5]);
0910:                assertEquals("matching userid1", lines[6]);
0911:                assertEquals("not matching userid2", lines[7]);
0912:
0913:                request = new GetMethodWebRequest(
0914:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=gbevinencrypted&password=yeolpass");
0915:                response = conversation.getResponse(request);
0916:                assertEquals(0, response.getForms().length);
0917:                lines = StringUtils.splitToArray(response.getText(), "\n");
0918:                assertEquals("not matching login", lines[0]);
0919:                assertEquals("not matching password1", lines[1]);
0920:                assertEquals("matching password2", lines[2]);
0921:                assertEquals("matching role1", lines[3]);
0922:                assertEquals("matching role2", lines[4]);
0923:                assertEquals("matching role3", lines[5]);
0924:                assertEquals("not matching userid1", lines[6]);
0925:                assertEquals("matching userid2", lines[7]);
0926:
0927:                request = new GetMethodWebRequest(
0928:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=johndoe&password=thepassofbass");
0929:                response = conversation.getResponse(request);
0930:                assertEquals(0, response.getForms().length);
0931:                lines = StringUtils.splitToArray(response.getText(), "\n");
0932:                assertEquals("not matching login", lines[0]);
0933:                assertEquals("not matching password1", lines[1]);
0934:                assertEquals("not matching password2", lines[2]);
0935:                assertEquals("not matching role1", lines[3]);
0936:                assertEquals("matching role2", lines[4]);
0937:                assertEquals("matching role3", lines[5]);
0938:                assertEquals("not matching userid1", lines[6]);
0939:                assertEquals("not matching userid2", lines[7]);
0940:
0941:                request = new GetMethodWebRequest(
0942:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=guest&password=guestpass");
0943:                response = conversation.getResponse(request);
0944:                assertEquals(1, response.getForms().length);
0945:            }
0946:
0947:            public void testIdentifiedGroovy() throws Exception {
0948:                setupSite("site/roleuser_groovy.xml");
0949:
0950:                WebConversation conversation = new WebConversation();
0951:                WebRequest request = null;
0952:                WebResponse response = null;
0953:                String[] lines = null;
0954:                String authid = null;
0955:
0956:                request = new GetMethodWebRequest(
0957:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevin&password=yeolpass");
0958:                response = conversation.getResponse(request);
0959:                lines = StringUtils.splitToArray(response.getText(), "\n");
0960:                authid = lines[8];
0961:                request = new GetMethodWebRequest(
0962:                        "http://localhost:8181/identified?authid=" + authid);
0963:                assertEquals(0, response.getForms().length);
0964:                lines = StringUtils.splitToArray(response.getText(), "\n");
0965:                assertEquals("matching login", lines[0]);
0966:                assertEquals("matching password1", lines[1]);
0967:                assertEquals("not matching password2", lines[2]);
0968:                assertEquals("matching role1", lines[3]);
0969:                assertEquals("matching role2", lines[4]);
0970:                assertEquals("matching role3", lines[5]);
0971:                assertEquals("matching userid1", lines[6]);
0972:                assertEquals("not matching userid2", lines[7]);
0973:
0974:                request = new GetMethodWebRequest(
0975:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevinencrypted&password=yeolpass");
0976:                response = conversation.getResponse(request);
0977:                lines = StringUtils.splitToArray(response.getText(), "\n");
0978:                authid = lines[8];
0979:                request = new GetMethodWebRequest(
0980:                        "http://localhost:8181/identified?authid=" + authid);
0981:                response = conversation.getResponse(request);
0982:                assertEquals(0, response.getForms().length);
0983:                lines = StringUtils.splitToArray(response.getText(), "\n");
0984:                assertEquals("not matching login", lines[0]);
0985:                assertEquals("not matching password1", lines[1]);
0986:                assertEquals("matching password2", lines[2]);
0987:                assertEquals("matching role1", lines[3]);
0988:                assertEquals("matching role2", lines[4]);
0989:                assertEquals("matching role3", lines[5]);
0990:                assertEquals("not matching userid1", lines[6]);
0991:                assertEquals("matching userid2", lines[7]);
0992:
0993:                request = new GetMethodWebRequest(
0994:                        "http://localhost:8181/identified?authid=blargh");
0995:                response = conversation.getResponse(request);
0996:                assertEquals(0, response.getForms().length);
0997:                lines = StringUtils.splitToArray(response.getText(), "\n");
0998:                assertEquals("not matching login", lines[0]);
0999:                assertEquals("not matching password1", lines[1]);
1000:                assertEquals("not matching password2", lines[2]);
1001:                assertEquals("not matching role1", lines[3]);
1002:                assertEquals("not matching role2", lines[4]);
1003:                assertEquals("not matching role3", lines[5]);
1004:                assertEquals("not matching userid1", lines[6]);
1005:                assertEquals("not matching userid2", lines[7]);
1006:            }
1007:
1008:            public void testExplicitEvaluationGroovy() throws Exception {
1009:                setupSite("site/roleuser_groovy.xml");
1010:
1011:                WebConversation conversation = new WebConversation();
1012:                WebRequest request = null;
1013:                WebResponse response = null;
1014:                String[] lines = null;
1015:
1016:                request = new GetMethodWebRequest(
1017:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass");
1018:                response = conversation.getResponse(request);
1019:                assertEquals(0, response.getForms().length);
1020:                lines = StringUtils.splitToArray(response.getText(), "\n");
1021:                assertEquals("not matching login", lines[0]);
1022:                assertEquals("not matching password1", lines[1]);
1023:                assertEquals("not matching password2", lines[2]);
1024:                assertEquals("not matching role1", lines[3]);
1025:                assertEquals("not matching role2", lines[4]);
1026:                assertEquals("not matching role3", lines[5]);
1027:                assertEquals("not matching userid1", lines[6]);
1028:                assertEquals("not matching userid2", lines[7]);
1029:
1030:                request = new GetMethodWebRequest(
1031:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=login");
1032:                response = conversation.getResponse(request);
1033:                assertEquals(0, response.getForms().length);
1034:                lines = StringUtils.splitToArray(response.getText(), "\n");
1035:                assertEquals("matching login", lines[0]);
1036:                assertEquals("not matching password1", lines[1]);
1037:                assertEquals("not matching password2", lines[2]);
1038:                assertEquals("not matching role1", lines[3]);
1039:                assertEquals("not matching role2", lines[4]);
1040:                assertEquals("not matching role3", lines[5]);
1041:                assertEquals("not matching userid1", lines[6]);
1042:                assertEquals("not matching userid2", lines[7]);
1043:
1044:                request = new GetMethodWebRequest(
1045:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=password1");
1046:                response = conversation.getResponse(request);
1047:                assertEquals(0, response.getForms().length);
1048:                lines = StringUtils.splitToArray(response.getText(), "\n");
1049:                assertEquals("not matching login", lines[0]);
1050:                assertEquals("matching password1", lines[1]);
1051:                assertEquals("not matching password2", lines[2]);
1052:                assertEquals("not matching role1", lines[3]);
1053:                assertEquals("not matching role2", lines[4]);
1054:                assertEquals("not matching role3", lines[5]);
1055:                assertEquals("not matching userid1", lines[6]);
1056:                assertEquals("not matching userid2", lines[7]);
1057:
1058:                request = new GetMethodWebRequest(
1059:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=password2");
1060:                response = conversation.getResponse(request);
1061:                assertEquals(0, response.getForms().length);
1062:                lines = StringUtils.splitToArray(response.getText(), "\n");
1063:                assertEquals("not matching login", lines[0]);
1064:                assertEquals("not matching password1", lines[1]);
1065:                assertEquals("not matching password2", lines[2]);
1066:                assertEquals("not matching role1", lines[3]);
1067:                assertEquals("not matching role2", lines[4]);
1068:                assertEquals("not matching role3", lines[5]);
1069:                assertEquals("not matching userid1", lines[6]);
1070:                assertEquals("not matching userid2", lines[7]);
1071:
1072:                request = new GetMethodWebRequest(
1073:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=role1&roleadmin=anotheradmin");
1074:                response = conversation.getResponse(request);
1075:                assertEquals(0, response.getForms().length);
1076:                lines = StringUtils.splitToArray(response.getText(), "\n");
1077:                assertEquals("not matching login", lines[0]);
1078:                assertEquals("not matching password1", lines[1]);
1079:                assertEquals("not matching password2", lines[2]);
1080:                assertEquals("not matching role1", lines[3]);
1081:                assertEquals("not matching role2", lines[4]);
1082:                assertEquals("not matching role3", lines[5]);
1083:                assertEquals("not matching userid1", lines[6]);
1084:                assertEquals("not matching userid2", lines[7]);
1085:
1086:                request = new GetMethodWebRequest(
1087:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=role1&roleadmin=admin");
1088:                response = conversation.getResponse(request);
1089:                assertEquals(0, response.getForms().length);
1090:                lines = StringUtils.splitToArray(response.getText(), "\n");
1091:                assertEquals("not matching login", lines[0]);
1092:                assertEquals("not matching password1", lines[1]);
1093:                assertEquals("not matching password2", lines[2]);
1094:                assertEquals("matching role1", lines[3]);
1095:                assertEquals("not matching role2", lines[4]);
1096:                assertEquals("not matching role3", lines[5]);
1097:                assertEquals("not matching userid1", lines[6]);
1098:                assertEquals("not matching userid2", lines[7]);
1099:            }
1100:
1101:            public void testDatabaseRoleAdminGroovy() throws Exception {
1102:                setupSite("site/roleuser_groovy.xml");
1103:
1104:                WebConversation conversation = new WebConversation();
1105:                WebRequest request = null;
1106:                WebResponse response = null;
1107:                String[] lines = null;
1108:
1109:                request = new GetMethodWebRequest(
1110:                        "http://localhost:8181/database/role_admin?submission=credentials&login=gbevin&password=yeolpass");
1111:                response = conversation.getResponse(request);
1112:                assertEquals(0, response.getForms().length);
1113:                lines = StringUtils.splitToArray(response.getText(), "\n");
1114:                assertEquals("matching login", lines[0]);
1115:                assertEquals("matching password1", lines[1]);
1116:                assertEquals("not matching password2", lines[2]);
1117:                assertEquals("matching role1", lines[3]);
1118:                assertEquals("matching role2", lines[4]);
1119:                assertEquals("matching role3", lines[5]);
1120:                assertEquals("matching userid1", lines[6]);
1121:                assertEquals("not matching userid2", lines[7]);
1122:
1123:                request = new GetMethodWebRequest(
1124:                        "http://localhost:8181/database/encrypted?submission=credentials&login=gbevinencrypted&password=yeolpass");
1125:                response = conversation.getResponse(request);
1126:                assertEquals(0, response.getForms().length);
1127:                lines = StringUtils.splitToArray(response.getText(), "\n");
1128:                assertEquals("not matching login", lines[0]);
1129:                assertEquals("not matching password1", lines[1]);
1130:                assertEquals("matching password2", lines[2]);
1131:                assertEquals("matching role1", lines[3]);
1132:                assertEquals("matching role2", lines[4]);
1133:                assertEquals("matching role3", lines[5]);
1134:                assertEquals("not matching userid1", lines[6]);
1135:                assertEquals("matching userid2", lines[7]);
1136:
1137:                request = new GetMethodWebRequest(
1138:                        "http://localhost:8181/database/role_admin?submission=credentials&login=johndoe&password=thepassofbass");
1139:                response = conversation.getResponse(request);
1140:                assertEquals(1, response.getForms().length);
1141:
1142:                request = new GetMethodWebRequest(
1143:                        "http://localhost:8181/database/role_admin?submission=credentials&login=guest&password=guestpass");
1144:                response = conversation.getResponse(request);
1145:                assertEquals(1, response.getForms().length);
1146:            }
1147:
1148:            public void testDatabaseRoleMaintGroovy() throws Exception {
1149:                setupSite("site/roleuser_groovy.xml");
1150:
1151:                WebConversation conversation = new WebConversation();
1152:                WebRequest request = null;
1153:                WebResponse response = null;
1154:                String[] lines = null;
1155:
1156:                request = new GetMethodWebRequest(
1157:                        "http://localhost:8181/database/role_maint?submission=credentials&login=gbevin&password=yeolpass");
1158:                response = conversation.getResponse(request);
1159:                assertEquals(0, response.getForms().length);
1160:                lines = StringUtils.splitToArray(response.getText(), "\n");
1161:                assertEquals("matching login", lines[0]);
1162:                assertEquals("matching password1", lines[1]);
1163:                assertEquals("not matching password2", lines[2]);
1164:                assertEquals("matching role1", lines[3]);
1165:                assertEquals("matching role2", lines[4]);
1166:                assertEquals("matching role3", lines[5]);
1167:                assertEquals("matching userid1", lines[6]);
1168:                assertEquals("not matching userid2", lines[7]);
1169:
1170:                request = new GetMethodWebRequest(
1171:                        "http://localhost:8181/database/encrypted?submission=credentials&login=gbevinencrypted&password=yeolpass");
1172:                response = conversation.getResponse(request);
1173:                assertEquals(0, response.getForms().length);
1174:                lines = StringUtils.splitToArray(response.getText(), "\n");
1175:                assertEquals("not matching login", lines[0]);
1176:                assertEquals("not matching password1", lines[1]);
1177:                assertEquals("matching password2", lines[2]);
1178:                assertEquals("matching role1", lines[3]);
1179:                assertEquals("matching role2", lines[4]);
1180:                assertEquals("matching role3", lines[5]);
1181:                assertEquals("not matching userid1", lines[6]);
1182:                assertEquals("matching userid2", lines[7]);
1183:
1184:                request = new GetMethodWebRequest(
1185:                        "http://localhost:8181/database/role_maint?submission=credentials&login=johndoe&password=thepassofbass");
1186:                response = conversation.getResponse(request);
1187:                assertEquals(0, response.getForms().length);
1188:                lines = StringUtils.splitToArray(response.getText(), "\n");
1189:                assertEquals("not matching login", lines[0]);
1190:                assertEquals("not matching password1", lines[1]);
1191:                assertEquals("not matching password2", lines[2]);
1192:                assertEquals("not matching role1", lines[3]);
1193:                assertEquals("matching role2", lines[4]);
1194:                assertEquals("matching role3", lines[5]);
1195:                assertEquals("not matching userid1", lines[6]);
1196:                assertEquals("not matching userid2", lines[7]);
1197:
1198:                request = new GetMethodWebRequest(
1199:                        "http://localhost:8181/database/role_admin?submission=credentials&login=guest&password=guestpass");
1200:                response = conversation.getResponse(request);
1201:                assertEquals(1, response.getForms().length);
1202:            }
1203:
1204:            public void testMemoryRoleAdminJanino() throws Exception {
1205:                setupSite("site/roleuser_janino.xml");
1206:
1207:                WebConversation conversation = new WebConversation();
1208:                WebRequest request = null;
1209:                WebResponse response = null;
1210:                String[] lines = null;
1211:
1212:                request = new GetMethodWebRequest(
1213:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevin&password=yeolpass");
1214:                response = conversation.getResponse(request);
1215:                assertEquals(0, response.getForms().length);
1216:                lines = StringUtils.splitToArray(response.getText(), "\n");
1217:                assertEquals("matching login", lines[0]);
1218:                assertEquals("matching password1", lines[1]);
1219:                assertEquals("not matching password2", lines[2]);
1220:                assertEquals("matching role1", lines[3]);
1221:                assertEquals("matching role2", lines[4]);
1222:                assertEquals("matching role3", lines[5]);
1223:                assertEquals("matching userid1", lines[6]);
1224:                assertEquals("not matching userid2", lines[7]);
1225:
1226:                request = new GetMethodWebRequest(
1227:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevinencrypted&password=yeolpass");
1228:                response = conversation.getResponse(request);
1229:                assertEquals(0, response.getForms().length);
1230:                lines = StringUtils.splitToArray(response.getText(), "\n");
1231:                assertEquals("not matching login", lines[0]);
1232:                assertEquals("not matching password1", lines[1]);
1233:                assertEquals("matching password2", lines[2]);
1234:                assertEquals("matching role1", lines[3]);
1235:                assertEquals("matching role2", lines[4]);
1236:                assertEquals("matching role3", lines[5]);
1237:                assertEquals("not matching userid1", lines[6]);
1238:                assertEquals("matching userid2", lines[7]);
1239:
1240:                request = new GetMethodWebRequest(
1241:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=johndoe&password=thepassofbass");
1242:                response = conversation.getResponse(request);
1243:                assertEquals(1, response.getForms().length);
1244:
1245:                request = new GetMethodWebRequest(
1246:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=guest&password=guestpass");
1247:                response = conversation.getResponse(request);
1248:                assertEquals(1, response.getForms().length);
1249:            }
1250:
1251:            public void testMemoryRoleMaintJanino() throws Exception {
1252:                setupSite("site/roleuser_janino.xml");
1253:
1254:                WebConversation conversation = new WebConversation();
1255:                WebRequest request = null;
1256:                WebResponse response = null;
1257:                String[] lines = null;
1258:
1259:                request = new GetMethodWebRequest(
1260:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=gbevin&password=yeolpass");
1261:                response = conversation.getResponse(request);
1262:                assertEquals(0, response.getForms().length);
1263:                lines = StringUtils.splitToArray(response.getText(), "\n");
1264:                assertEquals("matching login", lines[0]);
1265:                assertEquals("matching password1", lines[1]);
1266:                assertEquals("not matching password2", lines[2]);
1267:                assertEquals("matching role1", lines[3]);
1268:                assertEquals("matching role2", lines[4]);
1269:                assertEquals("matching role3", lines[5]);
1270:                assertEquals("matching userid1", lines[6]);
1271:                assertEquals("not matching userid2", lines[7]);
1272:
1273:                request = new GetMethodWebRequest(
1274:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=gbevinencrypted&password=yeolpass");
1275:                response = conversation.getResponse(request);
1276:                assertEquals(0, response.getForms().length);
1277:                lines = StringUtils.splitToArray(response.getText(), "\n");
1278:                assertEquals("not matching login", lines[0]);
1279:                assertEquals("not matching password1", lines[1]);
1280:                assertEquals("matching password2", lines[2]);
1281:                assertEquals("matching role1", lines[3]);
1282:                assertEquals("matching role2", lines[4]);
1283:                assertEquals("matching role3", lines[5]);
1284:                assertEquals("not matching userid1", lines[6]);
1285:                assertEquals("matching userid2", lines[7]);
1286:
1287:                request = new GetMethodWebRequest(
1288:                        "http://localhost:8181/memory/role_maint?submission=credentials&login=johndoe&password=thepassofbass");
1289:                response = conversation.getResponse(request);
1290:                assertEquals(0, response.getForms().length);
1291:                lines = StringUtils.splitToArray(response.getText(), "\n");
1292:                assertEquals("not matching login", lines[0]);
1293:                assertEquals("not matching password1", lines[1]);
1294:                assertEquals("not matching password2", lines[2]);
1295:                assertEquals("not matching role1", lines[3]);
1296:                assertEquals("matching role2", lines[4]);
1297:                assertEquals("matching role3", lines[5]);
1298:                assertEquals("not matching userid1", lines[6]);
1299:                assertEquals("not matching userid2", lines[7]);
1300:
1301:                request = new GetMethodWebRequest(
1302:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=guest&password=guestpass");
1303:                response = conversation.getResponse(request);
1304:                assertEquals(1, response.getForms().length);
1305:            }
1306:
1307:            public void testIdentifiedJanino() throws Exception {
1308:                setupSite("site/roleuser_janino.xml");
1309:
1310:                WebConversation conversation = new WebConversation();
1311:                WebRequest request = null;
1312:                WebResponse response = null;
1313:                String[] lines = null;
1314:                String authid = null;
1315:
1316:                request = new GetMethodWebRequest(
1317:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevin&password=yeolpass");
1318:                response = conversation.getResponse(request);
1319:                lines = StringUtils.splitToArray(response.getText(), "\n");
1320:                authid = lines[8];
1321:                request = new GetMethodWebRequest(
1322:                        "http://localhost:8181/identified?authid=" + authid);
1323:                assertEquals(0, response.getForms().length);
1324:                lines = StringUtils.splitToArray(response.getText(), "\n");
1325:                assertEquals("matching login", lines[0]);
1326:                assertEquals("matching password1", lines[1]);
1327:                assertEquals("not matching password2", lines[2]);
1328:                assertEquals("matching role1", lines[3]);
1329:                assertEquals("matching role2", lines[4]);
1330:                assertEquals("matching role3", lines[5]);
1331:                assertEquals("matching userid1", lines[6]);
1332:                assertEquals("not matching userid2", lines[7]);
1333:
1334:                request = new GetMethodWebRequest(
1335:                        "http://localhost:8181/memory/role_admin?submission=credentials&login=gbevinencrypted&password=yeolpass");
1336:                response = conversation.getResponse(request);
1337:                lines = StringUtils.splitToArray(response.getText(), "\n");
1338:                authid = lines[8];
1339:                request = new GetMethodWebRequest(
1340:                        "http://localhost:8181/identified?authid=" + authid);
1341:                response = conversation.getResponse(request);
1342:                assertEquals(0, response.getForms().length);
1343:                lines = StringUtils.splitToArray(response.getText(), "\n");
1344:                assertEquals("not matching login", lines[0]);
1345:                assertEquals("not matching password1", lines[1]);
1346:                assertEquals("matching password2", lines[2]);
1347:                assertEquals("matching role1", lines[3]);
1348:                assertEquals("matching role2", lines[4]);
1349:                assertEquals("matching role3", lines[5]);
1350:                assertEquals("not matching userid1", lines[6]);
1351:                assertEquals("matching userid2", lines[7]);
1352:
1353:                request = new GetMethodWebRequest(
1354:                        "http://localhost:8181/identified?authid=blargh");
1355:                response = conversation.getResponse(request);
1356:                assertEquals(0, response.getForms().length);
1357:                lines = StringUtils.splitToArray(response.getText(), "\n");
1358:                assertEquals("not matching login", lines[0]);
1359:                assertEquals("not matching password1", lines[1]);
1360:                assertEquals("not matching password2", lines[2]);
1361:                assertEquals("not matching role1", lines[3]);
1362:                assertEquals("not matching role2", lines[4]);
1363:                assertEquals("not matching role3", lines[5]);
1364:                assertEquals("not matching userid1", lines[6]);
1365:                assertEquals("not matching userid2", lines[7]);
1366:            }
1367:
1368:            public void testExplicitEvaluationJanino() throws Exception {
1369:                setupSite("site/roleuser_janino.xml");
1370:
1371:                WebConversation conversation = new WebConversation();
1372:                WebRequest request = null;
1373:                WebResponse response = null;
1374:                String[] lines = null;
1375:
1376:                request = new GetMethodWebRequest(
1377:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass");
1378:                response = conversation.getResponse(request);
1379:                assertEquals(0, response.getForms().length);
1380:                lines = StringUtils.splitToArray(response.getText(), "\n");
1381:                assertEquals("not matching login", lines[0]);
1382:                assertEquals("not matching password1", lines[1]);
1383:                assertEquals("not matching password2", lines[2]);
1384:                assertEquals("not matching role1", lines[3]);
1385:                assertEquals("not matching role2", lines[4]);
1386:                assertEquals("not matching role3", lines[5]);
1387:                assertEquals("not matching userid1", lines[6]);
1388:                assertEquals("not matching userid2", lines[7]);
1389:
1390:                request = new GetMethodWebRequest(
1391:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=login");
1392:                response = conversation.getResponse(request);
1393:                assertEquals(0, response.getForms().length);
1394:                lines = StringUtils.splitToArray(response.getText(), "\n");
1395:                assertEquals("matching login", lines[0]);
1396:                assertEquals("not matching password1", lines[1]);
1397:                assertEquals("not matching password2", lines[2]);
1398:                assertEquals("not matching role1", lines[3]);
1399:                assertEquals("not matching role2", lines[4]);
1400:                assertEquals("not matching role3", lines[5]);
1401:                assertEquals("not matching userid1", lines[6]);
1402:                assertEquals("not matching userid2", lines[7]);
1403:
1404:                request = new GetMethodWebRequest(
1405:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=password1");
1406:                response = conversation.getResponse(request);
1407:                assertEquals(0, response.getForms().length);
1408:                lines = StringUtils.splitToArray(response.getText(), "\n");
1409:                assertEquals("not matching login", lines[0]);
1410:                assertEquals("matching password1", lines[1]);
1411:                assertEquals("not matching password2", lines[2]);
1412:                assertEquals("not matching role1", lines[3]);
1413:                assertEquals("not matching role2", lines[4]);
1414:                assertEquals("not matching role3", lines[5]);
1415:                assertEquals("not matching userid1", lines[6]);
1416:                assertEquals("not matching userid2", lines[7]);
1417:
1418:                request = new GetMethodWebRequest(
1419:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=password2");
1420:                response = conversation.getResponse(request);
1421:                assertEquals(0, response.getForms().length);
1422:                lines = StringUtils.splitToArray(response.getText(), "\n");
1423:                assertEquals("not matching login", lines[0]);
1424:                assertEquals("not matching password1", lines[1]);
1425:                assertEquals("not matching password2", lines[2]);
1426:                assertEquals("not matching role1", lines[3]);
1427:                assertEquals("not matching role2", lines[4]);
1428:                assertEquals("not matching role3", lines[5]);
1429:                assertEquals("not matching userid1", lines[6]);
1430:                assertEquals("not matching userid2", lines[7]);
1431:
1432:                request = new GetMethodWebRequest(
1433:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=role1&roleadmin=anotheradmin");
1434:                response = conversation.getResponse(request);
1435:                assertEquals(0, response.getForms().length);
1436:                lines = StringUtils.splitToArray(response.getText(), "\n");
1437:                assertEquals("not matching login", lines[0]);
1438:                assertEquals("not matching password1", lines[1]);
1439:                assertEquals("not matching password2", lines[2]);
1440:                assertEquals("not matching role1", lines[3]);
1441:                assertEquals("not matching role2", lines[4]);
1442:                assertEquals("not matching role3", lines[5]);
1443:                assertEquals("not matching userid1", lines[6]);
1444:                assertEquals("not matching userid2", lines[7]);
1445:
1446:                request = new GetMethodWebRequest(
1447:                        "http://localhost:8181/explicit_evaluation?submission=credentials&login=gbevin&password=yeolpass&evaluate=role1&roleadmin=admin");
1448:                response = conversation.getResponse(request);
1449:                assertEquals(0, response.getForms().length);
1450:                lines = StringUtils.splitToArray(response.getText(), "\n");
1451:                assertEquals("not matching login", lines[0]);
1452:                assertEquals("not matching password1", lines[1]);
1453:                assertEquals("not matching password2", lines[2]);
1454:                assertEquals("matching role1", lines[3]);
1455:                assertEquals("not matching role2", lines[4]);
1456:                assertEquals("not matching role3", lines[5]);
1457:                assertEquals("not matching userid1", lines[6]);
1458:                assertEquals("not matching userid2", lines[7]);
1459:            }
1460:
1461:            public void testDatabaseRoleAdminJanino() throws Exception {
1462:                setupSite("site/roleuser_janino.xml");
1463:
1464:                WebConversation conversation = new WebConversation();
1465:                WebRequest request = null;
1466:                WebResponse response = null;
1467:                String[] lines = null;
1468:
1469:                request = new GetMethodWebRequest(
1470:                        "http://localhost:8181/database/role_admin?submission=credentials&login=gbevin&password=yeolpass");
1471:                response = conversation.getResponse(request);
1472:                assertEquals(0, response.getForms().length);
1473:                lines = StringUtils.splitToArray(response.getText(), "\n");
1474:                assertEquals("matching login", lines[0]);
1475:                assertEquals("matching password1", lines[1]);
1476:                assertEquals("not matching password2", lines[2]);
1477:                assertEquals("matching role1", lines[3]);
1478:                assertEquals("matching role2", lines[4]);
1479:                assertEquals("matching role3", lines[5]);
1480:                assertEquals("matching userid1", lines[6]);
1481:                assertEquals("not matching userid2", lines[7]);
1482:
1483:                request = new GetMethodWebRequest(
1484:                        "http://localhost:8181/database/encrypted?submission=credentials&login=gbevinencrypted&password=yeolpass");
1485:                response = conversation.getResponse(request);
1486:                assertEquals(0, response.getForms().length);
1487:                lines = StringUtils.splitToArray(response.getText(), "\n");
1488:                assertEquals("not matching login", lines[0]);
1489:                assertEquals("not matching password1", lines[1]);
1490:                assertEquals("matching password2", lines[2]);
1491:                assertEquals("matching role1", lines[3]);
1492:                assertEquals("matching role2", lines[4]);
1493:                assertEquals("matching role3", lines[5]);
1494:                assertEquals("not matching userid1", lines[6]);
1495:                assertEquals("matching userid2", lines[7]);
1496:
1497:                request = new GetMethodWebRequest(
1498:                        "http://localhost:8181/database/role_admin?submission=credentials&login=johndoe&password=thepassofbass");
1499:                response = conversation.getResponse(request);
1500:                assertEquals(1, response.getForms().length);
1501:
1502:                request = new GetMethodWebRequest(
1503:                        "http://localhost:8181/database/role_admin?submission=credentials&login=guest&password=guestpass");
1504:                response = conversation.getResponse(request);
1505:                assertEquals(1, response.getForms().length);
1506:            }
1507:
1508:            public void testDatabaseRoleMaintJanino() throws Exception {
1509:                setupSite("site/roleuser_janino.xml");
1510:
1511:                WebConversation conversation = new WebConversation();
1512:                WebRequest request = null;
1513:                WebResponse response = null;
1514:                String[] lines = null;
1515:
1516:                request = new GetMethodWebRequest(
1517:                        "http://localhost:8181/database/role_maint?submission=credentials&login=gbevin&password=yeolpass");
1518:                response = conversation.getResponse(request);
1519:                assertEquals(0, response.getForms().length);
1520:                lines = StringUtils.splitToArray(response.getText(), "\n");
1521:                assertEquals("matching login", lines[0]);
1522:                assertEquals("matching password1", lines[1]);
1523:                assertEquals("not matching password2", lines[2]);
1524:                assertEquals("matching role1", lines[3]);
1525:                assertEquals("matching role2", lines[4]);
1526:                assertEquals("matching role3", lines[5]);
1527:                assertEquals("matching userid1", lines[6]);
1528:                assertEquals("not matching userid2", lines[7]);
1529:
1530:                request = new GetMethodWebRequest(
1531:                        "http://localhost:8181/database/encrypted?submission=credentials&login=gbevinencrypted&password=yeolpass");
1532:                response = conversation.getResponse(request);
1533:                assertEquals(0, response.getForms().length);
1534:                lines = StringUtils.splitToArray(response.getText(), "\n");
1535:                assertEquals("not matching login", lines[0]);
1536:                assertEquals("not matching password1", lines[1]);
1537:                assertEquals("matching password2", lines[2]);
1538:                assertEquals("matching role1", lines[3]);
1539:                assertEquals("matching role2", lines[4]);
1540:                assertEquals("matching role3", lines[5]);
1541:                assertEquals("not matching userid1", lines[6]);
1542:                assertEquals("matching userid2", lines[7]);
1543:
1544:                request = new GetMethodWebRequest(
1545:                        "http://localhost:8181/database/role_maint?submission=credentials&login=johndoe&password=thepassofbass");
1546:                response = conversation.getResponse(request);
1547:                assertEquals(0, response.getForms().length);
1548:                lines = StringUtils.splitToArray(response.getText(), "\n");
1549:                assertEquals("not matching login", lines[0]);
1550:                assertEquals("not matching password1", lines[1]);
1551:                assertEquals("not matching password2", lines[2]);
1552:                assertEquals("not matching role1", lines[3]);
1553:                assertEquals("matching role2", lines[4]);
1554:                assertEquals("matching role3", lines[5]);
1555:                assertEquals("not matching userid1", lines[6]);
1556:                assertEquals("not matching userid2", lines[7]);
1557:
1558:                request = new GetMethodWebRequest(
1559:                        "http://localhost:8181/database/role_admin?submission=credentials&login=guest&password=guestpass");
1560:                response = conversation.getResponse(request);
1561:                assertEquals(1, response.getForms().length);
1562:            }
1563:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.