Skip to content

Commit fe7fd78

Browse files
committed
version 3.6.2
1 parent b686bea commit fe7fd78

File tree

6 files changed

+184
-56
lines changed

6 files changed

+184
-56
lines changed

QueueIT.KnownUserV3.SDK.Tests/UserInQueueServiceTest.cs

Lines changed: 86 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void ValidateRequest_ValidState_ExtendableCookie_NoCookieExtensionFromCon
2929
};
3030

3131
cookieProviderMock.GetState("", 0, "")
32-
.ReturnsForAnyArgs(new StateInfo(true, queueId, null, "idle"));
32+
.ReturnsForAnyArgs(new StateInfo(true, true, queueId, null, "idle"));
3333

3434

3535
UserInQueueService testObject = new UserInQueueService(cookieProviderMock);
@@ -60,7 +60,7 @@ public void ValidateRequest_ValidState_ExtendableCookie_CookieExtensionFromConfi
6060
ActionName = "QueueAction"
6161
};
6262

63-
cookieProviderMock.GetState("", 20, "").ReturnsForAnyArgs(new StateInfo(true, queueId, null, "disabled"));
63+
cookieProviderMock.GetState("", 20, "").ReturnsForAnyArgs(new StateInfo(true, true, queueId, null, "disabled"));
6464

6565
UserInQueueService testObject = new UserInQueueService(cookieProviderMock);
6666

@@ -101,7 +101,7 @@ public void ValidateRequest_ValidState_NoExtendableCookie_DoNotRedirectDoNotStor
101101
var customerKey = "4e1db821-a825-49da-acd0-5d376f2068db";
102102

103103
cookieProviderMock.GetState("", 10, "")
104-
.ReturnsForAnyArgs(new StateInfo(true, queueId, 3, "idle"));
104+
.ReturnsForAnyArgs(new StateInfo(true, true, queueId, 3, "idle"));
105105

106106
UserInQueueService testObject = new UserInQueueService(cookieProviderMock);
107107

@@ -133,7 +133,7 @@ public void ValidateRequest_NoCookie_TampredToken_RedirectToErrorPageWithHashErr
133133
var customerKey = "4e1db821-a825-49da-acd0-5d376f2068db";
134134
var queueId = "iopdb821-a825-49da-acd0-5d376f2068db";
135135

136-
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, "", null, ""));
136+
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, false, "", null, ""));
137137
var queueitToken = QueueITTokenGenerator.GenerateToken(
138138
DateTime.UtcNow.AddHours(1),
139139
"e1",
@@ -167,7 +167,7 @@ public void ValidateRequest_NoCookie_TampredToken_RedirectToErrorPageWithHashErr
167167
Assert.True(config.EventId == result.EventId);
168168
Assert.Equal(config.ActionName, result.ActionName);
169169
cookieProviderMock.DidNotReceiveWithAnyArgs().Store("", "", null, "", "", "");
170-
cookieProviderMock.ReceivedWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
170+
cookieProviderMock.DidNotReceiveWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
171171
}
172172

173173
[Fact]
@@ -187,7 +187,7 @@ public void ValidateRequest_NoCookie_ExpiredTimeStampInToken_RedirectToErrorPage
187187
var customerKey = "4e1db821-a825-49da-acd0-5d376f2068db";
188188
var queueId = "iopdb821-a825-49da-acd0-5d376f2068db";
189189

190-
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, "", null, ""));
190+
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, false, "", null, ""));
191191
string hash = null;
192192
var queueitToken = QueueITTokenGenerator.GenerateToken(
193193
DateTime.UtcNow.AddHours(-1),
@@ -222,7 +222,7 @@ public void ValidateRequest_NoCookie_ExpiredTimeStampInToken_RedirectToErrorPage
222222
Assert.True(config.EventId == result.EventId);
223223
Assert.Equal(config.ActionName, result.ActionName);
224224
cookieProviderMock.DidNotReceiveWithAnyArgs().Store("", "", null, "", null, "");
225-
cookieProviderMock.ReceivedWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
225+
cookieProviderMock.DidNotReceiveWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
226226
}
227227

