From 50916d58b165f1374369beef764a6a4108e82c9e Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Mon, 16 Oct 2023 11:12:12 +0200 Subject: [PATCH] Clean up created test user to avoid conflict with other tests Closes #23804 --- .../keycloak/testsuite/runonserver/SerializationUtil.java | 3 +++ .../federation/ldap/LDAPProvidersFullNameMapperTest.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/runonserver/SerializationUtil.java b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/runonserver/SerializationUtil.java index 1f56a807ae96..397144e00620 100644 --- a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/runonserver/SerializationUtil.java +++ b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/runonserver/SerializationUtil.java @@ -51,6 +51,9 @@ public static String encodeException(Throwable t) { oos.close(); return "EXCEPTION:" + Base64.encodeBytes(os.toByteArray()); + } catch (NotSerializableException e) { + // when the exception can't be serialized, at least log the original exception, so it can be analyzed + throw new RuntimeException("Unable to serialize exception due to not serializable class " + e.getMessage(), t); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPProvidersFullNameMapperTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPProvidersFullNameMapperTest.java index 4c713d21d582..72f58ec8fbf3 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPProvidersFullNameMapperTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/federation/ldap/LDAPProvidersFullNameMapperTest.java @@ -167,7 +167,7 @@ public void testUpdatingAttributesWorksEvenWithEmptyAttributes() { MatcherAssert.assertThat(Arrays.asList("one", "two", "three"), Matchers.containsInAnyOrder(fullnameUser.getAttributeStream("myAttrThreeValues").toArray(String[]::new))); - // Remove "fullnameUser" to assert he is removed from LDAP. + // Remove "fullnameUser" to prevent conflicts with other tests session.users().removeUser(appRealm, fullnameUser); }); } @@ -201,6 +201,9 @@ public void testMultiValuedAttributes() { UserModel fullnameUser = session.users().getUserByUsername(appRealm, "fullname"); Assert.assertEquals(Arrays.asList("role1", "role2"), fullnameUser.getAttributeStream("roles").collect(Collectors.toList())); + + // Remove "fullnameUser" to prevent conflicts with other tests + session.users().removeUser(appRealm, fullnameUser); }); } }