KEYCLOAK-5186 createUser: set federationLink (#4316)
This commit is contained in:
parent
e36b94d905
commit
924b4f651a
4 changed files with 49 additions and 15 deletions
|
@ -201,6 +201,8 @@ public class UserResource {
|
|||
if (rep.isEnabled() != null) user.setEnabled(rep.isEnabled());
|
||||
if (rep.isEmailVerified() != null) user.setEmailVerified(rep.isEmailVerified());
|
||||
|
||||
if (rep.getFederationLink() != null) user.setFederationLink(rep.getFederationLink());
|
||||
|
||||
List<String> reqActions = rep.getRequiredActions();
|
||||
|
||||
if (reqActions != null) {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
org.keycloak.testsuite.federation.DummyUserFederationProviderFactory
|
0
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/AbstractAdminTest.java
Normal file → Executable file
0
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/AbstractAdminTest.java
Normal file → Executable file
|
@ -40,6 +40,7 @@ import org.keycloak.models.PasswordPolicy;
|
|||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.representations.idm.ComponentRepresentation;
|
||||
import org.keycloak.representations.idm.CredentialRepresentation;
|
||||
import org.keycloak.representations.idm.ErrorRepresentation;
|
||||
import org.keycloak.representations.idm.FederatedIdentityRepresentation;
|
||||
|
@ -50,7 +51,10 @@ import org.keycloak.representations.idm.RequiredActionProviderRepresentation;
|
|||
import org.keycloak.representations.idm.RoleRepresentation;
|
||||
import org.keycloak.representations.idm.UserRepresentation;
|
||||
import org.keycloak.services.resources.RealmsResource;
|
||||
import org.keycloak.storage.UserStorageProvider;
|
||||
import org.keycloak.testsuite.AbstractTestRealmKeycloakTest;
|
||||
import org.keycloak.testsuite.federation.DummyUserFederationProvider;
|
||||
import org.keycloak.testsuite.federation.DummyUserFederationProviderFactory;
|
||||
import org.keycloak.testsuite.page.LoginPasswordUpdatePage;
|
||||
import org.keycloak.testsuite.pages.ErrorPage;
|
||||
import org.keycloak.testsuite.pages.InfoPage;
|
||||
|
@ -122,6 +126,7 @@ public class UserTest extends AbstractAdminTest {
|
|||
return RunOnServerDeployment.create(
|
||||
AbstractAdminTest.class,
|
||||
AbstractTestRealmKeycloakTest.class,
|
||||
DummyUserFederationProviderFactory.class, DummyUserFederationProvider.class,
|
||||
UserResource.class);
|
||||
}
|
||||
|
||||
|
@ -318,6 +323,32 @@ public class UserTest extends AbstractAdminTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createUserWithFederationLink() {
|
||||
|
||||
// add a dummy federation provider
|
||||
ComponentRepresentation dummyFederationProvider = new ComponentRepresentation();
|
||||
dummyFederationProvider.setId(DummyUserFederationProviderFactory.PROVIDER_NAME);
|
||||
dummyFederationProvider.setName(DummyUserFederationProviderFactory.PROVIDER_NAME);
|
||||
dummyFederationProvider.setProviderId(DummyUserFederationProviderFactory.PROVIDER_NAME);
|
||||
dummyFederationProvider.setProviderType(UserStorageProvider.class.getName());
|
||||
adminClient.realms().realm(REALM_NAME).components().add(dummyFederationProvider);
|
||||
|
||||
assertAdminEvents.assertEvent(realmId, OperationType.CREATE, AdminEventPaths.componentPath(DummyUserFederationProviderFactory.PROVIDER_NAME), dummyFederationProvider, ResourceType.COMPONENT);
|
||||
|
||||
UserRepresentation user = new UserRepresentation();
|
||||
user.setUsername("user1");
|
||||
user.setEmail("user1@localhost");
|
||||
user.setFederationLink(DummyUserFederationProviderFactory.PROVIDER_NAME);
|
||||
|
||||
String userId = createUser(user);
|
||||
|
||||
// fetch user again and see federation link filled in
|
||||
UserRepresentation createdUser = realm.users().get(userId).toRepresentation();
|
||||
assertNotNull(createdUser);
|
||||
assertEquals(user.getFederationLink(), createdUser.getFederationLink());
|
||||
}
|
||||
|
||||
private void createUsers() {
|
||||
for (int i = 1; i < 10; i++) {
|
||||
UserRepresentation user = new UserRepresentation();
|
||||
|
|
Loading…
Reference in a new issue