Skip to content

Commit 492625c

Browse files
authored
Merge branch 'master' into sdk-5652-support-for-SSO-FF-for-auth0-java
2 parents 3aaaa71 + a7b0ff4 commit 492625c

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ buildscript {
66
dependencies {
77
// https://github.com/melix/japicmp-gradle-plugin/issues/36
88
classpath 'com.google.guava:guava:31.1-jre'
9+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0"
910
}
1011
}
1112

@@ -114,7 +115,7 @@ test {
114115
}
115116

116117
ext {
117-
okhttpVersion = '4.11.0'
118+
okhttpVersion = '4.12.0'
118119
hamcrestVersion = '2.2'
119120
jupiterVersion = '5.9.3'
120121

@@ -126,9 +127,14 @@ dependencies {
126127
// TODO remove direct dependency when OkHttp 4.12.0 is released
127128
implementation ("com.squareup.okhttp3:okhttp:${okhttpVersion}") {
128129
exclude group: 'com.squareup.okhttp3', module: 'okio'
130+
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
131+
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
129132
}
130133
implementation "com.squareup.okio:okio:3.5.0"
131134

135+
implementation "org.jetbrains.kotlin:kotlin-stdlib:2.1.0"
136+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.0"
137+
132138
implementation "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}"
133139
implementation "com.fasterxml.jackson.core:jackson-databind:2.15.0"
134140
implementation "com.auth0:java-jwt:4.4.0"

src/main/java/com/auth0/client/mgmt/filter/ConnectionFilter.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,27 @@ public ConnectionFilter withFields(String fields, boolean includeFields) {
6161
super.withFields(fields, includeFields);
6262
return this;
6363
}
64+
65+
/**
66+
* Include the {@code from} parameter to specify where to start the page selection. Only applicable for endpoints that
67+
* support checkpoint pagination.
68+
* @param from the ID from which to start selection. This can be obtained from the {@code next} field returned from
69+
* a checkpoint-paginated result.
70+
* @return this filter instance.
71+
*/
72+
public ConnectionFilter withFrom(String from) {
73+
parameters.put("from", from);
74+
return this;
75+
}
76+
77+
/**
78+
* Include the {@code take} parameter to specify the amount of results to return per page. Only applicable for endpoints that
79+
* support checkpoint pagination.
80+
* @param take the amount of entries to retrieve per page.
81+
* @return this filter instance.
82+
*/
83+
public ConnectionFilter withTake(int take) {
84+
parameters.put("take", take);
85+
return this;
86+
}
6487
}

src/test/java/com/auth0/client/mgmt/ConnectionsEntityTest.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,52 @@ public void shouldListConnectionsWithTotals() throws Exception {
7979
assertThat(response.getLimit(), is(50));
8080
}
8181

82+
@Test
83+
public void shouldListConnectionsWithFrom() throws Exception {
84+
ConnectionFilter filter = new ConnectionFilter().withFrom("10");
85+
Request<ConnectionsPage> request = api.connections().listAll(filter);
86+
assertThat(request, is(notNullValue()));
87+
88+
server.jsonResponse(MGMT_CONNECTIONS_PAGED_LIST, 200);
89+
ConnectionsPage response = request.execute().getBody();
90+
RecordedRequest recordedRequest = server.takeRequest();
91+
92+
assertThat(recordedRequest, hasMethodAndPath(HttpMethod.GET, "/api/v2/connections"));
93+
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
94+
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
95+
assertThat(recordedRequest, hasQueryParameter("from", "10"));
96+
97+
assertThat(response, is(notNullValue()));
98+
assertThat(response.getItems(), hasSize(2));
99+
assertThat(response.getStart(), is(0));
100+
assertThat(response.getLength(), is(14));
101+
assertThat(response.getTotal(), is(14));
102+
assertThat(response.getLimit(), is(50));
103+
}
104+
105+
@Test
106+
public void shouldListConnectionsWithTake() throws Exception {
107+
ConnectionFilter filter = new ConnectionFilter().withTake(1);
108+
Request<ConnectionsPage> request = api.connections().listAll(filter);
109+
assertThat(request, is(notNullValue()));
110+
111+
server.jsonResponse(MGMT_CONNECTIONS_PAGED_LIST, 200);
112+
ConnectionsPage response = request.execute().getBody();
113+
RecordedRequest recordedRequest = server.takeRequest();
114+
115+
assertThat(recordedRequest, hasMethodAndPath(HttpMethod.GET, "/api/v2/connections"));
116+
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
117+
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
118+
assertThat(recordedRequest, hasQueryParameter("take", "1"));
119+
120+
assertThat(response, is(notNullValue()));
121+
assertThat(response.getItems(), hasSize(2));
122+
assertThat(response.getStart(), is(0));
123+
assertThat(response.getLength(), is(14));
124+
assertThat(response.getTotal(), is(14));
125+
assertThat(response.getLimit(), is(50));
126+
}
127+
82128
@Test
83129
public void shouldThrowOnGetConnectionWithNullId() {
84130
verifyThrows(IllegalArgumentException.class,

0 commit comments

Comments
 (0)