PHRAS-2859_tests-do-corrupt-conf-bis_4.1

fix new tests
This commit is contained in:
Jean-Yves Gaulier
2019-12-18 16:51:17 +01:00
parent f883748f40
commit d6c8eaa659
4 changed files with 42 additions and 6 deletions

View File

@@ -1281,7 +1281,7 @@ class ApiJsonTest extends ApiTestCase
$tochange = []; $tochange = [];
foreach ($statusStructure as $n => $datas) { foreach ($statusStructure as $n => $datas) {
$tochange[$n] = substr($record_status, ($n - 1), 1) == '0' ? '1' : '0'; $tochange[$n] = substr($record_status, $n, 1) == '0' ? '1' : '0';
} }
$this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']); $this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']);
@@ -1305,7 +1305,8 @@ class ApiJsonTest extends ApiTestCase
// test record_status in string // test record_status in string
$record_status_expected = $record_status; $record_status_expected = $record_status;
$pos = strpos($record_status, '1'); $bitToChange = [];
$pos = strpos($record_status, '1', 4);
$bitToChange[$pos] = '1'; $bitToChange[$pos] = '1';
$response = $this->request('POST', $route, $this->getParameters(['status' => $bitToChange]), ['HTTP_Accept' => $this->getAcceptMimeType()]); $response = $this->request('POST', $route, $this->getParameters(['status' => $bitToChange]), ['HTTP_Accept' => $this->getAcceptMimeType()]);

View File

@@ -2017,6 +2017,9 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$app = $this->getApplication(); $app = $this->getApplication();
$this->logout($app); $this->logout($app);
$bkp = $app['phraseanet.configuration']['session'];
$app['phraseanet.configuration']['session'] = [ $app['phraseanet.configuration']['session'] = [
'idle' => 10, 'idle' => 10,
'lifetime' => 60475, 'lifetime' => 60475,
@@ -2027,12 +2030,17 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertEquals('hidden', $crawler->filter('input[name="remember-me"]')->attr('type')); $this->assertEquals('hidden', $crawler->filter('input[name="remember-me"]')->attr('type'));
$app['phraseanet.configuration']['session'] = $bkp;
} }
public function testLoginPageWithNoIdleSessionTime() public function testLoginPageWithNoIdleSessionTime()
{ {
$app = $this->getApplication(); $app = $this->getApplication();
$this->logout($app); $this->logout($app);
$bkp = $app['phraseanet.configuration']['session'];
$app['phraseanet.configuration']['session'] = [ $app['phraseanet.configuration']['session'] = [
'idle' => 0, 'idle' => 0,
'lifetime' => 60475, 'lifetime' => 60475,
@@ -2043,6 +2051,8 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertEquals('checkbox', $crawler->filter('input[name="remember-me"]')->attr('type')); $this->assertEquals('checkbox', $crawler->filter('input[name="remember-me"]')->attr('type'));
$app['phraseanet.configuration']['session'] = $bkp;
} }
private function addUsrAuthDoctrineEntitySupport($id, $out, $participants = false) private function addUsrAuthDoctrineEntitySupport($id, $out, $participants = false)

View File

@@ -19,6 +19,9 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$app = new Application(Application::ENV_TEST); $app = new Application(Application::ENV_TEST);
$app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app)); $app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app));
$bkp = $app['phraseanet.configuration']['session'];
$app['phraseanet.configuration']['session'] = [ $app['phraseanet.configuration']['session'] = [
'idle' => 0, 'idle' => 0,
'lifetime' => 60475, 'lifetime' => 60475,
@@ -39,12 +42,17 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session')); $this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
$this->assertNotNUll($client->getResponse()->headers->get('location')); $this->assertNotNUll($client->getResponse()->headers->get('location'));
$this->assertRegExp('#/login\?redirect=..(?:%2F|/)prod#', $client->getResponse()->headers->get('location')); $this->assertRegExp('#/login\?redirect=..(?:%2F|/)prod#', $client->getResponse()->headers->get('location'));
$app['phraseanet.configuration']['session'] = $bkp;
} }
public function testEndSessionXmlXhttpRequest() public function testEndSessionXmlXhttpRequest()
{ {
$app = new Application(Application::ENV_TEST); $app = new Application(Application::ENV_TEST);
$app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app)); $app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app));
$bkp = $app['phraseanet.configuration']['session'];
$app['phraseanet.configuration']['session'] = [ $app['phraseanet.configuration']['session'] = [
'idle' => 0, 'idle' => 0,
'lifetime' => 60475, 'lifetime' => 60475,
@@ -67,6 +75,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertTrue($client->getResponse()->isClientError()); $this->assertTrue($client->getResponse()->isClientError());
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session')); $this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
$app['phraseanet.configuration']['session'] = $bkp;
} }
public function testEndSessionAuthenticated() public function testEndSessionAuthenticated()
@@ -85,6 +95,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$app['orm.em']->expects($this->exactly(4))->method('persist')->will($this->returnValue(null)); $app['orm.em']->expects($this->exactly(4))->method('persist')->will($this->returnValue(null));
$app['orm.em']->expects($this->exactly(2))->method('flush')->will($this->returnValue(null)); $app['orm.em']->expects($this->exactly(2))->method('flush')->will($this->returnValue(null));
$bkp = $app['phraseanet.configuration']['session'];
$app['phraseanet.configuration']['session'] = [ $app['phraseanet.configuration']['session'] = [
'idle' => 0, 'idle' => 0,
'lifetime' => 60475, 'lifetime' => 60475,
@@ -101,6 +113,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$client->request('GET', '/prod'); $client->request('GET', '/prod');
$this->assertTrue($client->getResponse()->isOK()); $this->assertTrue($client->getResponse()->isOK());
$app['phraseanet.configuration']['session'] = $bkp;
} }
public function testEndSessionAuthenticatedWithOutdatedIdle() public function testEndSessionAuthenticatedWithOutdatedIdle()
@@ -120,6 +134,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$app['orm.em']->expects($this->any())->method('persist')->will($this->returnValue(null)); $app['orm.em']->expects($this->any())->method('persist')->will($this->returnValue(null));
$app['orm.em']->expects($this->any())->method('flush')->will($this->returnValue(null)); $app['orm.em']->expects($this->any())->method('flush')->will($this->returnValue(null));
$bkp = $app['phraseanet.configuration']['session'];
$app['phraseanet.configuration']['session'] = [ $app['phraseanet.configuration']['session'] = [
'idle' => 10, 'idle' => 10,
'lifetime' => 60475, 'lifetime' => 60475,
@@ -139,6 +155,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session')); $this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
$this->assertNotNUll($client->getResponse()->headers->get('location')); $this->assertNotNUll($client->getResponse()->headers->get('location'));
$this->assertRegExp('#/login\?redirect=..(?:%2F|/)prod#', $client->getResponse()->headers->get('location')); $this->assertRegExp('#/login\?redirect=..(?:%2F|/)prod#', $client->getResponse()->headers->get('location'));
$app['phraseanet.configuration']['session'] = $bkp;
} }
public function testEndSessionAuthenticatedWithOutdatedIdleXmlHttpRequest() public function testEndSessionAuthenticatedWithOutdatedIdleXmlHttpRequest()
@@ -158,6 +176,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$app['orm.em']->expects($this->any())->method('persist')->will($this->returnValue(null)); $app['orm.em']->expects($this->any())->method('persist')->will($this->returnValue(null));
$app['orm.em']->expects($this->any())->method('flush')->will($this->returnValue(null)); $app['orm.em']->expects($this->any())->method('flush')->will($this->returnValue(null));
$bkp = $app['phraseanet.configuration']['session'];
$app['phraseanet.configuration']['session'] = [ $app['phraseanet.configuration']['session'] = [
'idle' => 10, 'idle' => 10,
'lifetime' => 60475, 'lifetime' => 60475,
@@ -178,6 +198,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertTrue($client->getResponse()->isClientError()); $this->assertTrue($client->getResponse()->isClientError());
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session')); $this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
$app['phraseanet.configuration']['session'] = $bkp;
} }
public function testUndefinedModule() public function testUndefinedModule()

