|
| 1 | +package com.uid2.operator.util; |
| 2 | + |
| 3 | +import com.uid2.operator.vertx.Endpoints; |
| 4 | +import org.junit.jupiter.params.ParameterizedTest; |
| 5 | +import org.junit.jupiter.params.provider.CsvSource; |
| 6 | +import org.junit.jupiter.params.provider.ValueSource; |
| 7 | + |
| 8 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 9 | + |
| 10 | +public class HTTPPathMetricFilterOptimizedTest { |
| 11 | + @ParameterizedTest |
| 12 | + @ValueSource(strings = { |
| 13 | + "", |
| 14 | + "/", |
| 15 | + "/unknown-path", |
| 16 | + "../", |
| 17 | + "/v1/identity/map%55", |
| 18 | + "/list/123", |
| 19 | + }) |
| 20 | + void testPathFiltering_InvalidPaths_Unknown(String actualPath) { |
| 21 | + String filteredPath = HTTPPathMetricFilterOptimized.filterPath(actualPath, Endpoints.pathSet()); |
| 22 | + assertEquals("/unknown", filteredPath); |
| 23 | + } |
| 24 | + |
| 25 | + @ParameterizedTest |
| 26 | + @ValueSource(strings = { |
| 27 | + "v1/identity/map?id=bad-escape-code%2", |
| 28 | + "token/refresh?refresh_token=SOME_TOKEN<%=7485*4353%>", |
| 29 | + "list/12%4/5435" |
| 30 | + }) |
| 31 | + void testPathFiltering_InvalidPaths_ParsingError(String actualPath) { |
| 32 | + String filteredPath = HTTPPathMetricFilterOptimized.filterPath(actualPath, Endpoints.pathSet()); |
| 33 | + assertEquals("/parsing_error", filteredPath); |
| 34 | + } |
| 35 | + |
| 36 | + @ParameterizedTest |
| 37 | + @CsvSource(value = { |
| 38 | + "/v2/identity/map, /v2/identity/map", |
| 39 | + "v2/identity/map, /v2/identity/map", |
| 40 | + "V3/IdenTity/mAp, /v3/identity/map", |
| 41 | + "v2/token/refresh?refresh_token=123%20%23, /v2/token/refresh", |
| 42 | + "v2/identity/map?identity/../map/, /v2/identity/map" |
| 43 | + }) |
| 44 | + void testPathFiltering_ValidPaths_KnownEndpoints(String actualPath, String expectedFilteredPath) { |
| 45 | + String filteredPath = HTTPPathMetricFilterOptimized.filterPath(actualPath, Endpoints.pathSet()); |
| 46 | + assertEquals(expectedFilteredPath, filteredPath); |
| 47 | + } |
| 48 | +} |
0 commit comments