From cdb61215c99fda97de916b1b08ad21ccf40fcc24 Mon Sep 17 00:00:00 2001 From: mposolda Date: Thu, 5 Oct 2023 18:08:18 +0200 Subject: [PATCH] UserProfileContext.ACCOUNT_OLD seems to be obsolete and not needed closes #23749 --- .../java/org/keycloak/userprofile/UserProfileContext.java | 1 - .../org/keycloak/userprofile/AbstractUserProfileProvider.java | 2 -- .../java/org/keycloak/userprofile/config/UPConfigUtils.java | 3 +-- .../org/keycloak/testsuite/user/profile/UserProfileTest.java | 4 ---- .../testsuite/user/profile/config/UPConfigUtilsTest.java | 4 ---- 5 files changed, 1 insertion(+), 13 deletions(-) diff --git a/server-spi-private/src/main/java/org/keycloak/userprofile/UserProfileContext.java b/server-spi-private/src/main/java/org/keycloak/userprofile/UserProfileContext.java index d3c37c3d0c..90ddc96a59 100644 --- a/server-spi-private/src/main/java/org/keycloak/userprofile/UserProfileContext.java +++ b/server-spi-private/src/main/java/org/keycloak/userprofile/UserProfileContext.java @@ -33,7 +33,6 @@ public enum UserProfileContext { UPDATE_PROFILE(true), USER_API(false), ACCOUNT(true), - ACCOUNT_OLD(true), IDP_REVIEW(false), REGISTRATION_PROFILE(false), REGISTRATION_USER_CREATION(false), diff --git a/services/src/main/java/org/keycloak/userprofile/AbstractUserProfileProvider.java b/services/src/main/java/org/keycloak/userprofile/AbstractUserProfileProvider.java index 472a5ac0a4..065b7a09b9 100644 --- a/services/src/main/java/org/keycloak/userprofile/AbstractUserProfileProvider.java +++ b/services/src/main/java/org/keycloak/userprofile/AbstractUserProfileProvider.java @@ -21,7 +21,6 @@ package org.keycloak.userprofile; import static org.keycloak.userprofile.DefaultAttributes.READ_ONLY_ATTRIBUTE_KEY; import static org.keycloak.userprofile.UserProfileContext.ACCOUNT; -import static org.keycloak.userprofile.UserProfileContext.ACCOUNT_OLD; import static org.keycloak.userprofile.UserProfileContext.IDP_REVIEW; import static org.keycloak.userprofile.UserProfileContext.REGISTRATION_PROFILE; import static org.keycloak.userprofile.UserProfileContext.REGISTRATION_USER_CREATION; @@ -239,7 +238,6 @@ public abstract class AbstractUserProfileProvider addContextualProfileMetadata(configureUserProfile(createBrokeringProfile(readOnlyValidator))); addContextualProfileMetadata(configureUserProfile(createAccountProfile(ACCOUNT, readOnlyValidator))); - addContextualProfileMetadata(configureUserProfile(createDefaultProfile(ACCOUNT_OLD, readOnlyValidator))); addContextualProfileMetadata(configureUserProfile(createDefaultProfile(REGISTRATION_PROFILE, readOnlyValidator))); addContextualProfileMetadata(configureUserProfile(createDefaultProfile(UPDATE_PROFILE, readOnlyValidator))); if (Profile.isFeatureEnabled(Profile.Feature.UPDATE_EMAIL)) { diff --git a/services/src/main/java/org/keycloak/userprofile/config/UPConfigUtils.java b/services/src/main/java/org/keycloak/userprofile/config/UPConfigUtils.java index a5da7a1e24..73ddc51180 100644 --- a/services/src/main/java/org/keycloak/userprofile/config/UPConfigUtils.java +++ b/services/src/main/java/org/keycloak/userprofile/config/UPConfigUtils.java @@ -278,8 +278,7 @@ public class UPConfigUtils { * @return true if context CAN BE part of the auth flow */ public static boolean canBeAuthFlowContext(UserProfileContext context) { - return context != UserProfileContext.USER_API && context != UserProfileContext.ACCOUNT - && context != UserProfileContext.ACCOUNT_OLD; + return context != UserProfileContext.USER_API && context != UserProfileContext.ACCOUNT; } /** diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/user/profile/UserProfileTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/user/profile/UserProfileTest.java index c794e84b05..083ca08a7e 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/user/profile/UserProfileTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/user/profile/UserProfileTest.java @@ -1453,8 +1453,6 @@ public class UserProfileTest extends AbstractUserProfileTest { profile.validate(); profile = provider.create(UserProfileContext.ACCOUNT, attributes); profile.validate(); - profile = provider.create(UserProfileContext.ACCOUNT_OLD, attributes); - profile.validate(); // no fail on auth flow scopes when scope is not required profile = provider.create(UserProfileContext.REGISTRATION_PROFILE, attributes); @@ -1474,8 +1472,6 @@ public class UserProfileTest extends AbstractUserProfileTest { profile.validate(); profile = provider.create(UserProfileContext.ACCOUNT, attributes); profile.validate(); - profile = provider.create(UserProfileContext.ACCOUNT_OLD, attributes); - profile.validate(); // fail on auth flow scopes when scope is required try { diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/user/profile/config/UPConfigUtilsTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/user/profile/config/UPConfigUtilsTest.java index 7a972f2ba5..0f9dc9dc54 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/user/profile/config/UPConfigUtilsTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/user/profile/config/UPConfigUtilsTest.java @@ -39,7 +39,6 @@ public class UPConfigUtilsTest { @Test public void canBeAuthFlowContext() { Assert.assertFalse(UPConfigUtils.canBeAuthFlowContext(UserProfileContext.ACCOUNT)); - Assert.assertFalse(UPConfigUtils.canBeAuthFlowContext(UserProfileContext.ACCOUNT_OLD)); Assert.assertFalse(UPConfigUtils.canBeAuthFlowContext(UserProfileContext.USER_API)); Assert.assertTrue(UPConfigUtils.canBeAuthFlowContext(UserProfileContext.IDP_REVIEW)); @@ -57,14 +56,12 @@ public class UPConfigUtilsTest { roles.add(ROLE_ADMIN); Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.USER_API, roles)); Assert.assertFalse(UPConfigUtils.isRoleForContext(UserProfileContext.ACCOUNT, roles)); - Assert.assertFalse(UPConfigUtils.isRoleForContext(UserProfileContext.ACCOUNT_OLD, roles)); Assert.assertFalse(UPConfigUtils.isRoleForContext(UserProfileContext.UPDATE_PROFILE, roles)); roles = new HashSet<>(); roles.add(ROLE_USER); Assert.assertFalse(UPConfigUtils.isRoleForContext(UserProfileContext.USER_API, roles)); Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.ACCOUNT, roles)); - Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.ACCOUNT_OLD, roles)); Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.IDP_REVIEW, roles)); Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.REGISTRATION_PROFILE, roles)); @@ -72,7 +69,6 @@ public class UPConfigUtilsTest { roles.add(ROLE_ADMIN); Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.USER_API, roles)); Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.ACCOUNT, roles)); - Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.ACCOUNT_OLD, roles)); Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.IDP_REVIEW, roles)); Assert.assertTrue(UPConfigUtils.isRoleForContext(UserProfileContext.REGISTRATION_PROFILE, roles)); }