228228
[Fact]
@@ -240,7 +240,7 @@ public void ValidateRequest_NoCookie_EventIdMismatch_RedirectToErrorPageWithEven
240240
};
241241
var customerKey = "4e1db821-a825-49da-acd0-5d376f2068db";
242242
var queueId = "iopdb821-a825-49da-acd0-5d376f2068db";
243-
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, "", null, ""));
243+
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, false, "", null, ""));
244244
string hash = "";
245245

246246
var queueitToken = QueueITTokenGenerator.GenerateToken(
@@ -276,7 +276,7 @@ public void ValidateRequest_NoCookie_EventIdMismatch_RedirectToErrorPageWithEven
276276
Assert.True(config.EventId == result.EventId);
277277
Assert.Equal(config.ActionName, result.ActionName);
278278
cookieProviderMock.DidNotReceiveWithAnyArgs().Store("", "", null, "", null, "");
279-
cookieProviderMock.ReceivedWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
279+
cookieProviderMock.DidNotReceiveWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
280280
}
281281

282282
[Fact]
@@ -295,7 +295,7 @@ public void ValidateRequest_NoCookie_ValidToken_ExtendableCookie_DoNotRedirect_S
295295
var customerKey = "4e1db821-a825-49da-acd0-5d376f2068db";
296296

297297
var queueId = "iopdb821-a825-49da-acd0-5d376f2068db";
298-
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, "", null, ""));
298+
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, false, "", null, ""));
299299
string hash = "";
300300

301301
var queueitToken = QueueITTokenGenerator.GenerateToken(
@@ -343,7 +343,7 @@ public void ValidateRequest_NoCookie_ValidToken_CookieValidityMinuteFromToken_Do
343343
var customerKey = "secretekeyofuser";
344344
var queueId = "f8757c2d-34c2-4639-bef2-1736cdd30bbb";
345345

346-
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, "", null, ""));
346+
cookieProviderMock.GetState("", 10, "").ReturnsForAnyArgs(new StateInfo(false, false, "", null, ""));
347347

348348
var queueitToken = "e_eventid~q_f8757c2d-34c2-4639-bef2-1736cdd30bbb~ri_34678c2d-34c2-4639-bef2-1736cdd30bbb~ts_1797033600~ce_False~cv_3~rt_DirectLink~h_5ee2babc3ac9fae9d80d5e64675710c371876386e77209f771007dc3e093e326";
349349

@@ -386,7 +386,7 @@ public void ValidateRequest_NoCookie_WithoutToken_RedirectToQueue()
386386
ActionName = "QueueAction"
387387
};
388388

389-
cookieProviderMock.GetState("", 0, "").ReturnsForAnyArgs(new StateInfo(false, "", null, ""));
389+
cookieProviderMock.GetState("", 0, "").ReturnsForAnyArgs(new StateInfo(false, false, "", null, ""));
390390

391391
UserInQueueService testObject = new UserInQueueService(cookieProviderMock);
392392
var targetUrl = "http://test.test.com?b=h";
@@ -405,7 +405,7 @@ public void ValidateRequest_NoCookie_WithoutToken_RedirectToQueue()
405405
cookieProviderMock.DidNotReceiveWithAnyArgs().Store(null, null, null, null, null, null);
406406
Assert.True(config.EventId == result.EventId);
407407
Assert.Equal(config.ActionName, result.ActionName);
408-
cookieProviderMock.ReceivedWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
408+
cookieProviderMock.DidNotReceiveWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
409409
}
410410

411411
[Fact]
@@ -425,7 +425,7 @@ public void ValidateRequest_NoCookie_WithoutToken_RedirectToQueue_NotargetUrl()
425425
ActionName = "QueueAction"
426426
};
427427

428-
cookieProviderMock.GetState("", 0, "").ReturnsForAnyArgs(new StateInfo(false, "", null, null));
428+
cookieProviderMock.GetState("", 0, "").ReturnsForAnyArgs(new StateInfo(false, false, "", null, null));
429429

430430
UserInQueueService testObject = new UserInQueueService(cookieProviderMock);
431431

