diff --git a/core/platform-common/src/main/java/org/sunbird/sso/impl/KeyCloakServiceImpl.java b/core/platform-common/src/main/java/org/sunbird/sso/impl/KeyCloakServiceImpl.java index 9e97d94531..9ac0f3425f 100644 --- a/core/platform-common/src/main/java/org/sunbird/sso/impl/KeyCloakServiceImpl.java +++ b/core/platform-common/src/main/java/org/sunbird/sso/impl/KeyCloakServiceImpl.java @@ -6,6 +6,7 @@ import java.security.PublicKey; import java.security.spec.X509EncodedKeySpec; import java.util.Base64; +import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.keycloak.RSATokenVerifier; @@ -94,6 +95,9 @@ public boolean removePII(String userId, RequestContext context) { user.setEnabled(false); logger.info("KeyCloakServiceImpl::removePII:: userId:: " + fedUserId); userResource.update(user); + List userSessions = userResource.getUserSessions(); + for (Object userSession : userSessions) + userSessions.remove(userSession); return true; } catch (Exception e) { logger.error(context, "removePII: Exception occurred: ", e); diff --git a/core/platform-common/src/test/java/org/sunbird/sso/impl/KeyCloakServiceImplTest.java b/core/platform-common/src/test/java/org/sunbird/sso/impl/KeyCloakServiceImplTest.java index 8dc8e4bf75..1e2e22babf 100644 --- a/core/platform-common/src/test/java/org/sunbird/sso/impl/KeyCloakServiceImplTest.java +++ b/core/platform-common/src/test/java/org/sunbird/sso/impl/KeyCloakServiceImplTest.java @@ -196,11 +196,12 @@ public void testGetFederatedUserId() @Test public void testUpdatePassword() throws Exception { boolean updated = keyCloakService.updatePassword(userId.get(JsonKey.USER_ID), "password", null); - Assert.assertNotNull(updated); + Assert.assertTrue(updated); } @Test public void testRemovePII() { - keyCloakService.removePII(userId.get(JsonKey.USER_ID), new RequestContext()); + boolean piiRemoved = keyCloakService.removePII(userId.get(JsonKey.USER_ID), new RequestContext()); + Assert.assertTrue(piiRemoved); } }