File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -279,8 +279,12 @@ function DownloadArchive($id, $testServer)
279279*/
280280function RestoreArchive ($ id )
281281{
282+ global $ request_context ;
283+
282284 $ isSaaSTest = (stripos ($ id , '_saas_ ' ) !== false );
283285 $ saas_capture_prefix = GetSetting ("cp_saas_capture_prefix " );
286+ $ isInstantTest = (stripos ($ id , '_instant_ ' ) !== false );
287+ $ isAdmin = isset ($ request_context ) && $ request_context ->getUser ()->isAdmin ();
284288
285289 $ ret = false ;
286290 if (TestArchiveExpired ($ id )) {
@@ -309,7 +313,7 @@ function RestoreArchive($id)
309313 }
310314 }
311315 //saas tests do not specifiy capture server in the URL, so we'll hardcode it
312- if ($ isSaaSTest ) {
316+ if ($ isSaaSTest || ( $ isInstantTest && $ isAdmin ) ) {
313317 $ capture_server = GetSetting ("cp_capture_ $ saas_capture_prefix " );
314318 $ capture_salt = GetSetting ("cp_capture_salt_ $ saas_capture_prefix " );
315319 }
@@ -417,6 +421,9 @@ function RestoreArchive($id)
417421 if ($ deleteZip ) {
418422 @unlink ($ zipfile );
419423 }
424+ if ($ isInstantTest && $ isAdmin ) {
425+ ProcessUploadedTest ($ id );
426+ }
420427 }
421428 } else {
422429 $ ret = true ;
Original file line number Diff line number Diff line change @@ -455,6 +455,11 @@ if (strlen($id)) {
455455 throw new ForbiddenException ();
456456 }
457457
458+ $ test_is_instant = (stripos ($ id , '_instant_ ' ) !== false );
459+ if ($ test_is_instant && !(isset ($ request_context ) && $ request_context ->getUser ()->isAdmin ())) {
460+ throw new ForbiddenException ();
461+ }
462+
458463 $ url = array_key_exists ('url ' , $ test ['testinfo ' ]) ? htmlspecialchars ($ test ['testinfo ' ]['url ' ]) : null ;
459464 $ dom = array_key_exists ('domElement ' , $ test ['testinfo ' ]) ? htmlspecialchars ($ test ['testinfo ' ]['domElement ' ]) : null ;
460465 $ login = array_key_exists ('login ' , $ test ['testinfo ' ]) ? htmlspecialchars ($ test ['testinfo ' ]['login ' ]) : null ;
Original file line number Diff line number Diff line change @@ -15,6 +15,13 @@ $testInfoJson = null;
1515*/
1616function GetTestStatus ($ id , $ includePosition = true )
1717{
18+ global $ request_context ;
19+ $ isInstantTest = (stripos ($ id , '_instant_ ' ) !== false );
20+ $ isAdmin = isset ($ request_context ) && $ request_context ->getUser ()->isAdmin ();
21+ if ($ isInstantTest && !$ isAdmin ) {
22+ return array ('statusCode ' => 400 , 'statusText ' => 'Test not found ' , 'id ' => $ id );
23+ }
24+
1825 $ testServer = GetServerForTest ($ id );
1926 if (isset ($ testServer )) {
2027 // Proxy the status through the server that actually owns the test
You can’t perform that action at this time.
0 commit comments