@@ -443,7 +443,44 @@ public void ValidateRequest_NoCookie_WithoutToken_RedirectToQueue_NotargetUrl()
443443
cookieProviderMock.DidNotReceiveWithAnyArgs().Store(null, null, null, null, null, null);
444444
Assert.True(config.EventId == result.EventId);
445445
Assert.Equal(config.ActionName, result.ActionName);
446-
cookieProviderMock.ReceivedWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
446+
cookieProviderMock.DidNotReceiveWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
447+
}
448+
449+
[Fact]
450+
public void ValidateRequest_InvalidCookie_WithoutToken_RedirectToQueue_CancelCookie()
451+
{
452+
var cookieProviderMock = Substitute.For<IUserInQueueStateRepository>();
453+
454+
var config = new QueueEventConfig()
455+
{
456+
EventId = "e1",
457+
QueueDomain = "testDomain.com",
458+
CookieValidityMinute = 10,
459+
ExtendCookieValidity = false,
460+
Culture = null,
461+
LayoutName = "testlayout",
462+
Version = 10,
463+
ActionName = "QueueAction"
464+
};
465+
466+
cookieProviderMock.GetState("", 0, "").ReturnsForAnyArgs(new StateInfo(true, false, "", null, null));
467+
468+
UserInQueueService testObject = new UserInQueueService(cookieProviderMock);
469+
470+
var knownUserVersion = UserInQueueService.SDK_VERSION;
471+
var expectedUrl = $"https://testDomain.com/?c=testCustomer&e=e1" +
472+
$"&ver={knownUserVersion}" +
473+
$"&cver=10" +
474+
$"&man=QueueAction" +
475+
$"&l={config.LayoutName}";
476+
var result = testObject.ValidateQueueRequest(null, "", config, "testCustomer", "key");
477+
478+
Assert.True(result.DoRedirect);
479+
Assert.True(result.RedirectUrl.ToUpper() == expectedUrl.ToUpper());
480+
cookieProviderMock.DidNotReceiveWithAnyArgs().Store(null, null, null, null, null, null);
481+
Assert.True(config.EventId == result.EventId);
482+
Assert.Equal(config.ActionName, result.ActionName);
483+
cookieProviderMock.Received().CancelQueueCookie(config.EventId, config.CookieDomain);
447484
}
448485

449486
[Fact]
@@ -462,7 +499,7 @@ public void ValidateRequest_NoCookie_InValidToken()
462499
Version = 10,
463500
ActionName = "QueueAction"
464501
};
465-
cookieProviderMock.GetState("", 0, "").ReturnsForAnyArgs(new StateInfo(false, null, null, null));
502+
cookieProviderMock.GetState("", 0, "").ReturnsForAnyArgs(new StateInfo(false, false, null, null, null));
466503

467504
UserInQueueService testObject = new UserInQueueService(cookieProviderMock);
468505
var targetUrl = "http://test.test.com?b=h";
@@ -475,7 +512,38 @@ public void ValidateRequest_NoCookie_InValidToken()
475512
cookieProviderMock.DidNotReceiveWithAnyArgs().Store(null, null, null, null, null, null);
476513
Assert.True(config.EventId == result.EventId);
477514
Assert.Equal(config.ActionName, result.ActionName);
478-
cookieProviderMock.ReceivedWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
515+
cookieProviderMock.DidNotReceiveWithAnyArgs().CancelQueueCookie(config.EventId, config.CookieDomain);
516+
}
517+
518+
[Fact]
519+
public void ValidateRequest_InvalidCookie_InvalidToken_CancelCookie()
520+
{
521+
var cookieProviderMock = Substitute.For<IUserInQueueStateRepository>();
522+
523+
var config = new QueueEventConfig()
524+
{
525+
EventId = "e1",
526+
QueueDomain = "testDomain.com",
527+
CookieValidityMinute = 10,
528+
ExtendCookieValidity = false,
529+
Culture = null,
530+
LayoutName = "testlayout",
531+
Version = 10,
532+
ActionName = "QueueAction"
533+
};
534+
cookieProviderMock.GetState("", 0, "").ReturnsForAnyArgs(new StateInfo(true, false, null, null, null));
535+
536+
UserInQueueService testObject = new UserInQueueService(cookieProviderMock);
537+
var targetUrl = "http://test.test.com?b=h";
538+
var knownUserVersion = UserInQueueService.SDK_VERSION;
539+
var result = testObject.ValidateQueueRequest(targetUrl, "ts_sasa~cv_adsasa~ce_falwwwse~q_944c1f44-60dd-4e37-aabc-f3e4bb1c8895", config, "testCustomer", "key");
540+
541+
Assert.True(result.DoRedirect);
542+
Assert.StartsWith($"https://testDomain.com/error/hash/?c=testCustomer&e=e1&ver={knownUserVersion}&cver=10&man=QueueAction&l=testlayout&queueittoken=ts_sasa~cv_adsasa~ce_falwwwse~q_944c1f44-60dd-4e37-aabc-f3e4bb1c8895&", result.RedirectUrl);
543+
cookieProviderMock.DidNotReceiveWithAnyArgs().Store(null, null, null, null, null, null);
544+
Assert.True(config.EventId == result.EventId);
545+
Assert.Equal(config.ActionName, result.ActionName);
546+
cookieProviderMock.Received().CancelQueueCookie(config.EventId, config.CookieDomain);
479547
}
480548

