@@ -183,6 +183,33 @@ public void escapePathSegmentsWithWildCard() throws Exception {
183183 "theRest=foo bar,foobar,foo bar,foo@bar" ));
184184 }
185185
186+ @ Test
187+ public void flash_scope_compatibility () throws Exception {
188+ // Use case: MVC is able to decrypt a flash message cookie that was encrypted with legacy methods
189+ // Create a SimpleMessage, serialize, encrypt, and encode. The message text is hard-coded here because there is no context to look up the message.
190+ var message = new SimpleMessage (MessageType .INFO , "[FlashScopeMessageKey]" , "This is a message!" );
191+ // Serialize List<Message>
192+ var serialized = objectMapper .writeValueAsBytes (List .of (message ));
193+ // Instantiate DefaultEncryptor with two copies of CBCCipherProvider to encrypt with CBC
194+ Encryptor cbcEncryptor = new DefaultEncryptor (new CBCCipherProvider (configuration ), new CBCCipherProvider (configuration ));
195+ var encrypted = cbcEncryptor .encrypt (serialized );
196+ var encoded = Base64 .getUrlEncoder ().encodeToString (encrypted );
197+
198+ simulator .test ("/flash-scope/" )
199+ .withCookie (configuration .messageFlashScopeCookieName (), encoded )
200+ .get ()
201+ .assertStatusCode (200 )
202+ .assertContainsGeneralMessageCodes (MessageType .INFO , "[FlashScopeMessageKey]" )
203+ .assertBodyContainsMessagesFromKey ("[FlashScopeMessageKey]" )
204+ .assertBody ("""
205+ This is an index page.
206+
207+ Info:This is a message!
208+
209+ """ )
210+ ;
211+ }
212+
186213 @ Test
187214 public void get () throws Exception {
188215 // Not called yet
@@ -1038,40 +1065,13 @@ public void get_redirect_flash_scope_messageLookup() throws Exception {
10381065 .assertBodyContainsMessagesFromKey ("[FlashScopeMessageKey]" )
10391066 .assertBody ("""
10401067 This is an index page.
1041-
1068+
10421069 Info:This is a message!
1043-
1070+
10441071 """ )
10451072 );
10461073 }
10471074
1048- @ Test
1049- public void flash_scope_compatibility () throws Exception {
1050- // Use case: MVC is able to decrypt a flash message cookie that was encrypted with legacy methods
1051- // Create a SimpleMessage, serialize, encrypt, and encode. The message text is hard-coded here because there is no context to look up the message.
1052- var message = new SimpleMessage (MessageType .INFO , "[FlashScopeMessageKey]" , "This is a message!" );
1053- // Serialize List<Message>
1054- var serialized = objectMapper .writeValueAsBytes (List .of (message ));
1055- // Instantiate DefaultEncryptor with two copies of CBCCipherProvider to encrypt with CBC
1056- Encryptor cbcEncryptor = new DefaultEncryptor (new CBCCipherProvider (configuration ), new CBCCipherProvider (configuration ));
1057- var encrypted = cbcEncryptor .encrypt (serialized );
1058- var encoded = Base64 .getUrlEncoder ().encodeToString (encrypted );
1059-
1060- simulator .test ("/flash-scope/" )
1061- .withCookie (configuration .messageFlashScopeCookieName (), encoded )
1062- .get ()
1063- .assertStatusCode (200 )
1064- .assertContainsGeneralMessageCodes (MessageType .INFO , "[FlashScopeMessageKey]" )
1065- .assertBodyContainsMessagesFromKey ("[FlashScopeMessageKey]" )
1066- .assertBody ("""
1067- This is an index page.
1068-
1069- Info:This is a message!
1070-
1071- """ )
1072- ;
1073- }
1074-
10751075 @ Test
10761076 public void get_redirect_withActual () throws Exception {
10771077 // Contains no parameters
@@ -1100,6 +1100,12 @@ public void get_template_noAction() throws Exception {
11001100 .assertStatusCode (200 )
11011101 .assertBodyContains ("Yo, nice template." );
11021102
1103+ // uses a message key that's not found
1104+ simulator .test ("/freemarker/missing-message-template" )
1105+ .get ()
1106+ .assertStatusCode (200 )
1107+ .assertBodyContains ("Yo, nice template." , "the default message" );
1108+
11031109 // Double slash, redirect to the correct location
11041110 simulator .test ("/freemarker//stand-alone-template" )
11051111 .get ()
@@ -1961,7 +1967,7 @@ public void post_jsonContentType() throws Exception {
19611967 "message" : "Invalid [Content-Type] HTTP request header value of [application/test+json]. Supported values for this request include [application/json]."
19621968 } ]
19631969 }
1964- """ );
1970+ """ );
19651971
19661972 // Patch not supported on this endpoint
19671973 simulator .test ("/json-content-type-no-restriction" )
@@ -1981,7 +1987,7 @@ public void post_jsonContentType() throws Exception {
19811987 "message" : "The [Content-Type] HTTP request header value of [application/json-patch+json] is not supported for this request."
19821988 } ]
19831989 }
1984- """ );
1990+ """ );
19851991
19861992 // Missing Content-Type Header
19871993 simulator .test ("/json-content-type" )
@@ -2028,7 +2034,7 @@ public void post_jsonContentType() throws Exception {
20282034 "message" : "Invalid [Content-Type] HTTP request header value of [application/klingon]. Supported values for this request include [application/json]."
20292035 } ]
20302036 }
2031- """ );
2037+ """ );
20322038
20332039 // Not supported in general
20342040 simulator .test ("/json-content-type-no-restriction" )
0 commit comments