Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BXC-4497 - Temporarily disabling setting of a random user id #1695

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a temporary comment as to why it's commented out?

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
Loading