From 6ff13d430d8d9030b4bac1988fa0b3936b89b1b4 Mon Sep 17 00:00:00 2001 From: Frederik Williams Date: Tue, 30 Jan 2018 11:32:10 +0100 Subject: [PATCH] Release 3.5 --- .../knownuserv3/sdk/CancelEventConfig.java | 14 +- .../queueit/knownuserv3/sdk/Constants.java | 2 +- .../queueit/knownuserv3/sdk/KnownUser.java | 3 +- .../knownuserv3/sdk/QueueEventConfig.java | 18 +- .../knownuserv3/sdk/QueueITHelpers.java | 34 +-- .../sdk/RequestValidationResult.java | 10 +- .../knownuserv3/sdk/UserInQueueService.java | 72 +++--- .../sdk/UserInQueueStateCookieRepository.java | 165 ++++++++----- .../sdk/UrlParameterProviderTest.java | 4 +- .../sdk/UserInQueueServiceTest.java | 218 ++++++++--------- .../UserInQueueStateCookieRepositoryTest.java | 224 +++++++++++++++--- 11 files changed, 481 insertions(+), 283 deletions(-) diff --git a/SDK/src/queueit/knownuserv3/sdk/CancelEventConfig.java b/SDK/src/queueit/knownuserv3/sdk/CancelEventConfig.java index 3f25f68..fe800e2 100644 --- a/SDK/src/queueit/knownuserv3/sdk/CancelEventConfig.java +++ b/SDK/src/queueit/knownuserv3/sdk/CancelEventConfig.java @@ -14,7 +14,7 @@ public String getEventId() { public void setEventId(String eventId) { this.eventId = eventId; } - + public String getQueueDomain() { return queueDomain; } @@ -42,12 +42,12 @@ public void setVersion(int version) { public CancelEventConfig() { this.version = -1; } - + @Override public String toString() { - return "EventId:" + eventId + - "&Version:" + version + - "&QueueDomain:" + queueDomain + - "&CookieDomain:" + cookieDomain; + return "EventId:" + eventId + + "&Version:" + version + + "&QueueDomain:" + queueDomain + + "&CookieDomain:" + cookieDomain; } -} \ No newline at end of file +} diff --git a/SDK/src/queueit/knownuserv3/sdk/Constants.java b/SDK/src/queueit/knownuserv3/sdk/Constants.java index ce18d3b..c8ffe79 100644 --- a/SDK/src/queueit/knownuserv3/sdk/Constants.java +++ b/SDK/src/queueit/knownuserv3/sdk/Constants.java @@ -1,7 +1,7 @@ package queueit.knownuserv3.sdk; final class ActionType { - + public static final String CANCEL_ACTION = "Cancel"; public static final String QUEUE_ACTION = "Queue"; public static final String IGNORE_ACTION = "Ignore"; diff --git a/SDK/src/queueit/knownuserv3/sdk/KnownUser.java b/SDK/src/queueit/knownuserv3/sdk/KnownUser.java index cc5b492..74e989b 100644 --- a/SDK/src/queueit/knownuserv3/sdk/KnownUser.java +++ b/SDK/src/queueit/knownuserv3/sdk/KnownUser.java @@ -68,7 +68,7 @@ public static RequestValidationResult validateRequestByIntegrationConfig(String } if (matchedConfig == null) { - return new RequestValidationResult(null, null, null, null); + return new RequestValidationResult(null, null, null, null, null); } // unspecified or 'Queue' specified @@ -343,7 +343,6 @@ public void setCookie(String cookieName, String cookieValue, Integer expiration, cookie.setDomain(cookieDomain); } - cookie.setHttpOnly(true); response.addCookie(cookie); } diff --git a/SDK/src/queueit/knownuserv3/sdk/QueueEventConfig.java b/SDK/src/queueit/knownuserv3/sdk/QueueEventConfig.java index 0be6523..c970173 100644 --- a/SDK/src/queueit/knownuserv3/sdk/QueueEventConfig.java +++ b/SDK/src/queueit/knownuserv3/sdk/QueueEventConfig.java @@ -78,16 +78,16 @@ public void setVersion(int version) { public QueueEventConfig() { this.version = -1; } - + @Override public String toString() { - return "EventId:" + eventId + - "&Version:" + version + - "&QueueDomain:" + queueDomain + - "&CookieDomain:" + cookieDomain + - "&ExtendCookieValidity:" + extendCookieValidity + - "&CookieValidityMinute:" + cookieValidityMinute + - "&LayoutName:" + layoutName + - "&Culture:" + culture; + return "EventId:" + eventId + + "&Version:" + version + + "&QueueDomain:" + queueDomain + + "&CookieDomain:" + cookieDomain + + "&ExtendCookieValidity:" + extendCookieValidity + + "&CookieValidityMinute:" + cookieValidityMinute + + "&LayoutName:" + layoutName + + "&Culture:" + culture; } } diff --git a/SDK/src/queueit/knownuserv3/sdk/QueueITHelpers.java b/SDK/src/queueit/knownuserv3/sdk/QueueITHelpers.java index 1ac463a..4150d4c 100644 --- a/SDK/src/queueit/knownuserv3/sdk/QueueITHelpers.java +++ b/SDK/src/queueit/knownuserv3/sdk/QueueITHelpers.java @@ -32,11 +32,11 @@ class QueueParameterHelper { public static final String TimeStampKey = "ts"; public static final String ExtendableCookieKey = "ce"; - public static final String CookieValidityMinuteKey = "cv"; + public static final String CookieValidityMinutesKey = "cv"; public static final String HashKey = "h"; public static final String QueueIdKey = "q"; public static final String RedirectTypeKey = "rt"; - public static final String EventIdKey = "e"; + public static final String EventIdKey = "e"; public static final String KeyValueSeparatorChar = "_"; public static final String KeyValueSeparatorGroupChar = "~"; @@ -61,11 +61,11 @@ public static QueueUrlParams extractQueueParams(String queueitToken) { result.setTimeStamp(0); } break; - case CookieValidityMinuteKey: { + case CookieValidityMinutesKey: { if (Utils.isInteger(keyValueArr[1])) { - result.setCookieValidityMinute(Integer.parseInt(keyValueArr[1])); + result.setCookieValidityMinutes(Integer.parseInt(keyValueArr[1])); } else { - result.setCookieValidityMinute(null); + result.setCookieValidityMinutes(null); } break; } @@ -78,7 +78,7 @@ public static QueueUrlParams extractQueueParams(String queueitToken) { break; case ExtendableCookieKey: result.setExtendableCookie(Boolean.parseBoolean(keyValueArr[1])); - break; + break; case HashKey: result.setHashCode(keyValueArr[1]); break; @@ -121,22 +121,22 @@ class QueueUrlParams { private boolean extendableCookie; private String queueITToken; private String queueITTokenWithoutHash; - private Integer cookieValidityMinute; + private Integer cookieValidityMinutes; private long timeStamp; private String queueId; private String redirectType; - public QueueUrlParams(){ + public QueueUrlParams() { this.eventId = ""; this.hashCode = ""; this.extendableCookie = false; this.queueITToken = ""; this.queueITTokenWithoutHash = ""; - this.cookieValidityMinute = null; + this.cookieValidityMinutes = null; this.timeStamp = 0; this.queueId = ""; } - + public String getEventId() { return this.eventId; } @@ -161,12 +161,12 @@ public void setExtendableCookie(boolean extendableCookie) { this.extendableCookie = extendableCookie; } - public Integer getCookieValidityMinute() { - return this.cookieValidityMinute; + public Integer getCookieValidityMinutes() { + return this.cookieValidityMinutes; } - public void setCookieValidityMinute(Integer cookieValidityMinute) { - this.cookieValidityMinute = cookieValidityMinute; + public void setCookieValidityMinutes(Integer cookieValidityMinute) { + this.cookieValidityMinutes = cookieValidityMinute; } public String getQueueITToken() { @@ -200,11 +200,11 @@ public void setQueueId(String queueId) { public String getQueueId() { return this.queueId; } - - public void setRedirectType(String redirectType) { + + public void setRedirectType(String redirectType) { this.redirectType = redirectType; } - + public String getRedirectType() { return this.redirectType; } diff --git a/SDK/src/queueit/knownuserv3/sdk/RequestValidationResult.java b/SDK/src/queueit/knownuserv3/sdk/RequestValidationResult.java index 34305fb..12c9d5d 100644 --- a/SDK/src/queueit/knownuserv3/sdk/RequestValidationResult.java +++ b/SDK/src/queueit/knownuserv3/sdk/RequestValidationResult.java @@ -6,18 +6,20 @@ public class RequestValidationResult { private String eventId; private String redirectUrl; private String queueId; + private String redirectType; - public RequestValidationResult(String actionType, String eventId, String queueId, String redirectUrl) { + public RequestValidationResult(String actionType, String eventId, String queueId, String redirectUrl, String redirectType) { this.actionType = actionType; this.eventId = eventId; this.queueId = queueId; this.redirectUrl = redirectUrl; + this.redirectType = redirectType; } public String getActionType() { return actionType; } - + public String getEventId() { return eventId; } @@ -33,6 +35,10 @@ public boolean doRedirect() { public String getQueueId() { return this.queueId; } + + public String getRedirectType() { + return this.redirectType; + } } class KnowUserException extends Exception { diff --git a/SDK/src/queueit/knownuserv3/sdk/UserInQueueService.java b/SDK/src/queueit/knownuserv3/sdk/UserInQueueService.java index 3fc6b0b..d6edb92 100644 --- a/SDK/src/queueit/knownuserv3/sdk/UserInQueueService.java +++ b/SDK/src/queueit/knownuserv3/sdk/UserInQueueService.java @@ -18,20 +18,20 @@ RequestValidationResult validateCancelRequest( CancelEventConfig config, String customerId, String secretKey) throws Exception; - + void extendQueueCookie( String eventId, - int cookieValidityMinute, + int cookieValidityMinutes, String cookieDomain, String secretKey ); - + RequestValidationResult getIgnoreActionResult(); } class UserInQueueService implements IUserInQueueService { - public static final String SDK_VERSION = "3.4.0"; + public static final String SDK_VERSION = "3.5.0"; private final IUserInQueueStateRepository _userInQueueStateRepository; public UserInQueueService( @@ -47,17 +47,18 @@ public RequestValidationResult validateQueueRequest( String customerId, String secretKey ) throws Exception { - StateInfo stateInfo = this._userInQueueStateRepository.getState(config.getEventId(), secretKey); + StateInfo stateInfo = this._userInQueueStateRepository.getState(config.getEventId(), config.getCookieValidityMinute(), secretKey, true); if (stateInfo.isValid()) { if (stateInfo.isStateExtendable() && config.getExtendCookieValidity()) { - this._userInQueueStateRepository.store(config.getEventId(), + this._userInQueueStateRepository.store( + config.getEventId(), stateInfo.getQueueId(), - true, + null, config.getCookieDomain(), - config.getCookieValidityMinute(), + stateInfo.getRedirectType(), secretKey); } - return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), stateInfo.getQueueId(), null); + return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), stateInfo.getQueueId(), null, stateInfo.getRedirectType()); } QueueUrlParams queueParmas = QueueParameterHelper.extractQueueParams(queueitToken); @@ -92,12 +93,12 @@ private RequestValidationResult getQueueITTokenValidationResult( this._userInQueueStateRepository.store( config.getEventId(), queueParams.getQueueId(), - queueParams.getExtendableCookie(), + queueParams.getCookieValidityMinutes(), config.getCookieDomain(), - queueParams.getCookieValidityMinute() != null ? queueParams.getCookieValidityMinute() : config.getCookieValidityMinute(), + queueParams.getRedirectType(), secretKey); - return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), queueParams.getQueueId(), null); + return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), queueParams.getQueueId(), null, queueParams.getRedirectType()); } private RequestValidationResult getVaidationErrorResult( @@ -110,8 +111,7 @@ private RequestValidationResult getVaidationErrorResult( String query = getQueryString(customerId, config.getEventId(), config.getVersion(), config.getCulture(), config.getLayoutName()) + "&queueittoken=" + qParams.getQueueITToken() + "&ts=" + System.currentTimeMillis() / 1000L; - if(!Utils.isNullOrWhiteSpace(targetUrl)) - { + if (!Utils.isNullOrWhiteSpace(targetUrl)) { query += "&t=" + URLEncoder.encode(targetUrl, "UTF-8"); } String domainAlias = config.getQueueDomain(); @@ -119,7 +119,7 @@ private RequestValidationResult getVaidationErrorResult( domainAlias = domainAlias + "/"; } String redirectUrl = "https://" + domainAlias + "error/" + errorCode + "/?" + query; - return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), null, redirectUrl); + return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), null, redirectUrl, null); } private RequestValidationResult getInQueueRedirectResult( @@ -129,11 +129,11 @@ private RequestValidationResult getInQueueRedirectResult( String redirectUrl = "https://" + config.getQueueDomain() + "?" + getQueryString(customerId, config.getEventId(), config.getVersion(), config.getCulture(), config.getLayoutName()); - if(!Utils.isNullOrWhiteSpace(targetUrl)) { + if (!Utils.isNullOrWhiteSpace(targetUrl)) { redirectUrl += "&t=" + URLEncoder.encode(targetUrl, "UTF-8"); } - - return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), null, redirectUrl); + + return new RequestValidationResult(ActionType.QUEUE_ACTION, config.getEventId(), null, redirectUrl, null); } private String getQueryString( @@ -158,49 +158,49 @@ private String getQueryString( return String.join("&", queryStringList); } - + @Override public void extendQueueCookie( String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { - this._userInQueueStateRepository.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, secretKey); + this._userInQueueStateRepository.reissueQueueCookie(eventId, cookieValidityMinute, cookieDomain, secretKey); } - + @Override public RequestValidationResult validateCancelRequest( - String targetUrl, - CancelEventConfig config, - String customerId, + String targetUrl, + CancelEventConfig config, + String customerId, String secretKey) throws Exception { - - StateInfo state = _userInQueueStateRepository.getState(config.getEventId(), secretKey); + + StateInfo state = _userInQueueStateRepository.getState(config.getEventId(), -1, secretKey, false); if (state.isValid()) { this._userInQueueStateRepository.cancelQueueCookie(config.getEventId(), config.getCookieDomain()); String query = getQueryString(customerId, config.getEventId(), config.getVersion(), null, null); - - if(targetUrl != null) + + if (targetUrl != null) { query += "&r=" + URLEncoder.encode(targetUrl, "UTF-8"); + } String domainAlias = config.getQueueDomain(); - if (!domainAlias.endsWith("/")) + if (!domainAlias.endsWith("/")) { domainAlias = domainAlias + "/"; + } String redirectUrl = "https://" + domainAlias + "cancel/" + customerId + "/" + config.getEventId() + "/?" + query; - return new RequestValidationResult(ActionType.CANCEL_ACTION, config.getEventId(), state.getQueueId(), redirectUrl); - } - else - { - return new RequestValidationResult(ActionType.CANCEL_ACTION, config.getEventId(), null, null); + return new RequestValidationResult(ActionType.CANCEL_ACTION, config.getEventId(), state.getQueueId(), redirectUrl, state.getRedirectType()); + } else { + return new RequestValidationResult(ActionType.CANCEL_ACTION, config.getEventId(), null, null, null); } } - + @Override public RequestValidationResult getIgnoreActionResult() { - return new RequestValidationResult(ActionType.IGNORE_ACTION, null, null, null); + return new RequestValidationResult(ActionType.IGNORE_ACTION, null, null, null, null); } } diff --git a/SDK/src/queueit/knownuserv3/sdk/UserInQueueStateCookieRepository.java b/SDK/src/queueit/knownuserv3/sdk/UserInQueueStateCookieRepository.java index 7722742..f186897 100644 --- a/SDK/src/queueit/knownuserv3/sdk/UserInQueueStateCookieRepository.java +++ b/SDK/src/queueit/knownuserv3/sdk/UserInQueueStateCookieRepository.java @@ -8,21 +8,24 @@ interface IUserInQueueStateRepository { void store( String eventId, String queueId, - boolean isStateExtendable, + Integer fixedCookieValidityMinutes, String cookieDomain, - int cookieValidityMinute, - String customerSecretKey) throws Exception; + String redirectType, + String secretKey) throws Exception; StateInfo getState(String eventId, - String customerSecretKey); + int cookieValidityMinutes, + String secretKey, + boolean validateTime); void cancelQueueCookie( String eventId, - String cookieDomain); + String cookieDomain + ); - void extendQueueCookie( + void reissueQueueCookie( String eventId, - int cookieValidityMinute, + int cookieValidityMinutes, String cookieDomain, String secretKey ); @@ -32,9 +35,11 @@ class UserInQueueStateCookieRepository implements IUserInQueueStateRepository { private static final String QUEUEIT_DATA_KEY = "QueueITAccepted-SDFrts345E-V3"; private static final String QUEUE_ID_KEY = "QueueId"; - private static final String IS_COOKIE_EXTENDABLE_KEY = "IsCookieExtendable"; private static final String HASH_KEY = "Hash"; - private static final String EXPIRES_KEY = "Expires"; + private static final String ISSUETIME_KEY = "IssueTime"; + private static final String REDIRECT_TYPE_KEY = "RedirectType"; + private static final String EVENT_ID_KEY = "EventId"; + private static final String FIXED_COOKIE_VALIDITY_MINUTES_KEY = "FixedValidityMins"; private final ICookieManager cookieManager; @@ -50,63 +55,88 @@ public UserInQueueStateCookieRepository(ICookieManager cookieManeger) { public void store( String eventId, String queueId, - boolean isStateExtendable, + Integer fixedCookieValidityMinutes, String cookieDomain, - int cookieValidityMinute, + String redirectType, String secretKey) throws Exception { String cookieKey = getCookieKey(eventId); - Long expirationTime = System.currentTimeMillis() / 1000L + cookieValidityMinute * 60; - String isStateExtendableString = Boolean.toString(isStateExtendable); - - String cookieValue = createCookieValue(queueId, isStateExtendableString, String.valueOf(expirationTime), secretKey); + String cookieValue = createCookieValue(eventId, queueId, fixedCookieValidityMinutes, redirectType, secretKey); this.cookieManager.setCookie(cookieKey, cookieValue, 24 * 60 * 60, cookieDomain); } - private String createCookieValue(String queueId, String isStateExtendable, String expirationTime, String secretKey) throws Exception { - String hashValue = HashHelper.generateSHA256Hash(secretKey, queueId - + isStateExtendable - + expirationTime); - String cookieValue = QUEUE_ID_KEY + "=" + queueId + "&" + IS_COOKIE_EXTENDABLE_KEY - + "=" + isStateExtendable + "&" + EXPIRES_KEY + "=" + expirationTime + "&" + HASH_KEY + "=" + hashValue; + private String createCookieValue(String eventId, String queueId, Integer fixedCookieValidityMinutes, String redirectType, String secretKey) throws Exception { + String issueTime = Long.toString(System.currentTimeMillis() / 1000L); + String fixedValidityStr = fixedCookieValidityMinutes != null ? String.valueOf(fixedCookieValidityMinutes) : ""; + + String hashValue = HashHelper.generateSHA256Hash(secretKey, eventId + queueId + + fixedValidityStr + + redirectType + + issueTime); + String cookieValue = EVENT_ID_KEY + "=" + eventId + "&" + QUEUE_ID_KEY + "=" + queueId + "&" + + (fixedCookieValidityMinutes != null ? (FIXED_COOKIE_VALIDITY_MINUTES_KEY + "=" + fixedValidityStr + "&") : "") + + REDIRECT_TYPE_KEY + "=" + redirectType + + "&" + ISSUETIME_KEY + "=" + issueTime + "&" + HASH_KEY + "=" + hashValue; return cookieValue; } private Boolean isCookieValid( + String secretKey, HashMap cookieNameValueMap, - String secretKey) { + String eventId, + int cookieValidityMinutes, + boolean validateTime) { try { - if (!cookieNameValueMap.containsKey(IS_COOKIE_EXTENDABLE_KEY) - || Utils.isNullOrWhiteSpace(IS_COOKIE_EXTENDABLE_KEY)) { + if (!cookieNameValueMap.containsKey(EVENT_ID_KEY)) { + return false; + } + if (!cookieNameValueMap.containsKey(QUEUE_ID_KEY)) { return false; } - if (!cookieNameValueMap.containsKey(QUEUE_ID_KEY) - || Utils.isNullOrWhiteSpace(QUEUE_ID_KEY)) { + if (!cookieNameValueMap.containsKey(REDIRECT_TYPE_KEY)) { return false; } - if (!cookieNameValueMap.containsKey(EXPIRES_KEY) - || Utils.isNullOrWhiteSpace(EXPIRES_KEY)) { + if (!cookieNameValueMap.containsKey(ISSUETIME_KEY)) { return false; } - if (!cookieNameValueMap.containsKey(HASH_KEY) - || Utils.isNullOrWhiteSpace(HASH_KEY)) { + if (!cookieNameValueMap.containsKey(HASH_KEY)) { return false; } + String fixedCookieValidityMinutes = ""; + if (cookieNameValueMap.containsKey(FIXED_COOKIE_VALIDITY_MINUTES_KEY)) { + fixedCookieValidityMinutes = cookieNameValueMap.get(FIXED_COOKIE_VALIDITY_MINUTES_KEY); + } + String hashValue = HashHelper.generateSHA256Hash(secretKey, - cookieNameValueMap.get(QUEUE_ID_KEY) - + cookieNameValueMap.get(IS_COOKIE_EXTENDABLE_KEY) - + cookieNameValueMap.get(EXPIRES_KEY)); + cookieNameValueMap.get(EVENT_ID_KEY) + + cookieNameValueMap.get(QUEUE_ID_KEY) + + fixedCookieValidityMinutes + + cookieNameValueMap.get(REDIRECT_TYPE_KEY) + + cookieNameValueMap.get(ISSUETIME_KEY)); if (!Objects.equals(hashValue, cookieNameValueMap.get(HASH_KEY))) { return false; } - Long nowSecond = System.currentTimeMillis() / 1000L; - if (Long.parseLong(cookieNameValueMap.get(EXPIRES_KEY)) < nowSecond) { + if (!eventId.toLowerCase().equals(cookieNameValueMap.get(EVENT_ID_KEY).toLowerCase())) { return false; } + + if (validateTime) { + int validity = cookieValidityMinutes; + if (!Utils.isNullOrWhiteSpace(fixedCookieValidityMinutes)) { + validity = Integer.valueOf(fixedCookieValidityMinutes); + } + + long expirationTime = Long.valueOf(cookieNameValueMap.get(ISSUETIME_KEY)) + (validity * 60); + if (expirationTime < (System.currentTimeMillis() / 1000L)) { + return false; + } + } + return true; + } catch (Exception ex) { } return true; @@ -116,10 +146,7 @@ public static HashMap getCookieNameValueMap(String cookieValue) HashMap result = new HashMap<>(); String[] cookieNameValues = cookieValue.split("&"); - if (cookieNameValues.length < 4) { - return result; - } - for (int i = 0; i < 4; ++i) { + for (int i = 0; i < cookieNameValues.length; ++i) { String[] arr = cookieNameValues[i].split("="); if (arr.length == 2) { result.put(arr[0], arr[1]); @@ -129,25 +156,25 @@ public static HashMap getCookieNameValueMap(String cookieValue) } @Override - public StateInfo getState(String eventId, String secretKey) { + public StateInfo getState(String eventId, int cookieValidityMinutes, String secretKey, boolean validateTime) { try { String cookieKey = getCookieKey(eventId); String cookieValue = this.cookieManager.getCookie(cookieKey); if (cookieValue == null) { - return new StateInfo(false, null, false, 0); + return new StateInfo(false, null, null, null); } HashMap cookieNameValueMap = UserInQueueStateCookieRepository.getCookieNameValueMap(cookieValue); - if (!isCookieValid(cookieNameValueMap, secretKey)) { - return new StateInfo(false, null, false, 0); + if (!isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, validateTime)) { + return new StateInfo(false, null, null, null); } return new StateInfo(true, cookieNameValueMap.get(QUEUE_ID_KEY), - Boolean.parseBoolean(cookieNameValueMap.get(IS_COOKIE_EXTENDABLE_KEY)), - Long.parseLong(cookieNameValueMap.get(EXPIRES_KEY))); + cookieNameValueMap.get(FIXED_COOKIE_VALIDITY_MINUTES_KEY), + cookieNameValueMap.get(REDIRECT_TYPE_KEY)); } catch (NumberFormatException ex) { } - return new StateInfo(false, null, false, 0); + return new StateInfo(false, null, null, null); } @Override @@ -155,15 +182,16 @@ public void cancelQueueCookie( String eventId, String cookieDomain) { String cookieKey = getCookieKey(eventId); - cookieManager.setCookie(cookieKey, null, 0, cookieDomain); + cookieManager.setCookie(cookieKey, null, 0, cookieDomain); } @Override - public void extendQueueCookie( + public void reissueQueueCookie( String eventId, - int cookieValidityMinute, + int cookieValidityMinutes, String cookieDomain, - String secretKey) { + String secretKey + ) { try { String cookieKey = getCookieKey(eventId); String cookieValueOld = this.cookieManager.getCookie(cookieKey); @@ -171,13 +199,20 @@ public void extendQueueCookie( return; } HashMap cookieNameValueMap = getCookieNameValueMap(cookieValueOld); - if (!isCookieValid(cookieNameValueMap, secretKey)) { + if (!isCookieValid(secretKey, cookieNameValueMap, eventId, cookieValidityMinutes, true)) { return; } - long expirationTime = System.currentTimeMillis() / 1000L + cookieValidityMinute * 60; - String cookieValue = createCookieValue(cookieNameValueMap.get(QUEUE_ID_KEY), cookieNameValueMap.get(IS_COOKIE_EXTENDABLE_KEY), - String.valueOf(expirationTime), secretKey); + + String issueTime = Long.toString(System.currentTimeMillis() / 1000L); + Integer fixedCookieValidityMinutes = null; + if (cookieNameValueMap.containsKey(FIXED_COOKIE_VALIDITY_MINUTES_KEY)) { + fixedCookieValidityMinutes = Integer.valueOf(cookieNameValueMap.get(FIXED_COOKIE_VALIDITY_MINUTES_KEY)); + } + + String cookieValue = createCookieValue(eventId, cookieNameValueMap.get(QUEUE_ID_KEY), + fixedCookieValidityMinutes, cookieNameValueMap.get(REDIRECT_TYPE_KEY), secretKey); this.cookieManager.setCookie(cookieKey, cookieValue, 24 * 60 * 60, cookieDomain); + } catch (Exception ex) { } } @@ -187,14 +222,16 @@ class StateInfo { private final boolean isValid; private final String queueId; - private final boolean isStateExtendable; - private final long expires; + private final String redirectType; + private final String fixedCookieValidityMinutes; - public StateInfo(boolean isValid, String queueid, boolean isStateExtendable, long expires /*used in tests*/) { + public StateInfo(boolean isValid, String queueid, String fixedCookieValidityMinutes, + String redirectType + ) { this.isValid = isValid; this.queueId = queueid; - this.isStateExtendable = isStateExtendable; - this.expires = expires; + this.fixedCookieValidityMinutes = fixedCookieValidityMinutes; + this.redirectType = redirectType; } public String getQueueId() { @@ -205,12 +242,12 @@ public boolean isValid() { return this.isValid; } - public boolean isStateExtendable() { - return this.isStateExtendable; + public String getRedirectType() { + return this.redirectType; } - //used in tests - public long getExpires() { - return this.expires; + public boolean isStateExtendable() { + return this.isValid && Utils.isNullOrWhiteSpace(this.fixedCookieValidityMinutes); } + } diff --git a/SDK/test/queueit/knownuserv3/sdk/UrlParameterProviderTest.java b/SDK/test/queueit/knownuserv3/sdk/UrlParameterProviderTest.java index 0462034..f5eec79 100644 --- a/SDK/test/queueit/knownuserv3/sdk/UrlParameterProviderTest.java +++ b/SDK/test/queueit/knownuserv3/sdk/UrlParameterProviderTest.java @@ -13,7 +13,7 @@ public void TryExtractQueueParams_Test() { QueueUrlParams queueParameter = QueueParameterHelper.extractQueueParams(queueitToken); assertTrue(queueParameter.getTimeStamp() == 1480593661); assertTrue("eventid".equals(queueParameter.getEventId())); - assertTrue(queueParameter.getCookieValidityMinute() == 10); + assertTrue(queueParameter.getCookieValidityMinutes() == 10); assertTrue(queueParameter.getExtendableCookie() == false); assertTrue("218b734e-d5be-4b60-ad66-9b1b326266e2".equals(queueParameter.getHashCode())); assertTrue(Objects.equals(queueParameter.getQueueITToken(), queueitToken)); @@ -27,7 +27,7 @@ public void TryExtractQueueParams_NotValidFormat_Test() { QueueUrlParams queueParameter = QueueParameterHelper.extractQueueParams(queueitToken); assertTrue(queueParameter.getTimeStamp() == 0); assertTrue("".equals(queueParameter.getEventId())); - assertTrue(queueParameter.getCookieValidityMinute() == null); + assertTrue(queueParameter.getCookieValidityMinutes() == null); assertTrue(queueParameter.getExtendableCookie() == false); assertTrue("".equals(queueParameter.getHashCode())); assertTrue(Objects.equals(queueParameter.getQueueITToken(), queueitToken)); diff --git a/SDK/test/queueit/knownuserv3/sdk/UserInQueueServiceTest.java b/SDK/test/queueit/knownuserv3/sdk/UserInQueueServiceTest.java index 289896b..11e165c 100644 --- a/SDK/test/queueit/knownuserv3/sdk/UserInQueueServiceTest.java +++ b/SDK/test/queueit/knownuserv3/sdk/UserInQueueServiceTest.java @@ -28,24 +28,25 @@ public void validateQueueRequest_ValidState_ExtendableCookie_NoCookieExtensionFr conditions.put("isStoreWasCalled", false); IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { + @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, int cookieValidityMinute, String customerSecretKey) throws Exception { - conditions.replace("isStoreWasCalled", true); + public void cancelQueueCookie(String eventId, String cookieDomain) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(true, "queueId", true, System.currentTimeMillis() / 1000L + 10 * 60); - + public void store(String eventId, String queueId,Integer fixedCookieValidityMinutes, String cookieDomainString, + String redirectType, String customerSecretKey) throws Exception { + conditions.replace("isStoreWasCalled", true); } @Override - public void cancelQueueCookie(String eventId, String cookieDomain) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(true, "queueId", null, "queue"); } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; @@ -56,10 +57,11 @@ public void extendQueueCookie(String eventId, int cookieValidityMinute, String c assertTrue(!conditions.get("isStoreWasCalled")); assertTrue(result.getEventId().equals("e1")); assertTrue(result.getQueueId().equals("queueId")); + assertTrue(result.getRedirectType().equals("queue")); } @Test - public void validateQueueRequest_ValidState_ExtendableCookie_CookieExtensionFromConfig_DoNotRedirectDoStoreCookieWithExtension() throws Exception { + public void validateQueueRequest_ValidState_ExtendableCookie_CookieExtensionFromConfig_DoNotRedirect_DoStoreCookieWithExtension() throws Exception { QueueEventConfig config = new QueueEventConfig(); config.setEventId("e1"); @@ -71,11 +73,11 @@ public void validateQueueRequest_ValidState_ExtendableCookie_CookieExtensionFrom callInfo.put("firstCall", new HashMap<>()); IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, - int cookieValidityMinute, String customerSecretKey) throws Exception { + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, String redirectType, String customerSecretKey) throws Exception { HashMap info = new HashMap<>(); info.put("eventId", eventId); - info.put("isStateExtendable", isStateExtendable); + info.put("fixedCookieValidityMinutes", fixedCookieValidityMinutes); + info.put("redirectType", redirectType); info.put("cookieDomain", cookieDomain); info.put("queueId", queueId); info.put("customerSecretKey", customerSecretKey); @@ -83,8 +85,8 @@ public void store(String eventId, String queueId, boolean isStateExtendable, Str } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(true, "queueId", true, System.currentTimeMillis() / 1000L + 10 * 60); + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(true, "queueId", null, "queue"); } @@ -94,7 +96,7 @@ public void cancelQueueCookie(String eventId, String cookieDomain) { } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; @@ -105,13 +107,13 @@ public void extendQueueCookie(String eventId, int cookieValidityMinute, String c assertTrue(!result.doRedirect()); assertTrue(callInfo.get("firstCall").get("queueId").equals("queueId")); assertTrue(callInfo.get("firstCall").get("eventId").equals("e1")); - assertTrue(callInfo.get("firstCall").get("isStateExtendable").equals(true)); + assertTrue(callInfo.get("firstCall").get("redirectType").equals("queue")); assertTrue(callInfo.get("firstCall").get("customerSecretKey").equals("key")); assertTrue(callInfo.get("firstCall").get("cookieDomain").equals(".testdomain.com")); } @Test - public void validateQueueRequest_ValidState_NoExtendableCookie_DoNotRedirectDoNotStoreCookieWithExtension() + public void validateQueueRequest_ValidState_NoExtendableCookie_DoNotRedirect_DoNotStoreCookieWithExtension() throws Exception { QueueEventConfig config = new QueueEventConfig(); @@ -125,14 +127,14 @@ public void validateQueueRequest_ValidState_NoExtendableCookie_DoNotRedirectDoNo IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, int cookieValidityMinute, String customerSecretKey) throws Exception { + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, String redirectType, String customerSecretKey) throws Exception { + HashMap info = new HashMap<>(); conditions.replace("isStoreWasCalled", true); } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(true, "queueId", false, System.currentTimeMillis() / 1000L + 10 * 60); - + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(true, "queueId", "3", "idle"); } @Override @@ -141,7 +143,7 @@ public void cancelQueueCookie(String eventId, String cookieDomain) { } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; @@ -168,29 +170,28 @@ public void ValidateQueueRequest_NoCookie_TampredToken_RedirectToErrorPageWithHa IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, int cookieValidityMinute, String customerSecretKey) throws Exception { - conditions.replace("isStoreWasCalled", true); + public void cancelQueueCookie(String eventId, String cookieDomain) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(false, "queueId", false, System.currentTimeMillis() / 1000L + 10 * 60); - + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, String redirectType, String customerSecretKey) throws Exception { + conditions.replace("isStoreWasCalled", true); } @Override - public void cancelQueueCookie(String eventId, String cookieDomain) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(false, null, null, null); } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; String customerKey = "4e1db821-a825-49da-acd0-5d376f2068db"; - String queueitToken = QueueITTokenGenerator.generateToken(new Date(), "e1", false, 20, customerKey); + String queueitToken = QueueITTokenGenerator.generateToken(new Date(), "e1", false, 20, customerKey, "queue"); queueitToken = queueitToken.replace("false", "true"); String targetUrl = "http://test.test.com?b=h"; @@ -233,30 +234,29 @@ public void ValidateQueueRequest_NoCookie_ExpiredTimeStampInToken_RedirectToErro IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, int cookieValidityMinute, String customerSecretKey) throws Exception { - conditions.replace("isStoreWasCalled", true); + public void cancelQueueCookie(String eventId, String cookieDomain) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(false, "queueId", false, System.currentTimeMillis() / 1000L + 10 * 60); - + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, String redirectType, String customerSecretKey) throws Exception { + conditions.replace("isStoreWasCalled", true); } @Override - public void cancelQueueCookie(String eventId, String cookieDomain) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(false, null, null, null); } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; Date date = new Date(); date.setTime(date.getTime() - 1000 * 60 * 60); - String queueitToken = QueueITTokenGenerator.generateToken(date, "e1", true, 20, customerKey); + String queueitToken = QueueITTokenGenerator.generateToken(date, "e1", true, 20, customerKey, "queue"); String targetUrl = "http://test.test.com?b=h"; String knownUserVersion = UserInQueueService.SDK_VERSION; @@ -298,30 +298,29 @@ public void ValidateQueueRequest_NoCookie_EventIdMismatch_RedirectToErrorPageWit IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, int cookieValidityMinute, String customerSecretKey) throws Exception { - conditions.replace("isStoreWasCalled", true); + public void cancelQueueCookie(String eventId, String cookieDomain) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(false, "queueId", false, System.currentTimeMillis() / 1000L + 10 * 60); - + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, String redirectType, String customerSecretKey) throws Exception { + conditions.replace("isStoreWasCalled", true); } @Override - public void cancelQueueCookie(String eventId, String cookieDomain) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(false, null, null, null); } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; Date date = new Date(); date.setTime(date.getTime() + 1000 * 60 * 60); - String queueitToken = QueueITTokenGenerator.generateToken(date, "e1", true, null, customerKey); + String queueitToken = QueueITTokenGenerator.generateToken(date, "e1", true, null, customerKey, "queue"); String targetUrl = "http://test.test.com?b=h"; String knownUserVersion = UserInQueueService.SDK_VERSION; @@ -361,20 +360,20 @@ public void ValidateQueueRequest_NoCookie_ValidToken_ExtendableCookie_DoNotRedir callInfo.put("firstCall", new HashMap<>()); IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, - int cookieValidityMinute, String customerSecretKey) throws Exception { + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, + String redirectType, String customerSecretKey) throws Exception { HashMap info = new HashMap<>(); info.put("eventId", eventId); - info.put("isStateExtendable", isStateExtendable); + info.put("fixedCookieValidityMinutes", fixedCookieValidityMinutes); info.put("cookieDomain", cookieDomain); - info.put("cookieValidityMinute", cookieValidityMinute); + info.put("redirectType", redirectType); info.put("customerSecretKey", customerSecretKey); callInfo.put("firstCall", info); } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(false, "queueId", false, System.currentTimeMillis() / 1000L + 10 * 60); + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(false, null, null, null); } @Override @@ -383,14 +382,14 @@ public void cancelQueueCookie(String eventId, String cookieDomain) { } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; Date date = new Date(); date.setTime(date.getTime() + 1000 * 60 * 60); - String queueitToken = QueueITTokenGenerator.generateToken(date, "e1", true, null, customerKey); + String queueitToken = QueueITTokenGenerator.generateToken(date, "e1", true, null, customerKey, "queue"); String targetUrl = "http://test.test.com?b=h"; @@ -398,9 +397,9 @@ public void extendQueueCookie(String eventId, int cookieValidityMinute, String c RequestValidationResult result = testObject.validateQueueRequest(targetUrl, queueitToken, config, "testCustomer", customerKey); assertTrue(!result.doRedirect()); assertTrue(callInfo.get("firstCall").get("eventId").equals(config.getEventId())); - assertTrue(callInfo.get("firstCall").get("isStateExtendable").equals(true)); + assertTrue(callInfo.get("firstCall").get("fixedCookieValidityMinutes") == null); assertTrue(callInfo.get("firstCall").get("cookieDomain").equals(config.getCookieDomain())); - assertTrue(callInfo.get("firstCall").get("cookieValidityMinute").equals(config.getCookieValidityMinute())); + assertTrue(callInfo.get("firstCall").get("redirectType").equals("queue")); assertTrue(callInfo.get("firstCall").get("customerSecretKey").equals(customerKey)); } @@ -417,20 +416,20 @@ public void ValidateQueueRequest_NoCookie_ValidToken_CookieValidityMinuteFromTok callInfo.put("firstCall", new HashMap<>()); IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, - int cookieValidityMinute, String customerSecretKey) throws Exception { + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, + String redirectType, String customerSecretKey) throws Exception { HashMap info = new HashMap<>(); info.put("eventId", eventId); - info.put("isStateExtendable", isStateExtendable); + info.put("fixedCookieValidityMinutes", fixedCookieValidityMinutes); info.put("cookieDomain", cookieDomain); - info.put("cookieValidityMinute", cookieValidityMinute); + info.put("redirectType", redirectType); info.put("customerSecretKey", customerSecretKey); callInfo.put("firstCall", info); } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(false, "queueId", false, System.currentTimeMillis() / 1000L + 10 * 60); + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(false, null, null, null); } @Override @@ -439,7 +438,7 @@ public void cancelQueueCookie(String eventId, String cookieDomain) { } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; @@ -451,9 +450,9 @@ public void extendQueueCookie(String eventId, int cookieValidityMinute, String c RequestValidationResult result = testObject.validateQueueRequest(targetUrl, queueitToken, config, "testCustomer", customerKey); assertTrue(!result.doRedirect()); assertTrue(callInfo.get("firstCall").get("eventId").equals(config.getEventId())); - assertTrue(callInfo.get("firstCall").get("isStateExtendable").equals(false)); + assertTrue(callInfo.get("firstCall").get("redirectType").equals("DirectLink")); assertTrue(callInfo.get("firstCall").get("cookieDomain").equals(config.getCookieDomain())); - assertTrue(callInfo.get("firstCall").get("cookieValidityMinute").equals(3)); + assertTrue(callInfo.get("firstCall").get("fixedCookieValidityMinutes").equals(3)); assertTrue(callInfo.get("firstCall").get("customerSecretKey").equals(customerKey)); assertTrue(config.getEventId().equals(result.getEventId())); } @@ -473,23 +472,22 @@ public void ValidateQueueRequest_NoCookie_WithoutToken_RedirectToQueue() throws IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, int cookieValidityMinute, String customerSecretKey) throws Exception { - conditions.replace("isStoreWasCalled", true); + public void cancelQueueCookie(String eventId, String cookieDomain) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(false, "queueId", false, System.currentTimeMillis() / 1000L + 10 * 60); - + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, String redirectType, String customerSecretKey) throws Exception { + conditions.replace("isStoreWasCalled", true); } @Override - public void cancelQueueCookie(String eventId, String cookieDomain) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(false, null, null, null); } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; @@ -509,7 +507,7 @@ public void extendQueueCookie(String eventId, int cookieValidityMinute, String c assertTrue(!conditions.get("isStoreWasCalled")); assertTrue(config.getEventId().equals(result.getEventId())); } - + @Test public void ValidateQueueRequest_NoCookie_WithoutToken_RedirectToQueue_NoTargetUrl() throws Exception { QueueEventConfig config = new QueueEventConfig(); @@ -525,28 +523,26 @@ public void ValidateQueueRequest_NoCookie_WithoutToken_RedirectToQueue_NoTargetU IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, int cookieValidityMinute, String customerSecretKey) throws Exception { - conditions.replace("isStoreWasCalled", true); + public void cancelQueueCookie(String eventId, String cookieDomain) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(false, "queueId", false, System.currentTimeMillis() / 1000L + 10 * 60); - + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, String redirectType, String customerSecretKey) throws Exception { + conditions.replace("isStoreWasCalled", true); } @Override - public void cancelQueueCookie(String eventId, String cookieDomain) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(false, null, null, null); } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; - String knownUserVersion = UserInQueueService.SDK_VERSION; String expectedErrorUrl = "https://testDomain.com?c=testCustomer&e=e1" + "&ver=v3-java-" + knownUserVersion @@ -576,23 +572,22 @@ public void ValidateQueueRequest_NoCookie_InValidToken() throws Exception { IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, int cookieValidityMinute, String customerSecretKey) throws Exception { - conditions.replace("isStoreWasCalled", true); + public void cancelQueueCookie(String eventId, String cookieDomain) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(false, "queueId", false, System.currentTimeMillis() / 1000L + 10 * 60); - + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, String redirectType, String customerSecretKey) throws Exception { + conditions.replace("isStoreWasCalled", true); } @Override - public void cancelQueueCookie(String eventId, String cookieDomain) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + return new StateInfo(false, null, null, null); } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; @@ -612,7 +607,7 @@ public void extendQueueCookie(String eventId, int cookieValidityMinute, String c assertTrue(!conditions.get("isStoreWasCalled")); assertTrue(config.getEventId().equals(result.getEventId())); } - + @Test public void validateCancelRequest() throws Exception { CancelEventConfig config = new CancelEventConfig(); @@ -622,29 +617,34 @@ public void validateCancelRequest() throws Exception { config.setVersion(10); HashMap conditions = new HashMap<>(); - + IUserInQueueStateRepository cookieProviderMock = new IUserInQueueStateRepository() { + @Override - public void store(String eventId, String queueId, boolean isStateExtendable, String cookieDomain, int cookieValidityMinute, String customerSecretKey) throws Exception { - throw new UnsupportedOperationException("Unsupported"); + public void store(String eventId, String queueId, Integer fixedCookieValidityMinutes, String cookieDomain, String redirectType, String customerSecretKey) throws Exception { + } @Override - public StateInfo getState(String eventId, String customerSecretKey) { - return new StateInfo(true, "queueId", true, System.currentTimeMillis() / 1000L + 10 * 60); + public StateInfo getState(String eventId, int cookieValidityMinutes, String customerSecretKey, boolean validateTime) { + if (!validateTime) { + return new StateInfo(true, "queueId", null, "queue"); + } else { + return new StateInfo(false, null, null, null); + } } @Override - public void cancelQueueCookie(String eventId, String cookieDomain) { - conditions.put("cancelQueueCookieWasCalled", "eventId:" + eventId + ",cookieDomain:" + cookieDomain); + public void reissueQueueCookie(String eventId, int cookieValidityMinutes, String cookieDomain, String secretKey) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override - public void extendQueueCookie(String eventId, int cookieValidityMinute, String cookieDomain, String secretKey) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public void cancelQueueCookie(String eventId, String cookieDomain) { + conditions.put("cancelQueueCookieWasCalled", "eventId:" + eventId + ",cookieDomain:" + cookieDomain); } - }; + }; String knownUserVersion = UserInQueueService.SDK_VERSION; String expectedUrl = "https://testDomain.com/cancel/testCustomer/e1/?c=testCustomer&e=e1" + "&ver=v3-java-" + knownUserVersion @@ -660,7 +660,7 @@ public void extendQueueCookie(String eventId, int cookieValidityMinute, String c assertTrue(expectedUrl.equals(result.getRedirectUrl())); assertTrue(config.getEventId().equals(result.getEventId())); } - + @Test public void getIgnoreRequest() throws Exception { UserInQueueService testObject = new UserInQueueService(null); @@ -679,15 +679,17 @@ public static String generateToken( String eventId, boolean extendableCookie, Integer cookieValidityMinute, - String secretKey + String secretKey, + String redirectType ) throws Exception { ArrayList paramList = new ArrayList<>(); paramList.add(QueueParameterHelper.TimeStampKey + QueueParameterHelper.KeyValueSeparatorChar + GetUnixTimestamp(timeStamp)); if (cookieValidityMinute != null) { - paramList.add(QueueParameterHelper.CookieValidityMinuteKey + QueueParameterHelper.KeyValueSeparatorChar + cookieValidityMinute); + paramList.add(QueueParameterHelper.CookieValidityMinutesKey + QueueParameterHelper.KeyValueSeparatorChar + cookieValidityMinute); } paramList.add(QueueParameterHelper.EventIdKey + QueueParameterHelper.KeyValueSeparatorChar + eventId); paramList.add(QueueParameterHelper.ExtendableCookieKey + QueueParameterHelper.KeyValueSeparatorChar + extendableCookie); + paramList.add(QueueParameterHelper.RedirectTypeKey + QueueParameterHelper.KeyValueSeparatorChar + redirectType); String tokenWithoutHash = String.join(QueueParameterHelper.KeyValueSeparatorGroupChar, paramList); String hash = HashHelper.generateSHA256Hash(secretKey, tokenWithoutHash); diff --git a/SDK/test/queueit/knownuserv3/sdk/UserInQueueStateCookieRepositoryTest.java b/SDK/test/queueit/knownuserv3/sdk/UserInQueueStateCookieRepositoryTest.java index 12fc234..d1aecba 100644 --- a/SDK/test/queueit/knownuserv3/sdk/UserInQueueStateCookieRepositoryTest.java +++ b/SDK/test/queueit/knownuserv3/sdk/UserInQueueStateCookieRepositoryTest.java @@ -35,13 +35,15 @@ public String getCookie(String cookieName) { }; UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); - testObject.store(eventId, queueId, true, cookieDomain, cookieValidity, secretKey); - StateInfo state = testObject.getState(eventId, secretKey); + testObject.store(eventId, queueId, null, cookieDomain, "Queue", secretKey); + StateInfo state = testObject.getState(eventId, cookieValidity, secretKey, true); assertTrue(state.isValid()); assertTrue(state.getQueueId().equals(queueId)); assertTrue(state.isStateExtendable()); - assertTrue(Math.abs(System.currentTimeMillis() / 1000L + 10 * 60 - state.getExpires()) < 100); + assertTrue(state.getRedirectType().equals("Queue")); + Long issueTime = Long.valueOf(UserInQueueStateCookieRepository.getCookieNameValueMap(String.valueOf(cookies.get(cookieKey).get("cookieValue"))).get("IssueTime")); + assertTrue(Math.abs(System.currentTimeMillis() / 1000L - issueTime) < 2); assertTrue((int) cookies.get(cookieKey).get("expiration") == 24 * 60 * 60); assertTrue(cookies.get(cookieKey).get("cookieDomain").equals(cookieDomain)); } @@ -69,20 +71,20 @@ public String getCookie(String cookieName) { }; UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); - testObject.store(eventId, queueId, false, cookieDomain, cookieValidity, secretKey); + testObject.store(eventId, queueId, cookieValidity, cookieDomain, "Queue", secretKey); - StateInfo state = testObject.getState(eventId, secretKey); + StateInfo state = testObject.getState(eventId, 10, secretKey, true); assertTrue(state.isValid()); String cookieString = cookies.get(cookieKey); - cookieString = cookieString.replace("IsCookieExtendable=false", "IsCookieExtendable=true"); + cookieString = cookieString.replace("FixedValidityMins=10&", ""); cookies.replace(cookieKey, cookieString); - state = testObject.getState(eventId, secretKey); + state = testObject.getState(eventId, 10, secretKey, true); assertFalse(state.isValid()); } @Test - public void store_getState_ExpiredCookie_StateIsNotValid() throws Exception { + public void store_getState_ExpiredCookie_StateIsNotValid_Queue() throws Exception { String eventId = "event1"; String secretKey = "4e1db821-a825-49da-acd0-5d376f2068db"; String cookieDomain = ".test.com"; @@ -101,9 +103,35 @@ public String getCookie(String cookieName) { } }; UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); - testObject.store(eventId, queueId, false, cookieDomain, -1, secretKey); + testObject.store(eventId, queueId, null, cookieDomain, "Queue", secretKey); - StateInfo state = testObject.getState(eventId, secretKey); + StateInfo state = testObject.getState(eventId, -1, secretKey, true); + assertFalse(state.isValid()); + } + + @Test + public void store_getState_ExpiredCookie_StateIsNotValid_Idle() throws Exception { + String eventId = "event1"; + String secretKey = "4e1db821-a825-49da-acd0-5d376f2068db"; + String cookieDomain = ".test.com"; + String queueId = "528f01d4-30f9-4753-95b3-2c8c33966abc"; + HashMap cookies = new HashMap<>(); + + ICookieManager cookieManager = new ICookieManager() { + @Override + public void setCookie(String cookieName, String cookieValue, Integer expiration, String cookieDomain) { + cookies.put(cookieName, cookieValue); + } + + @Override + public String getCookie(String cookieName) { + return cookies.get(cookieName); + } + }; + UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); + testObject.store(eventId, queueId, -1, cookieDomain, "Idle", secretKey); + + StateInfo state = testObject.getState(eventId, 10, secretKey, true); assertFalse(state.isValid()); } @@ -129,11 +157,11 @@ public String getCookie(String cookieName) { } }; UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); - testObject.store(eventId, queueId, false, cookieDomain, 10, secretKey); - StateInfo state = testObject.getState(eventId, secretKey); + testObject.store(eventId, queueId, null, cookieDomain, "Queue", secretKey); + StateInfo state = testObject.getState(eventId, 10, secretKey, true); assertTrue(state.isValid()); - state = testObject.getState("event2", secretKey); + state = testObject.getState("event2", 10, secretKey, true); assertFalse(state.isValid()); } @@ -152,13 +180,13 @@ public void setCookie(String cookieName, String cookieValue, Integer expiration, @Override public String getCookie(String cookieName) { - return "IsCookieExtendable=ooOOO&Expires=|||&QueueId=000&Hash=23232$$$"; + return "FixedValidityMins=ooOOO&Expires=|||&QueueId=000&Hash=23232$$$"; } }; UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); - testObject.store(eventId, queueId, false, cookieDomain, 10, secretKey); - StateInfo state = testObject.getState(eventId, secretKey); + testObject.store(eventId, queueId, null, cookieDomain, "Queue", secretKey); + StateInfo state = testObject.getState(eventId, 10, secretKey, true); assertFalse(state.isValid()); } @@ -168,7 +196,7 @@ public void cancelQueueCookie_Test() throws Exception { String secretKey = "secretKey"; String queueId = "528f01d4-30f9-4753-95b3-2c8c33966abc"; String cookieDomain = "testDomain"; - + String cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); HashMap> cookies = new HashMap<>(); cookies.put(cookieKey + "1", new HashMap<>()); @@ -195,15 +223,14 @@ public String getCookie(String cookieName) { }; UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); - testObject.store(eventId, queueId, true, "cookieDomain", 10, secretKey); - assertTrue(testObject.getState(eventId, secretKey).isValid()); + testObject.store(eventId, queueId, -1, "cookieDomain", "Idle", secretKey); + assertTrue(testObject.getState(eventId, 10, secretKey, false).isValid()); testObject.cancelQueueCookie(eventId, cookieDomain); assertTrue((int) cookies.get(cookieKey + "2").get("expiration") == 0); assertTrue(cookies.get(cookieKey + "2").get("cookieValue") == null); assertTrue(cookies.get(cookieKey + "2").get("cookieDomain").equals(cookieDomain)); - assertFalse(testObject.getState(eventId, secretKey).isValid()); } @Test @@ -213,44 +240,49 @@ public void extendQueueCookie_CookietExist_Test() throws Exception { String secretKey = "secretKey"; String queueId = "528f01d4-30f9-4753-95b3-2c8c33966abc"; String cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); - HashMap> cookies = new HashMap<>(); - cookies.put(cookieKey + "1", new HashMap<>()); - cookies.put(cookieKey + "2", new HashMap<>()); + HashMap cookie = new HashMap<>(); + Long issueTime = (System.currentTimeMillis() / 1000L - 120); + String hash = HashHelper.generateSHA256Hash(secretKey, eventId + queueId + "3" + "idle" + String.valueOf(issueTime)); + String cookieValue = "EventId=" + eventId + "&QueueId=" + queueId + "&FixedValidityMins=3&RedirectType=idle&IssueTime=" + String.valueOf(issueTime) + "&Hash=" + hash; ICookieManager cookieManager = new ICookieManager() { public int setCookieCallNumber = 0; + boolean isSetCookieCalled = false; @Override public void setCookie(String cookieName, String cookieValue, Integer expiration, String cookieDomain) { - setCookieCallNumber++; - HashMap cookie = cookies.get(cookieName + String.valueOf(setCookieCallNumber)); cookie.put("cookieValue", cookieValue); cookie.put("cookieValue", cookieValue); cookie.put("expiration", expiration); cookie.put("cookieDomain", cookieDomain); + isSetCookieCalled = true; } @Override public String getCookie(String cookieName) { - return String.valueOf(cookies.get(cookieName + String.valueOf(setCookieCallNumber)).get("cookieValue")); + if (!isSetCookieCalled) { + return cookieValue; + } + return String.valueOf(cookie.get("cookieValue")); } }; UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); - testObject.store(eventId, queueId, true, "cookieDomain", 10, secretKey); - assertTrue(testObject.getState(eventId, secretKey).isValid()); + assertTrue(testObject.getState(eventId, 10, secretKey, true).isValid()); - testObject.extendQueueCookie(eventId, 12, "cookieDomain", secretKey); + testObject.reissueQueueCookie(eventId, 12, "cookieDomain", secretKey); - StateInfo state = testObject.getState(eventId, secretKey); + StateInfo state = testObject.getState(eventId, 10, secretKey, true); assertTrue(state.isValid()); assertTrue(state.getQueueId().equals(queueId)); - assertTrue(state.isStateExtendable()); - assertTrue(Math.abs(System.currentTimeMillis() / 1000L + 12 * 60 - state.getExpires()) < 100); - assertTrue((int) cookies.get(cookieKey + "2").get("expiration") == 24 * 60 * 60); - assertTrue(cookies.get(cookieKey + "2").get("cookieDomain").equals("cookieDomain")); + assertTrue(!state.isStateExtendable()); + assertTrue(state.getRedirectType().equals("idle")); + Long newIssueTime = Long.valueOf(UserInQueueStateCookieRepository.getCookieNameValueMap(String.valueOf(cookie.get("cookieValue"))).get("IssueTime")); + assertTrue(Math.abs(System.currentTimeMillis() / 1000L - newIssueTime) < 2); + assertTrue((int) cookie.get("expiration") == 24 * 60 * 60); + assertTrue(cookie.get("cookieDomain").equals("cookieDomain")); } @Test @@ -273,7 +305,129 @@ public String getCookie(String cookieName) { } }; UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); - testObject.extendQueueCookie(eventId, 12, "queueDomain", secretKey); + testObject.reissueQueueCookie(eventId, 12, "queueDomain", secretKey); assertFalse(conditions.get("isSetCookieCalled")); } + + @Test + public void getState_ValidCookieFormat_Extendable_Test() throws Exception { + + String eventId = "event1"; + String secretKey = "secretKey"; + String queueId = "f8757c2d-34c2-4639-bef2-1736cdd30bbb"; + String cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); + Long issueTime = (System.currentTimeMillis() / 1000L - 120); + String hash = HashHelper.generateSHA256Hash(secretKey, eventId + queueId + "queue" + String.valueOf(issueTime)); + String cookieValue = "EventId=" + eventId + "&QueueId=" + queueId + "&RedirectType=queue&IssueTime=" + String.valueOf(issueTime) + "&Hash=" + hash; + ICookieManager cookieManager = new ICookieManager() { + @Override + public void setCookie(String cookieName, String cookieValue, Integer expiration, String cookieDomain) { + + } + + @Override + public String getCookie(String cookieName) { + if (cookieName.endsWith(cookieKey)) { + return cookieValue; + } + return null; + } + }; + UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); + StateInfo cookieState = testObject.getState(eventId, 10, secretKey, true); + assertTrue(cookieState.isValid()); + assertTrue(cookieState.getQueueId().equals(queueId)); + assertTrue(cookieState.getRedirectType().equals("queue")); + assertTrue(cookieState.isStateExtendable()); + } + + @Test + public void getState_ValidCookieFormat_NonExtendable_Test() throws Exception { + + String eventId = "event1"; + String secretKey = "secretKey"; + String queueId = "f8757c2d-34c2-4639-bef2-1736cdd30bbb"; + String cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); + Long issueTime = (System.currentTimeMillis() / 1000L - 120); + String hash = HashHelper.generateSHA256Hash(secretKey, eventId + queueId + "3" + "idle" + String.valueOf(issueTime)); + String cookieValue = "EventId=" + eventId + "&QueueId=" + queueId + "&FixedValidityMins=3&RedirectType=idle&IssueTime=" + String.valueOf(issueTime) + "&Hash=" + hash; + ICookieManager cookieManager = new ICookieManager() { + @Override + public void setCookie(String cookieName, String cookieValue, Integer expiration, String cookieDomain) { + + } + + @Override + public String getCookie(String cookieName) { + if (cookieName.equals(cookieKey)) { + return cookieValue; + } + return null; + } + }; + UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); + StateInfo cookieState = testObject.getState(eventId, 10, secretKey, true); + assertTrue(cookieState.isValid()); + assertTrue(cookieState.getQueueId().equals(queueId)); + assertTrue(cookieState.getRedirectType().equals("idle")); + assertTrue(!cookieState.isStateExtendable()); + } + + @Test + public void getState_OldCookie_InValid_ExpiredCookie_Extendable_Test() throws Exception { + + String eventId = "event1"; + String secretKey = "secretKey"; + String queueId = "f8757c2d-34c2-4639-bef2-1736cdd30bbb"; + String cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); + Long issueTime = (System.currentTimeMillis() / 1000L - (11 * 60)); + String hash = HashHelper.generateSHA256Hash(secretKey, eventId + queueId + "queue" + String.valueOf(issueTime)); + String cookieValue = "EventId=" + eventId + "&QueueId=" + queueId + "&RedirectType=queue&IssueTime=" + String.valueOf(issueTime) + "&Hash=" + hash; + ICookieManager cookieManager = new ICookieManager() { + @Override + public void setCookie(String cookieName, String cookieValue, Integer expiration, String cookieDomain) { + + } + + @Override + public String getCookie(String cookieName) { + if (cookieName.endsWith(cookieKey)) { + return cookieValue; + } + return null; + } + }; + UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); + StateInfo cookieState = testObject.getState(eventId, 10, secretKey, true); + assertFalse(cookieState.isValid()); + } + + @Test + public void getState_OldCookie_InValid_ExpiredCookie_NonExtendable_Test() throws Exception { + String eventId = "event1"; + String secretKey = "secretKey"; + String queueId = "f8757c2d-34c2-4639-bef2-1736cdd30bbb"; + String cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); + Long issueTime = (System.currentTimeMillis() / 1000L - (4 * 60)); + String hash = HashHelper.generateSHA256Hash(secretKey, eventId + queueId + "3" + "idle" + String.valueOf(issueTime)); + String cookieValue = "EventId=" + eventId + "&QueueId=" + queueId + "&FixedValidityMins=3&RedirectType=idle&IssueTime=" + String.valueOf(issueTime) + "&Hash=" + hash; + ICookieManager cookieManager = new ICookieManager() { + @Override + public void setCookie(String cookieName, String cookieValue, Integer expiration, String cookieDomain) { + + } + + @Override + public String getCookie(String cookieName) { + if (cookieName.endsWith(cookieKey)) { + return cookieValue; + } + return null; + } + }; + UserInQueueStateCookieRepository testObject = new UserInQueueStateCookieRepository(cookieManager); + StateInfo cookieState = testObject.getState(eventId, 3, secretKey, true); + assertFalse(cookieState.isValid()); + + } }