481549
[Fact]
@@ -497,7 +565,7 @@ public void ValidateCancelRequest()
497565
$"&ver={knownUserVersion}"
498566
+ $"&cver=10&man=QueueAction&r=" + "url";
499567
cookieProviderMock.GetState("", 0, "", false)
500-
.ReturnsForAnyArgs(new StateInfo(true, queueId, 3, "idle"));
568+
.ReturnsForAnyArgs(new StateInfo(true, true, queueId, 3, "idle"));
501569

502570
UserInQueueService testObject = new UserInQueueService(cookieProviderMock);
503571

QueueIT.KnownUserV3.SDK.Tests/UserInQueueStateCookieRepositoryTest.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Specialized;
3-
using System.Web;
43
using Xunit;
54

65
namespace QueueIT.KnownUserV3.SDK.Tests
@@ -414,6 +413,7 @@ public void GetState_ValidCookieFormat_Extendable()
414413

415414
Assert.True(state.IsStateExtendable);
416415
Assert.True(state.IsValid);
416+
Assert.True(state.IsFound);
417417
Assert.True(state.QueueId == queueId);
418418
Assert.True(state.RedirectType == "queue");
419419
}
@@ -448,6 +448,7 @@ public void GetState_OldCookie_InValid_ExpiredCookie_Extendable()
448448
var state = testObject.GetState(eventId, 10, secretKey);
449449

450450
Assert.True(!state.IsValid);
451+
Assert.True(state.IsFound);
451452
}
452453

453454
[Fact]
@@ -480,6 +481,7 @@ public void GetState_OldCookie_InValid_ExpiredCookie_NonExtendable()
480481
var state = testObject.GetState(eventId, 10, secretKey);
481482

482483
Assert.True(!state.IsValid);
484+
Assert.True(state.IsFound);
483485
}
484486

485487
[Fact]
@@ -513,8 +515,24 @@ public void GetState_ValidCookieFormat_NonExtendable()
513515

514516
Assert.False(state.IsStateExtendable);
515517
Assert.True(state.IsValid);
518+
Assert.True(state.IsFound);
516519
Assert.True(state.QueueId == queueId);
517520
Assert.True(state.RedirectType == "idle");
518521
}
522+
523+
[Fact]
524+
public void GetState_NoCookie()
525+
{
526+
KnownUserTest.HttpContextMock fakeContext = new KnownUserTest.HttpContextMock();
527+
var testObject = new UserInQueueStateCookieRepository(fakeContext);
528+
529+
var eventId = "event1";
530+
var secretKey = "4e1db821-a825-49da-acd0-5d376f2068db";
531+
532+
var state = testObject.GetState(eventId, 10, secretKey);
533+
534+
Assert.False(state.IsFound);
535+
Assert.False(state.IsValid);
536+
}
519537
}
520538
}

QueueIT.KnownUserV3.SDK/KnownUser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ internal static string GetRuntime()
389389
}
390390
catch
391391
{
392-
return "unresolved";
392+
return "unknown";
393393
}
394394
}
395395

QueueIT.KnownUserV3.SDK/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@
3434
// You can specify all the values or you can default the Build and Revision Numbers
3535
// by using the '*' as shown below:
3636
// [assembly: AssemblyVersion("1.0.*")]
37-
[assembly: AssemblyVersion("3.6.1")]
38-
[assembly: AssemblyFileVersion("3.6.1.0")]
37+
[assembly: AssemblyVersion("3.6.2")]
38+
[assembly: AssemblyFileVersion("3.6.2.0")]

0 commit comments

Comments
 (0)