View File

@@ -44,7 +44,8 @@ class media_Permalink_AdapterTest extends \PhraseanetTestCase
public function testGet_url() public function testGet_url()
{ {
$url = rtrim(self::$DI['app']['conf']->get('servername'), '/') . '/permalink/v1/' $url = $this->object->get_url()->getScheme() . '://'
. rtrim(self::$DI['app']['conf']->get('servername'), '/') . '/permalink/v1/'
. self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_sbas_id() . '/'
. self::$DI['record_1']->get_record_id() . self::$DI['record_1']->get_record_id()
. '/document/' . $this->object->get_label() . '/document/' . $this->object->get_label()
@@ -60,19 +61,21 @@ class media_Permalink_AdapterTest extends \PhraseanetTestCase
$subdef = self::$DI['record_1']->get_subdef('preview'); $subdef = self::$DI['record_1']->get_subdef('preview');
$previewPermalink = media_Permalink_Adapter::getPermalink(self::$DI['app'], $databox, $subdef); $previewPermalink = media_Permalink_Adapter::getPermalink(self::$DI['app'], $databox, $subdef);
$url = rtrim(self::$DI['app']['conf']->get('servername'), '/') . '/permalink/v1/' $url = $previewPermalink->get_url()->getScheme() . '://'
. rtrim(self::$DI['app']['conf']->get('servername'), '/') . '/permalink/v1/'
. self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_sbas_id() . '/'
. self::$DI['record_1']->get_record_id() . self::$DI['record_1']->get_record_id()
. '/preview/' . $previewPermalink->get_label() . '/preview/' . $previewPermalink->get_label()
. '.' . pathinfo(self::$DI['record_1']->get_subdef('preview')->get_file(), PATHINFO_EXTENSION) . '.' . pathinfo(self::$DI['record_1']->get_subdef('preview')->get_file(), PATHINFO_EXTENSION)
. '?token=' . urlencode($previewPermalink->get_token()); . '?token=' . urlencode($previewPermalink->get_token());
$this->assertEquals($url, $previewPermalink->get_url()); $this->assertEquals($url, (string)($previewPermalink->get_url()));
} }
public function testGet_page() public function testGet_page()
{ {
$url = rtrim(self::$DI['app']['conf']->get('servername'), '/') . '/permalink/v1/' $url = $this->object->get_url()->getScheme() . '://'
. rtrim(self::$DI['app']['conf']->get('servername'), '/') . '/permalink/v1/'
. self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_sbas_id() . '/'
. self::$DI['record_1']->get_record_id() . self::$DI['record_1']->get_record_id()
. '/document/' . '/document/'