diff --git a/js/utils.js b/js/utils.js index 8bb7bac35..5fcb5f7cd 100644 --- a/js/utils.js +++ b/js/utils.js @@ -666,7 +666,7 @@ Dict.Format = function () { var args = Array.from(arguments); args[0] = Dict.S(arguments[0]); return Format(args); -} +}; // TODO 3.0.0: Move functions above either in CombodoGlobalToolbox or CombodoBackofficeToolbox and deprecate them /** @@ -1073,4 +1073,4 @@ const CombodoSanitizer = { return sEncodedValue; } -} +}; \ No newline at end of file diff --git a/test/application/privUITransactionFileTest.php b/test/application/privUITransactionFileTest.php index 843155e97..a67808f84 100644 --- a/test/application/privUITransactionFileTest.php +++ b/test/application/privUITransactionFileTest.php @@ -27,6 +27,11 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase; */ class privUITransactionFileTest extends ItopDataTestCase { + /** @var int ID of the "support agent" pofile in the sample data */ + const SAMPLE_DATA_SUPPORT_PROFILE_ID = 5; + const USER1_TEST_LOGIN = 'user1_support_test_privUITransaction'; + const USER2_TEST_LOGIN = 'user2_support_test_privUITransaction'; + public function setUp() { parent::setUp(); @@ -137,27 +142,33 @@ class privUITransactionFileTest extends ItopDataTestCase /** * @throws \SecurityException + * @uses self::SAMPLE_DATA_SUPPORT_PROFILE_ID + * @uses self::USER1_TEST_LOGIN + * @uses self::USER2_TEST_LOGIN */ - public function testIsTransactionValid() { - $this->markTestSkipped('Still need some work for Jenkins (Token created by support user must be invalid in the admin user context)'); + public function testIsTransactionValid() + { + $this->CreateUser(static::USER1_TEST_LOGIN, self::SAMPLE_DATA_SUPPORT_PROFILE_ID); + $this->CreateUser(static::USER2_TEST_LOGIN, self::SAMPLE_DATA_SUPPORT_PROFILE_ID); - $this->CreateUser(static::USER_TEST_LOGIN, 5); // profile:5 is "Support agent" - - // create token in the support user context - UserRights::Login(self::USER_TEST_LOGIN); + // create token in the user1 context + $bUser1Login1 = UserRights::Login(self::USER1_TEST_LOGIN); + $this->assertTrue($bUser1Login1, 'Login with user1 throw an error'); $sTransactionIdUserSupport = privUITransactionFile::GetNewTransactionId(); $bResult = privUITransactionFile::IsTransactionValid($sTransactionIdUserSupport, false); $this->assertTrue($bResult, 'Token created by support user must be valid in the support user context'); - // test token in the admin user context - UserRights::Login('admin'); + // test token in the user2 context + $bUser2Login = UserRights::Login(self::USER2_TEST_LOGIN); + $this->assertTrue($bUser2Login, 'Login with user2 throw an error'); $bResult = privUITransactionFile::IsTransactionValid($sTransactionIdUserSupport, false); $this->assertFalse($bResult, 'Token created by support user must be invalid in the admin user context'); $bResult = privUITransactionFile::RemoveTransaction($sTransactionIdUserSupport); $this->assertFalse($bResult, 'Token created by support user cannot be removed in the admin user context'); - // test other methods in the support user context - UserRights::Login(self::USER_TEST_LOGIN); + // test other methods in the user1 context + $bUser1Login2 = UserRights::Login(self::USER1_TEST_LOGIN); + $this->assertTrue($bUser1Login2, 'Login with user1 throw an error'); $bResult = privUITransactionFile::RemoveTransaction($sTransactionIdUserSupport); $this->assertTrue($bResult, 'Token created by support user must be removed in the support user context'); }