Skip to content

Commit

Permalink
— Addition: add flag prefix in GeoLocation/UserRequestMetadata → "whe…
Browse files Browse the repository at this point in the history
…re": truncate "tech1_users_sessions" database
  • Loading branch information
yyluchkiv committed Jun 15, 2024
1 parent ff6a24e commit 5f1c766
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
### Changelog [v2.8.7]
— Modification: Change security matchers (/user/update1, /user/update2, /user/changePassword1) on denyAll() -> authenticated
— Addition: /test-data/sessions endpoint
— Addition: add flag prefix in GeoLocation/UserRequestMetadata → "where": truncate "tech1_users_sessions" database
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Map<String, Object> getAuthenticationLoginOrSessionRefreshedVariables(
variables.put("year", now(UTC).getYear());
variables.put("username", username.value());
variables.put("accessMethod", accountAccessMethod.getValue());
variables.put("where", geoLocation.getCountryFlag() + " " + geoLocation.getWhere());
variables.put("where", geoLocation.getWhere());
variables.put("what", userAgentDetails.getWhat());
variables.put("ipAddress", geoLocation.getIpAddr());
variables.put("webclientURL", this.applicationFrameworkProperties.getServerConfigs().getWebclientURL());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ void constructorTest() {
// Assert
assertThat(actual.sessions()).hasSize(3);
assertThat(actual.sessions().get(0).current()).isTrue();
assertThat(actual.sessions().get(0).where()).isEqualTo("USA, New York");
assertThat(actual.sessions().get(0).where()).isEqualTo("🇺🇸 USA, New York");
assertThat(actual.sessions().get(1).current()).isFalse();
assertThat(actual.sessions().get(1).where()).isEqualTo("UK, Liverpool");
assertThat(actual.sessions().get(1).where()).isEqualTo("🇬🇧 UK, Liverpool");
assertThat(actual.sessions().get(2).current()).isFalse();
assertThat(actual.sessions().get(2).where()).isEqualTo("UK, London");
assertThat(actual.sessions().get(2).where()).isEqualTo("🇬🇧 UK, London");
assertThat(actual.anyPresent()).isTrue();
assertThat(actual.anyProblem()).isTrue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@ public static GeoLocation testData() {
public String getWhere() {
var countryPresent = hasLength(this.country);
var cityPresent = hasLength(this.city);
var countryFlagPrefix = hasLength(this.countryFlag) ? this.countryFlag + " " : StringConstants.EMPTY;
if (countryPresent && !cityPresent) {
return this.country;
return countryFlagPrefix + this.country;
}
if (countryPresent) {
return this.country + ", " + this.city;
return countryFlagPrefix + this.country + ", " + this.city;
}
return StringConstants.UNKNOWN;
return TestsFlagsConstants.UNKNOWN + " " + StringConstants.UNKNOWN;
}

// =================================================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ private static Stream<Arguments> serializeTest() {

private static Stream<Arguments> getWhereTest() {
return Stream.of(
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", "Lviv"), "Ukraine, Lviv"),
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", ""), "Ukraine"),
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", " "), "Ukraine"),
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", " "), "Ukraine"),
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", null), "Ukraine"),
Arguments.of(processed(localhost(), null, "UA", "🇺🇦", "Lviv"), "Unknown"),
Arguments.of(processed(localhost(), "", "UA", "🇺🇦", "Lviv"), "Unknown"),
Arguments.of(processed(localhost(), "", "UA", "🇺🇦", "Lviv"), "Unknown"),
Arguments.of(processed(localhost(), " ", "UA", "🇺🇦", "Lviv"), "Unknown"),
Arguments.of(processed(localhost(), " ", "UA", "🇺🇦", "Lviv"), "Unknown")
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", "Lviv"), "🇺🇦 Ukraine, Lviv"),
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", ""), "🇺🇦 Ukraine"),
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", " "), "🇺🇦 Ukraine"),
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", " "), "🇺🇦 Ukraine"),
Arguments.of(processed(localhost(), "Ukraine", "UA", "🇺🇦", null), "🇺🇦 Ukraine"),
Arguments.of(processed(localhost(), null, "UA", "🇺🇦", "Lviv"), "🇺🇦 Unknown"),
Arguments.of(processed(localhost(), "", "UA", "🇺🇦", "Lviv"), "🏴‍ Unknown"),
Arguments.of(processed(localhost(), "", "UA", "🇺🇦", "Lviv"), "🏴‍ Unknown"),
Arguments.of(processed(localhost(), " ", "UA", "🇺🇦", "Lviv"), "🏴‍ Unknown"),
Arguments.of(processed(localhost(), " ", "UA", "🇺🇦", "Lviv"), "🏴‍ Unknown")
);
}

Expand Down Expand Up @@ -80,7 +80,7 @@ void validTest() {
assertThat(actual.getCountryFlag()).isEqualTo("🇺🇦");
assertThat(actual.getCity()).isEqualTo("Lviv");
assertThat(actual.getExceptionDetails()).isEmpty();
assertThat(actual.getWhere()).isEqualTo("Ukraine, Lviv");
assertThat(actual.getWhere()).isEqualTo("🇺🇦 Ukraine, Lviv");
}

@RepeatedTest(SMALL_ITERATIONS_COUNT)
Expand All @@ -94,7 +94,7 @@ void invalidTest() {
assertThat(actual.getCountry()).isEqualTo(UNKNOWN);
assertThat(actual.getCity()).isEqualTo(UNKNOWN);
assertThat(actual.getExceptionDetails()).isEqualTo("Location is unknown");
assertThat(actual.getWhere()).isEqualTo("Unknown, Unknown");
assertThat(actual.getWhere()).isEqualTo("🏴‍ Unknown, Unknown");
}

@RepeatedTest(SMALL_ITERATIONS_COUNT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void validTest() {
assertThat(actual.getGeoLocation().getCountry()).isEqualTo("Ukraine");
assertThat(actual.getGeoLocation().getCity()).isEqualTo("Lviv");
assertThat(actual.getGeoLocation().getExceptionDetails()).isEmpty();
assertThat(actual.getGeoLocation().getWhere()).isEqualTo("Ukraine, Lviv");
assertThat(actual.getGeoLocation().getWhere()).isEqualTo("🇺🇦 Ukraine, Lviv");
assertThat(actual.getUserAgentDetails().getBrowser()).isEqualTo("Chrome");
assertThat(actual.getUserAgentDetails().getPlatform()).isEqualTo("macOS");
assertThat(actual.getUserAgentDetails().getDeviceType()).isEqualTo("Desktop");
Expand All @@ -79,7 +79,7 @@ void validTest() {
assertThat(actual.getWhereTuple3().a()).isNotNull();
assertThat(actual.getWhereTuple3().a().split("\\.")).hasSize(4);
assertThat(actual.getWhereTuple3().b()).isEqualTo("🇺🇦");
assertThat(actual.getWhereTuple3().c()).isEqualTo("Ukraine, Lviv");
assertThat(actual.getWhereTuple3().c()).isEqualTo("🇺🇦 Ukraine, Lviv");
}

@RepeatedTest(SMALL_ITERATIONS_COUNT)
Expand All @@ -94,7 +94,7 @@ void invalidTest() {
assertThat(actual.getGeoLocation().getCountry()).isEqualTo("Unknown");
assertThat(actual.getGeoLocation().getCity()).isEqualTo("Unknown");
assertThat(actual.getGeoLocation().getExceptionDetails()).isEqualTo("Location is unknown");
assertThat(actual.getGeoLocation().getWhere()).isEqualTo("Unknown, Unknown");
assertThat(actual.getGeoLocation().getWhere()).isEqualTo("🏴‍ Unknown, Unknown");
assertThat(actual.getUserAgentDetails().getBrowser()).isEqualTo("Unknown");
assertThat(actual.getUserAgentDetails().getPlatform()).isEqualTo("Unknown");
assertThat(actual.getUserAgentDetails().getDeviceType()).isEqualTo("Unknown");
Expand All @@ -105,7 +105,7 @@ void invalidTest() {
assertThat(actual.getWhereTuple3().a()).isNotNull();
assertThat(actual.getWhereTuple3().a().split("\\.")).hasSize(4);
assertThat(actual.getWhereTuple3().b()).isEqualTo("🏴‍");
assertThat(actual.getWhereTuple3().c()).isEqualTo("Unknown, Unknown");
assertThat(actual.getWhereTuple3().c()).isEqualTo("🏴‍ Unknown, Unknown");
}

@RepeatedTest(SMALL_ITERATIONS_COUNT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"country" : "Ukraine",
"countryCode" : "UA",
"countryFlag" : "🇺🇦",
"where" : "Ukraine, Lviv"
"where" : "🇺🇦 Ukraine, Lviv"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"country" : "Unknown",
"countryCode" : "Unknown",
"countryFlag" : "🏴‍",
"where" : "Unknown, Unknown"
"where" : "🏴‍ Unknown, Unknown"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"country" : "[?]",
"countryCode" : "[?]",
"countryFlag" : "🏴‍",
"where" : "[?], [?]"
"where" : "🏴‍ [?], [?]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"country" : "Unknown",
"countryCode" : "Unknown",
"countryFlag" : "🏴‍",
"where" : "Unknown"
"where" : "🏴‍ Unknown"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"country" : "Unknown",
"countryCode" : "Unknown",
"countryFlag" : "🏴‍",
"where" : "Unknown, Unknown"
"where" : "🏴‍ Unknown, Unknown"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"country" : "[?]",
"countryCode" : "[?]",
"countryFlag" : "🏴‍",
"where" : "[?], [?]"
"where" : "🏴‍ [?], [?]"
},
"userAgentDetails" : {
"browser" : "[?]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"country" : "Ukraine",
"countryCode" : "UA",
"countryFlag" : "🇺🇦",
"where" : "Ukraine, Lviv"
"where" : "🇺🇦 Ukraine, Lviv"
},
"userAgentDetails" : {
"browser" : "Chrome",
Expand All @@ -17,7 +17,7 @@
"whereTuple3" : {
"a" : "127.0.0.1",
"b" : "🇺🇦",
"c" : "Ukraine, Lviv"
"c" : "🇺🇦 Ukraine, Lviv"
},
"whatTuple2" : {
"a" : "Chrome",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"country" : "Unknown",
"countryCode" : "Unknown",
"countryFlag" : "🏴‍",
"where" : "Unknown, Unknown"
"where" : "🏴‍ Unknown, Unknown"
},
"userAgentDetails" : {
"browser" : "Unknown",
Expand All @@ -17,7 +17,7 @@
"whereTuple3" : {
"a" : "127.0.0.1",
"b" : "🏴‍",
"c" : "Unknown, Unknown"
"c" : "🏴‍ Unknown, Unknown"
},
"whatTuple2" : {
"a" : "Unknown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"country" : "Ukraine",
"countryCode" : "UA",
"countryFlag" : "🇺🇦",
"where" : "Ukraine, Lviv"
"where" : "🇺🇦 Ukraine, Lviv"
},
"userAgentDetails" : {
"browser" : "Unknown",
Expand All @@ -17,7 +17,7 @@
"whereTuple3" : {
"a" : "127.0.0.1",
"b" : "🇺🇦",
"c" : "Ukraine, Lviv"
"c" : "🇺🇦 Ukraine, Lviv"
},
"whatTuple2" : {
"a" : "Unknown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"country" : "Unknown",
"countryCode" : "Unknown",
"countryFlag" : "🏴‍",
"where" : "Unknown, Unknown"
"where" : "🏴‍ Unknown, Unknown"
},
"userAgentDetails" : {
"browser" : "Chrome",
Expand All @@ -17,7 +17,7 @@
"whereTuple3" : {
"a" : "127.0.0.1",
"b" : "🏴‍",
"c" : "Unknown, Unknown"
"c" : "🏴‍ Unknown, Unknown"
},
"whatTuple2" : {
"a" : "Chrome",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ void convertAuthenticationLoginFailureUsernameMaskedPasswordIncidentTest() {
.containsEntry("countryFlag", UKRAINE)
.containsEntry("ipAddress", "127.0.0.1")
.containsEntry("what", "Chrome, macOS on Desktop")
.containsEntry("where", "Ukraine, Lviv");
.containsEntry("where", "🇺🇦 Ukraine, Lviv");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ void convertAuthenticationLoginFailureUsernamePasswordIncidentTest() {
.containsEntry("countryFlag", UKRAINE)
.containsEntry("ipAddress", "127.0.0.1")
.containsEntry("what", "Chrome, macOS on Desktop")
.containsEntry("where", "Ukraine, Lviv");
.containsEntry("where", "🇺🇦 Ukraine, Lviv");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ void convertAuthenticationLoginIncidentExceptionTest() {
.containsEntry("incidentType", "Authentication Login")
.containsEntry("username", username)
.containsEntry("browser", "[?]")
.containsEntry("countryFlag", UNKNOWN)
.containsEntry("countryFlag", "🏴‍")
.containsEntry("ipAddress", "8.8.8.8")
.containsEntry("what", "[?], [?] on [?]")
.containsEntry("where", "Unknown, Unknown")
.containsEntry("where", "🏴‍ Unknown, Unknown")
.containsEntry("exception", "exception1");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ void convertAuthenticationLogoutFullIncidentTest() {
.containsEntry("countryFlag", UK)
.containsEntry("ipAddress", "2.2.2.2")
.containsEntry("what", "Mozilla, MacOS on Desktop")
.containsEntry("where", "UK, London");
.containsEntry("where", "🇬🇧 UK, London");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ void convertSessionExpiredIncidentTest() {
.containsEntry("countryFlag", UK)
.containsEntry("ipAddress", "2.2.2.2")
.containsEntry("what", "Mozilla, MacOS on Desktop")
.containsEntry("where", "UK, London");
.containsEntry("where", "🇬🇧 UK, London");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ void convertSessionRefreshedIncidentTest() {
.containsEntry("countryFlag", UK)
.containsEntry("ipAddress", "2.2.2.2")
.containsEntry("what", "Mozilla, MacOS on Desktop")
.containsEntry("where", "UK, London");
.containsEntry("where", "🇬🇧 UK, London");
}
}

0 comments on commit 5f1c766

Please sign in to comment.