@@ -109,7 +109,7 @@ public function test_validateQueueRequest_ValidState_ExtendableCookie_NoCookieEx
109109 $ eventConfig ->actionName = "QueueAction " ;
110110 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
111111
112- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , "queueId " , null , "idle " ));
112+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , true , "queueId " , null , "idle " ));
113113 $ testObject = new QueueIT \KnownUserV3 \SDK \UserInQueueService ($ cookieProviderMock );
114114
115115 $ result = $ testObject ->validateQueueRequest ("url " , "token " , $ eventConfig , "customerid " , "key " );
@@ -131,7 +131,7 @@ public function test_validateQueueRequest_ValidState_ExtendableCookie_CookieExte
131131 $ eventConfig ->actionName = "QueueAction " ;
132132
133133 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
134- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , "queueId " , null , "disabled " ));
134+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , true , "queueId " , null , "disabled " ));
135135
136136 $ testObject = new QueueIT \KnownUserV3 \SDK \UserInQueueService ($ cookieProviderMock );
137137
@@ -153,7 +153,7 @@ public function test_validateQueueRequest_ValidState_NoExtendableCookie_DoNotRed
153153 $ eventConfig ->actionName = "QueueAction " ;
154154
155155 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
156- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , "queueId " , 3 , "idle " ));
156+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , true , "queueId " , 3 , "idle " ));
157157
158158 $ testObject = new QueueIT \KnownUserV3 \SDK \UserInQueueService ($ cookieProviderMock );
159159
@@ -177,7 +177,7 @@ public function test_validateQueueRequest_NoCookie_TampredToken_RedirectToErrorP
177177 $ eventConfig ->actionName = "QueueAction " ;
178178
179179 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
180- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , null , null , null ));
180+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , false , null , null , null ));
181181
182182 $ token = $ this ->generateHash ('e1 ' ,'queueId ' , strval (time () + (3 * 60 )), 'False ' , null , 'idle ' , $ key );
183183 $ token = str_replace ("False " , 'True ' , $ token );
@@ -215,7 +215,7 @@ public function test_validateQueueRequest_NoCookie_ExpiredTimeStampInToken_Redir
215215 $ eventConfig ->actionName = "Queue Action (._~-) !*|' \"" ;
216216 $ url = "http://test.test.com?b=h " ;
217217 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
218- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , null , null , null ));
218+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , false , null , null , null ));
219219 $ token = $ this ->generateHash ('e1 ' ,'queueId ' , strval (time () - (3 * 60 )), 'False ' , null , 'queue ' , $ key );
220220
221221 $ expectedErrorUrl = "https://testDomain.com/error/timestamp/?c=testCustomer&e=e1 " .
@@ -253,7 +253,7 @@ public function test_validateQueueRequest_NoCookie_EventIdMismatch_RedirectToErr
253253 $ eventConfig ->actionName = "Queue Action (._~-) !*|' \"" ;
254254 $ url = "http://test.test.com?b=h " ;
255255 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
256- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , null , null , null ));
256+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , false , null , null , null ));
257257 $ token = $ this ->generateHash ('e1 ' , 'queueId ' ,strval (time () - (3 * 60 )), 'False ' , null , 'queue ' , $ key );
258258
259259 $ expectedErrorUrl = "https://testDomain.com/error/eventid/?c=testCustomer&e=e2 " .
@@ -292,7 +292,7 @@ public function test_validateQueueRequest_NoCookie_ValidToken_ExtendableCookie_D
292292 //$eventConfig->actionName = "QueueAction";
293293 $ url = "http://test.test.com?b=h " ;
294294 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
295- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , null , null , null ));
295+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , false , null , null , null ));
296296
297297 $ token = $ this ->generateHash ('e1 ' , 'queueId ' ,strval (time () + (3 * 60 )), 'true ' , null , 'queue ' , $ key );
298298 $ testObject = new QueueIT \KnownUserV3 \SDK \UserInQueueService ($ cookieProviderMock );
@@ -316,7 +316,7 @@ public function test_validateQueueRequest_NoCookie_ValidToken_CookieValidityMinu
316316 //$eventConfig->actionName = "QueueAction";
317317 $ url = "http://test.test.com?b=h " ;
318318 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
319- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , null , null , null ));
319+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , false , null , null , null ));
320320 $ token = $ this ->generateHash ('e1 ' , 'queueId ' ,strval (time () + (3 * 60 )), 'false ' , 3 , 'DirectLink ' , $ key );
321321
322322 $ testObject = new QueueIT \KnownUserV3 \SDK \UserInQueueService ($ cookieProviderMock );
@@ -342,7 +342,7 @@ public function test_NoCookie_NoValidToken_WithoutToken_RedirectToQueue() {
342342
343343 $ url = "http://test.test.com?b=h " ;
344344 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
345- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , null , null , null ));
345+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , false , null , null , null ));
346346 $ token = "" ;
347347
348348 $ expectedRedirectUrl = "https://testDomain.com/?c=testCustomer&e=e1 " .
@@ -377,7 +377,7 @@ public function test_ValidateRequest_NoCookie_WithoutToken_RedirectToQueue_Notar
377377
378378 $ url = "http://test.test.com?b=h " ;
379379 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
380- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , null , null , null ));
380+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , false , null , null , null ));
381381 $ token = "" ;
382382
383383 $ expectedRedirectUrl = "https://testDomain.com/?c=testCustomer&e=e1 " .
@@ -397,6 +397,41 @@ public function test_ValidateRequest_NoCookie_WithoutToken_RedirectToQueue_Notar
397397 $ this ->assertTrue (strtolower ($ result ->actionName ) == strtolower ( $ eventConfig ->actionName ));
398398 }
399399
400+ public function test_ValidateRequest_InvalidCookie_WithoutToken_RedirectToQueue_CancelCookie () {
401+ $ key = "4e1db821-a825-49da-acd0-5d376f2068db " ;
402+ $ eventConfig = new QueueIT \KnownUserV3 \SDK \QueueEventConfig ();
403+ $ eventConfig ->eventId = "e1 " ;
404+ $ eventConfig ->queueDomain = "testDomain.com " ;
405+ $ eventConfig ->cookieValidityMinute = 10 ;
406+ $ eventConfig ->extendCookieValidity = false ;
407+ $ eventConfig ->version = 10 ;
408+ $ eventConfig ->actionName = "Queue Action (._~-) !*|' \"" ;
409+ $ eventConfig ->culture = null ;
410+ $ eventConfig ->layoutName = 'testlayout ' ;
411+
412+ $ url = "http://test.test.com?b=h " ;
413+ $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
414+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , false , null , null , null ));
415+ $ token = "" ;
416+
417+ $ expectedRedirectUrl = "https://testDomain.com/?c=testCustomer&e=e1 " .
418+ "&ver= " .QueueIT \KnownUserV3 \SDK \UserInQueueService::getSDKVersion ()
419+ . "&cver=10 "
420+ . "&man= " . rawurlencode ($ eventConfig ->actionName )
421+ . "&l=testlayout " ;
422+
423+ $ testObject = new QueueIT \KnownUserV3 \SDK \UserInQueueService ($ cookieProviderMock );
424+ $ result = $ testObject ->validateQueueRequest (null , $ token , $ eventConfig , "testCustomer " , $ key );
425+ $ this ->assertFalse ($ cookieProviderMock ->expectCallAny ('store ' ));
426+
427+ $ this ->assertTrue ($ result ->doRedirect ());
428+ $ this ->assertTrue ($ result ->eventId == 'e1 ' );
429+ $ this ->assertTrue ($ result ->queueId == null );
430+ $ this ->assertTrue (strtolower ($ result ->redirectUrl ) == strtolower ($ expectedRedirectUrl ));
431+ $ this ->assertTrue (strtolower ($ result ->actionName ) == strtolower ( $ eventConfig ->actionName ));
432+ $ this ->assertTrue ($ cookieProviderMock ->expectCallAny ('cancelQueueCookie ' ));
433+ }
434+
400435 public function test_validateQueueRequest_NoCookie_InValidToken () {
401436 $ key = "4e1db821-a825-49da-acd0-5d376f2068db " ;
402437 $ eventConfig = new QueueIT \KnownUserV3 \SDK \QueueEventConfig ();
@@ -411,7 +446,7 @@ public function test_validateQueueRequest_NoCookie_InValidToken() {
411446
412447 $ url = "http://test.test.com?b=h " ;
413448 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
414- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , null , null , null ));
449+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (false , false , null , null , null ));
415450 $ token = "" ;
416451
417452 $ testObject = new QueueIT \KnownUserV3 \SDK \UserInQueueService ($ cookieProviderMock );
@@ -424,7 +459,36 @@ public function test_validateQueueRequest_NoCookie_InValidToken() {
424459 $ this ->assertTrue (strpos ($ result ->redirectUrl , "https://testDomain.com/error/hash/?c=testCustomer&e=e1 " ) == 0 );
425460 $ this ->assertTrue (strtolower ($ result ->actionName ) == strtolower ('QueueAction ' ));
426461 }
462+
463+ public function test_validateQueueRequest_InvalidCookie_InvalidToken_CancelCookie () {
464+ $ key = "4e1db821-a825-49da-acd0-5d376f2068db " ;
465+ $ eventConfig = new QueueIT \KnownUserV3 \SDK \QueueEventConfig ();
466+ $ eventConfig ->eventId = "e1 " ;
467+ $ eventConfig ->queueDomain = "testDomain.com " ;
468+ $ eventConfig ->cookieValidityMinute = 10 ;
469+ $ eventConfig ->extendCookieValidity = true ;
470+ $ eventConfig ->version = 11 ;
471+ $ eventConfig ->actionName = "QueueAction " ;
472+ $ eventConfig ->culture = 'en-US ' ;
473+ $ eventConfig ->layoutName = 'testlayout ' ;
474+
475+ $ url = "http://test.test.com?b=h " ;
476+ $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
477+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , false , null , null , null ));
478+ $ token = "" ;
479+
480+ $ testObject = new QueueIT \KnownUserV3 \SDK \UserInQueueService ($ cookieProviderMock );
481+ $ result = $ testObject ->validateQueueRequest ($ url , "ts_sasa~cv_adsasa~ce_falwwwse~q_944c1f44-60dd-4e37-aabc-f3e4bb1c8895 " , $ eventConfig , "testCustomer " , $ key );
482+ $ this ->assertFalse ($ cookieProviderMock ->expectCallAny ('store ' ));
427483
484+ $ this ->assertTrue ($ result ->doRedirect ());
485+ $ this ->assertTrue ($ result ->eventId == 'e1 ' );
486+ $ this ->assertTrue ($ result ->queueId == null );
487+ $ this ->assertTrue (strpos ($ result ->redirectUrl , "https://testDomain.com/error/hash/?c=testCustomer&e=e1 " ) == 0 );
488+ $ this ->assertTrue (strtolower ($ result ->actionName ) == strtolower ('QueueAction ' ));
489+ $ this ->assertTrue ($ cookieProviderMock ->expectCallAny ('cancelQueueCookie ' ));
490+ }
491+
428492 public function test_validateCancelRequest () {
429493 $ key = "4e1db821-a825-49da-acd0-5d376f2068db " ;
430494 $ eventConfig = new QueueIT \KnownUserV3 \SDK \CancelEventConfig ();
@@ -435,7 +499,7 @@ public function test_validateCancelRequest() {
435499 $ eventConfig ->actionName = "QueueAction " ;
436500 $ url = "http://test.test.com?b=h " ;
437501 $ cookieProviderMock = new UserInQueueStateRepositoryMockClass ();
438- array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , "queueid " , 3 , "idle " ));
502+ array_push ($ cookieProviderMock ->arrayReturns ['getState ' ], new QueueIT \KnownUserV3 \SDK \StateInfo (true , true , "queueid " , 3 , "idle " ));
439503 $ token = "" ;
440504
441505 $ testObject = new QueueIT \KnownUserV3 \SDK \UserInQueueService ($ cookieProviderMock );
@@ -464,8 +528,8 @@ public function test_getIgnoreActionResult() {
464528 $ this ->assertTrue ($ result ->eventId == NULL );
465529 $ this ->assertTrue ($ result ->queueId == NULL );
466530 $ this ->assertTrue ($ result ->redirectUrl == NULL );
467- $ this ->assertTrue ($ result ->actionType == "Ignore " );
468- $ this ->assertTrue ($ result ->actionName == "IgnoreAction " );
531+ $ this ->assertTrue ($ result ->actionType == "Ignore " );
532+ $ this ->assertTrue ($ result ->actionName == "IgnoreAction " );
469533 }
470534
471535 public function generateHash ($ eventId , $ queueId , $ timestamp , $ extendableCookie , $ cookieValidityMinutes , $ redirectType , $ secretKey ) {
0 commit comments