From e29f1825be8a841fc4e094790e51f52e34d253d3 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 2 Nov 2021 17:05:13 +0100 Subject: [PATCH 1/2] =?UTF-8?q?N=C2=B04367=20Fix=20"redeclaration=20of=20c?= =?UTF-8?q?onst=20CombodoSanitizer"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The utils.js can be included more than once in old iTop branches :( This is fixed in 3.0.0 (develop branch) Also add missing ";" --- js/utils.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/utils.js b/js/utils.js index b1d1f9585..23744aa62 100644 --- a/js/utils.js +++ b/js/utils.js @@ -730,8 +730,7 @@ else { Dict.S = function (sEntry) { if (sEntry in Dict._entries) { return Dict._entries[sEntry]; - } - else { + } else { return sEntry; } }; @@ -739,7 +738,7 @@ Dict.Format = function () { var args = Array.from(arguments); args[0] = Dict.S(arguments[0]); return Format(args); -} +}; @@ -751,7 +750,7 @@ Dict.Format = function () { * @api * @since 2.6.5 2.7.6 3.0.0 N°4367 */ -const CombodoSanitizer = { +var CombodoSanitizer = { ENUM_SANITIZATION_FILTER_INTEGER: 'integer', ENUM_SANITIZATION_FILTER_STRING: 'string', ENUM_SANITIZATION_FILTER_CONTEXT_PARAM: 'context_param', @@ -805,4 +804,4 @@ const CombodoSanitizer = { return sDefaultValue; } } -} \ No newline at end of file +}; \ No newline at end of file From e8d314e1f63e312229ac85075d248e4db1b633ca Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Wed, 3 Nov 2021 10:46:59 +0100 Subject: [PATCH 2/2] =?UTF-8?q?:white=5Fcheck=5Fmark:=20N=C2=B04367=20Fix?= =?UTF-8?q?=20\privUITransactionFileTest::testIsTransactionValid=20*=20cha?= =?UTF-8?q?nge=20user=20name=20for=20when=20password=20policy=20is=20activ?= =?UTF-8?q?e=20*=20admin=20user=20doesn't=20exist=20on=20Jenkins=20:=20cre?= =?UTF-8?q?ate=20a=20second=20user=20*=20test=20UserRights::Login=20return?= =?UTF-8?q?=20value=20*=20document=20that=20we=20depend=20on=20the=20sampl?= =?UTF-8?q?e=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/privUITransactionFileTest.php | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/test/application/privUITransactionFileTest.php b/test/application/privUITransactionFileTest.php index aba678504..d416e3e22 100644 --- a/test/application/privUITransactionFileTest.php +++ b/test/application/privUITransactionFileTest.php @@ -1,31 +1,40 @@ 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'); }