Skip to content
Open
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
5 changes: 5 additions & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
<version>2.27.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope> <!-- or omit scope to default to compile -->
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,8 @@ class GroupsIT extends ITSupport {
sleep(3000)
assertUserInGroup(user, group, groupApi, 10, getTestOperationDelay())

// 3. Remove user from group and validate user removed
groupApi.unassignUserFromGroup(group.getId(), user.getId())
groupApi.unassignUserFromGroup(group.getId(), user.getId());

assertUserNotInGroup(user, group, groupApi,10, getTestOperationDelay())
assertUserNotInGroup(user, group, groupApi);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import static org.hamcrest.MatcherAssert.assertThat
import static org.hamcrest.Matchers.equalTo
import static org.hamcrest.Matchers.hasSize
import static org.hamcrest.Matchers.notNullValue
import static org.awaitility.Awaitility.await
import static java.util.concurrent.TimeUnit.SECONDS
import static org.hamcrest.Matchers.is

class Util {

Expand Down Expand Up @@ -117,26 +120,25 @@ class Util {
if (!present) Assert.fail("User found in group")
}

static void assertUserNotInGroup(User user, Group group, GroupApi groupApi) {
assertThat "User was found in group.", !StreamSupport.stream(groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false)
.filter{ listUser -> listUser.id == user.id}
.findFirst().isPresent()
}

static void assertUserNotInGroup(User user, Group group, GroupApi groupApi, int times, long delayInMilliseconds) {
for (int ii = 0; ii < times; ii++) {
sleep(delayInMilliseconds)
// static void assertUserNotInGroup(User user, Group group, GroupApi groupApi) {
// assertThat "User was found in group.", !StreamSupport.stream(groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false)
// .filter{ listUser -> listUser.id == user.id}
// .findFirst().isPresent()
// }

boolean userIsPresent = StreamSupport.stream(
groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false
).anyMatch { listUser -> listUser.id == user.id }

if (!userIsPresent) {
return
}
}

Assert.fail("User found in group after ${times} attempts")
static void assertUserNotInGroup(User user, Group group, GroupApi groupApi) {
await()
.atMost(60, SECONDS) // Wait for a maximum of 60 seconds.
.pollInterval(2, SECONDS) // Check every 2 seconds.
.untilAsserted(() -> {
boolean userIsPresent = StreamSupport.stream(
groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false
).anyMatch(listUser -> listUser.id.equals(user.id));

// This assertion will be retried until it passes or the timeout is reached.
assertThat("User should not be present in the group.", userIsPresent, is(false));
});
}


Expand Down
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<bouncycastle.version>1.78.1</bouncycastle.version>
<jjwt.version>0.12.6</jjwt.version>
<org.apache.httpcomponents.client5.version>5.3.1</org.apache.httpcomponents.client5.version>
<okta.sdk.previousVersion>23.0.1</okta.sdk.previousVersion>
<okta.sdk.previousVersion>24.0.0</okta.sdk.previousVersion>
<okta.commons.version>2.0.1</okta.commons.version>
<com.google.auto.service.version>1.1.1</com.google.auto.service.version>
<github.slug>okta/okta-sdk-java</github.slug>
Expand Down Expand Up @@ -87,6 +87,13 @@
<artifactId>okta-commons-lang</artifactId>
<version>${okta.commons.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.18.0</version>
</dependency>

<dependency>
<groupId>com.okta.commons</groupId>
<artifactId>okta-http-api</artifactId>
Expand Down Expand Up @@ -209,6 +216,11 @@
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.1</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down