Skip to content

Commit

Permalink
all admin paths should have Cache-control private #10821
Browse files Browse the repository at this point in the history
(cherry picked from commit 80cc553)
  • Loading branch information
rymsha committed Jan 20, 2025
1 parent 9b66715 commit 7657bdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public void setHeader( final String name, String value )
{
if ( value != null )
{
if ( value.contains( "public" ) )
if ( value.contains( "private" ) )
{
return;
}
else if ( value.contains( "public" ) )
{
value = value.replaceAll( "public", "private" );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;

@ExtendWith(MockitoExtension.class)
class NoCacheAdminFilterTest
Expand Down Expand Up @@ -59,6 +60,16 @@ void NoCacheAdminResponseWrapper_setHeader_replacesPublicWithPrivate()
verify( response ).setHeader( HttpHeaders.CACHE_CONTROL, "private, max-age=3600" );
}

@Test
void NoCacheAdminResponseWrapper_setHeader_alreadyPrivate()
{
HttpServletResponse responseWrapper = new NoCacheAdminFilter.NoCacheAdminResponseWrapper( response );

responseWrapper.setHeader( HttpHeaders.CACHE_CONTROL, "private, max-age=3600" );

verifyNoInteractions( response );
}

@Test
void NoCacheAdminResponseWrapper_setHeader_addsPrivateIfNotPresent()
{
Expand Down

0 comments on commit 7657bdf

Please sign in to comment.