From 7b77637b191e491e93300f97e957608531cd1b7e Mon Sep 17 00:00:00 2001 From: tanya732 Date: Fri, 14 Mar 2025 01:19:24 +0530 Subject: [PATCH 1/4] Added support for checkpoint pagination in get connection endpoint --- .../client/mgmt/filter/ConnectionFilter.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/com/auth0/client/mgmt/filter/ConnectionFilter.java b/src/main/java/com/auth0/client/mgmt/filter/ConnectionFilter.java index 375fe13d7..d1a160f8f 100644 --- a/src/main/java/com/auth0/client/mgmt/filter/ConnectionFilter.java +++ b/src/main/java/com/auth0/client/mgmt/filter/ConnectionFilter.java @@ -61,4 +61,27 @@ public ConnectionFilter withFields(String fields, boolean includeFields) { super.withFields(fields, includeFields); return this; } + + /** + * Include the {@code from} parameter to specify where to start the page selection. Only applicable for endpoints that + * support checkpoint pagination. + * @param from the ID from which to start selection. This can be obtained from the {@code next} field returned from + * a checkpoint-paginated result. + * @return this filter instance. + */ + public ConnectionFilter withFrom(String from) { + parameters.put("from", from); + return this; + } + + /** + * Include the {@code take} parameter to specify the amount of results to return per page. Only applicable for endpoints that + * support checkpoint pagination. + * @param take the amount of entries to retrieve per page. + * @return this filter instance. + */ + public ConnectionFilter withTake(int take) { + parameters.put("take", take); + return this; + } } From b95dbc2e6ac5f14615340768cae1d9deec6e87d3 Mon Sep 17 00:00:00 2001 From: tanya732 Date: Fri, 14 Mar 2025 11:21:07 +0530 Subject: [PATCH 2/4] Added test cases --- .../client/mgmt/ConnectionsEntityTest.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/test/java/com/auth0/client/mgmt/ConnectionsEntityTest.java b/src/test/java/com/auth0/client/mgmt/ConnectionsEntityTest.java index 211d13cb3..4e1149334 100644 --- a/src/test/java/com/auth0/client/mgmt/ConnectionsEntityTest.java +++ b/src/test/java/com/auth0/client/mgmt/ConnectionsEntityTest.java @@ -79,6 +79,52 @@ public void shouldListConnectionsWithTotals() throws Exception { assertThat(response.getLimit(), is(50)); } + @Test + public void shouldListConnectionsWithFrom() throws Exception { + ConnectionFilter filter = new ConnectionFilter().withFrom("10"); + Request request = api.connections().listAll(filter); + assertThat(request, is(notNullValue())); + + server.jsonResponse(MGMT_CONNECTIONS_PAGED_LIST, 200); + ConnectionsPage response = request.execute().getBody(); + RecordedRequest recordedRequest = server.takeRequest(); + + assertThat(recordedRequest, hasMethodAndPath(HttpMethod.GET, "/api/v2/connections")); + assertThat(recordedRequest, hasHeader("Content-Type", "application/json")); + assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken")); + assertThat(recordedRequest, hasQueryParameter("from", "10")); + + assertThat(response, is(notNullValue())); + assertThat(response.getItems(), hasSize(2)); + assertThat(response.getStart(), is(0)); + assertThat(response.getLength(), is(14)); + assertThat(response.getTotal(), is(14)); + assertThat(response.getLimit(), is(50)); + } + + @Test + public void shouldListConnectionsWithTake() throws Exception { + ConnectionFilter filter = new ConnectionFilter().withTake(1); + Request request = api.connections().listAll(filter); + assertThat(request, is(notNullValue())); + + server.jsonResponse(MGMT_CONNECTIONS_PAGED_LIST, 200); + ConnectionsPage response = request.execute().getBody(); + RecordedRequest recordedRequest = server.takeRequest(); + + assertThat(recordedRequest, hasMethodAndPath(HttpMethod.GET, "/api/v2/connections")); + assertThat(recordedRequest, hasHeader("Content-Type", "application/json")); + assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken")); + assertThat(recordedRequest, hasQueryParameter("take", "1")); + + assertThat(response, is(notNullValue())); + assertThat(response.getItems(), hasSize(2)); + assertThat(response.getStart(), is(0)); + assertThat(response.getLength(), is(14)); + assertThat(response.getTotal(), is(14)); + assertThat(response.getLimit(), is(50)); + } + @Test public void shouldThrowOnGetConnectionWithNullId() { verifyThrows(IllegalArgumentException.class, From f821af0ad1c7ee29dd08123e76d9ba4e909f4198 Mon Sep 17 00:00:00 2001 From: tanya732 Date: Sat, 15 Mar 2025 00:34:25 +0530 Subject: [PATCH 3/4] Fixed synk workflow by upgrading okhttpVersion --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 27d72ca38..3b4167af4 100644 --- a/build.gradle +++ b/build.gradle @@ -114,7 +114,7 @@ test { } ext { - okhttpVersion = '4.11.0' + okhttpVersion = '4.12.0' hamcrestVersion = '2.2' jupiterVersion = '5.9.3' From 9f4f6e551fbbb641ff998f036b1b21e753e8f7a0 Mon Sep 17 00:00:00 2001 From: tanya732 Date: Sat, 15 Mar 2025 02:02:32 +0530 Subject: [PATCH 4/4] updated org.jetbrains.kotlin version --- build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.gradle b/build.gradle index 3b4167af4..1942dedde 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,7 @@ buildscript { dependencies { // https://github.com/melix/japicmp-gradle-plugin/issues/36 classpath 'com.google.guava:guava:31.1-jre' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0" } } @@ -126,9 +127,14 @@ dependencies { // TODO remove direct dependency when OkHttp 4.12.0 is released implementation ("com.squareup.okhttp3:okhttp:${okhttpVersion}") { exclude group: 'com.squareup.okhttp3', module: 'okio' + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib' + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' } implementation "com.squareup.okio:okio:3.5.0" + implementation "org.jetbrains.kotlin:kotlin-stdlib:2.1.0" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.0" + implementation "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}" implementation "com.fasterxml.jackson.core:jackson-databind:2.15.0" implementation "com.auth0:java-jwt:4.4.0"