Skip to content

Commit

Permalink
BXC-4497 - Temporarily disabling setting of a random user id (#1695)
Browse files Browse the repository at this point in the history
* Temporarily disabling setting of a random user id

* Add comment
  • Loading branch information
bbpennel authored Mar 8, 2024
1 parent 375e909 commit 71f5865
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ public AnalyticsUserData(HttpServletRequest request) {

// if it cannot be found in the cookie, generate a random 16 character hex user ID
if (StringUtils.isBlank(uid)) {
uid = generateUserId();
// Commented out temporarily while we debug a resource exhaustion issue
// uid = generateUserId();
}

userAgent = request.getHeader("User-Agent");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,20 @@ public void testAnalyticsUserDataRemoteAddr() throws Exception {
assertEquals("1.1.1.1", userData.uip);
}

@Test
public void testAnalyticsUserDataInvalidUidCookie() {
when(request.getHeader("Proxy-Client-IP")).thenReturn("0.0.0.0");
var uidCookie = mock(Cookie.class);
when(uidCookie.getName()).thenReturn("_pk_id");
when(uidCookie.getValue()).thenReturn("");
when(request.getCookies()).thenReturn(new Cookie[]{ uidCookie });
when(request.getHeader("User-Agent")).thenReturn("boxy-client");
when(request.getRequestURL()).thenReturn(urlBuffer);

var userData = new AnalyticsTrackerUtil.AnalyticsUserData(request);
assertNotNull(userData.uid);
assertFalse(userData.uid.isEmpty());
}
// @Test
// public void testAnalyticsUserDataInvalidUidCookie() {
// when(request.getHeader("Proxy-Client-IP")).thenReturn("0.0.0.0");
// var uidCookie = mock(Cookie.class);
// when(uidCookie.getName()).thenReturn("_pk_id");
// when(uidCookie.getValue()).thenReturn("");
// when(request.getCookies()).thenReturn(new Cookie[]{ uidCookie });
// when(request.getHeader("User-Agent")).thenReturn("boxy-client");
// when(request.getRequestURL()).thenReturn(urlBuffer);
//
// var userData = new AnalyticsTrackerUtil.AnalyticsUserData(request);
// assertNotNull(userData.uid);
// assertFalse(userData.uid.isEmpty());
// }

private void assertMatomoQueryIsCorrect(Map<String, StringValuePattern> params) {
for (int i=0 ; i<100 ; i++) {
Expand Down

0 comments on commit 71f5865

Please sign in to comment.