Skip to content

Commit

Permalink
[SP-6512] - Backport of PPP-5053 - Intercepting few Get request with …
Browse files Browse the repository at this point in the history
…Burp Suite allows un-authorised user to access data (9.3 Suite) - Test Fix
  • Loading branch information
renato-s committed Apr 10, 2024
1 parent cdfb51f commit fe5085b
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.nullable;
import static org.mockito.Mockito.spy;
Expand All @@ -88,6 +89,8 @@ public class SolutionImportHandlerTest {
private IUnifiedRepository repository;
private IRoleAuthorizationPolicyRoleBindingDao roleAuthorizationPolicyRoleBindingDao;
private IPlatformMimeResolver mockMimeResolver;
private static MockedStatic<PentahoSystem> pentahoSystem;
IAuthorizationPolicy policy = mock( IAuthorizationPolicy.class );

@Before
public void setUp() throws Exception {
Expand Down Expand Up @@ -496,6 +499,8 @@ public void testImportSchedules() throws Exception {
when( iSchedulerMock.getStatus() ).thenReturn( mock( IScheduler.SchedulerStatus.class ) );
pentahoSessionHolderMockedStatic.when( PentahoSessionHolder::getSession )
.thenReturn( mock( IPentahoSession.class ) );
pentahoSystemMockedStatic.when( () -> PentahoSystem.get( eq( IAuthorizationPolicy.class ) ) ).thenReturn( policy );
when( policy.isAllowed( anyString() ) ).thenReturn( true );

importHandler.importSchedules( schedules );

Expand Down Expand Up @@ -527,6 +532,8 @@ public void testImportSchedules_FailsToCreateSchedule() throws Exception {
when( iSchedulerMock.getStatus() ).thenReturn( mock( IScheduler.SchedulerStatus.class ) );
pentahoSessionHolderMockedStatic.when( PentahoSessionHolder::getSession )
.thenReturn( mock( IPentahoSession.class ) );
pentahoSystemMockedStatic.when( () -> PentahoSystem.get( eq( IAuthorizationPolicy.class ) ) ).thenReturn( policy );
when( policy.isAllowed( anyString() ) ).thenReturn( true );

importHandler.importSchedules( schedules );
Assert.assertEquals( 0, ImportSession.getSession().getImportedScheduleJobIds().size() );
Expand All @@ -535,6 +542,7 @@ public void testImportSchedules_FailsToCreateSchedule() throws Exception {

@Test
public void testImportSchedules_FailsToCreateScheduleWithSpace() throws Exception {

List<JobScheduleRequest> schedules = new ArrayList<>();
JobScheduleRequest scheduleRequest = spy( new JobScheduleRequest() );
scheduleRequest.setInputFile( "/home/admin/scheduled Transform.ktr" );
Expand Down Expand Up @@ -563,6 +571,9 @@ public void testImportSchedules_FailsToCreateScheduleWithSpace() throws Exceptio
.thenReturn( iSchedulerMock );
when( iSchedulerMock.getStatus() ).thenReturn( mock( IScheduler.SchedulerStatus.class ) );
pentahoSessionHolderMockedStatic.when( PentahoSessionHolder::getSession ).thenReturn( mock( IPentahoSession.class ) );
pentahoSystemMockedStatic.when( () -> PentahoSystem.get( eq( IAuthorizationPolicy.class ) ) ).thenReturn( policy );
when( policy.isAllowed( anyString() ) ).thenReturn( true );

importHandler.importSchedules( schedules );
verify( importHandler, times( 2 ) ).createSchedulerJob(
any( SchedulerResource.class ), any( JobScheduleRequest.class ) );
Expand Down Expand Up @@ -604,6 +615,8 @@ public void testImportSchedules_FailsToCreateScheduleWithSpaceOnWindows() throws
when( iSchedulerMock.getStatus() ).thenReturn( mock( IScheduler.SchedulerStatus.class ) );
pentahoSessionHolderMockedStatic.when( PentahoSessionHolder::getSession )
.thenReturn( mock( IPentahoSession.class ) );
pentahoSystemMockedStatic.when( () -> PentahoSystem.get( eq( IAuthorizationPolicy.class ) ) ).thenReturn( policy );
when( policy.isAllowed( anyString() ) ).thenReturn( true );

importHandler.importSchedules( schedules );
verify( importHandler, times( 2 ) )
Expand Down

0 comments on commit fe5085b

Please sign in to comment.