File tree Expand file tree Collapse file tree
java/com/ocpsoft/pretty/faces/test/rewrite Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ Bugfixes:
2626* Dynaview: Parameter injection now correctly happens before view determination (#120)
2727* Fixed decoding of quotation mark character. Thanks to Bruno Aranda for the patch. (#122)
2828* Use equals() instead of matches() to compare URL with view-id. Thanks to mbenson for bringing this up.
29-
29+ * Prevent rewrite loops by avoiding nested rewrites for forwarded requests (#121)
3030
3131------------------------------------
3232 VERSION 3.3.0
Original file line number Diff line number Diff line change 1+ package com .ocpsoft .pretty .faces .test .rewrite ;
2+
3+ import static org .junit .Assert .assertTrue ;
4+
5+ import org .jboss .arquillian .api .Deployment ;
6+ import org .jboss .arquillian .junit .Arquillian ;
7+ import org .jboss .jsfunit .jsfsession .JSFClientSession ;
8+ import org .jboss .jsfunit .jsfsession .JSFSession ;
9+ import org .jboss .shrinkwrap .api .spec .WebArchive ;
10+ import org .junit .Test ;
11+ import org .junit .runner .RunWith ;
12+
13+ import com .ocpsoft .pretty .faces .test .PrettyFacesTestBase ;
14+
15+ @ RunWith (Arquillian .class )
16+ public class RewriteLoopTest extends PrettyFacesTestBase
17+ {
18+
19+ @ Deployment
20+ public static WebArchive createDeployment ()
21+ {
22+ return PrettyFacesTestBase .createDeployment ()
23+ .addResource ("rewrite/rewrite-loop.xhtml" , "rewrite-loop.xhtml" )
24+ .addWebResource ("rewrite/rewrite-loop-config.xml" , "pretty-config.xml" );
25+ }
26+
27+ @ Test
28+ public void testRewriteRuleSubstiuteMatchingRulePattern () throws Exception
29+ {
30+
31+ // Access the URL that is rewritten to the correct JSF page
32+ JSFSession jsfSession = new JSFSession ("/rewrite-loop.html" );
33+ JSFClientSession client = jsfSession .getJSFClientSession ();
34+
35+ // the page should render fine without any rewrite loop
36+ assertTrue (client .getContentPage ().getUrl ().toString ().endsWith ("/rewrite-loop.html" ));
37+ assertTrue (client .getPageAsText ().contains ("Rewrite loop test page rendered" ));
38+
39+ }
40+
41+ }
Original file line number Diff line number Diff line change 1+ <pretty-config xmlns =" http://ocpsoft.com/prettyfaces/3.3.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" >
2+
3+ <!-- matches "/rewrite-loop.html" AND "/rewrite-loop.jsf" -->
4+ <rewrite match =" /rewrite-loop\..*" substitute =" /rewrite-loop.jsf" redirect =" chain" />
5+
6+ </pretty-config >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+ < html xmlns ="http://www.w3.org/1999/xhtml "
4+ xmlns:f ="http://java.sun.com/jsf/core "
5+ xmlns:h ="http://java.sun.com/jsf/html "
6+ xmlns:pretty ="http://ocpsoft.com/prettyfaces "
7+ xmlns:ui ="http://java.sun.com/jsf/facelets ">
8+
9+ < head >
10+ < title > Rewrite Loop Test</ title >
11+ </ head >
12+
13+ < body >
14+
15+ < p > Rewrite loop test page rendered!</ p >
16+
17+ </ body >
18+
19+ </ html >
You can’t perform that action at this time.
0 commit comments