[KEYCLOAK-883] - Model tests.
This commit is contained in:
1 parent
15feb39ecc
commit
2065815627
32 files changed
+928
-62
No files matched your search
@@ -55,17 +55,15 @@ public class IdentityProviderModel {
|
||||
private Map<String, String> config = new HashMap<String, String>();
|
||||
|
||||
public IdentityProviderModel() {
|
||||
this(null, null, null, null);
|
||||
}
|
||||
|
||||
public IdentityProviderModel(String providerId, String id, String name, Map<String, String> config) {
|
||||
this.providerId = providerId;
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
|
||||
if (config != null) {
|
||||
this.config.putAll(config);
|
||||
}
|
||||
public IdentityProviderModel(IdentityProviderModel model) {
|
||||
this.providerId = model.getProviderId();
|
||||
this.id = model.getId();
|
||||
this.name = model.getName();
|
||||
this.config = new HashMap<String, String>(model.getConfig());
|
||||
this.enabled = model.isEnabled();
|
||||
this.updateProfileFirstLogin = model.isUpdateProfileFirstLogin();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
||||
@@ -164,6 +164,7 @@ public interface RealmModel extends RoleContainerModel {
|
||||
void setSmtpConfig(Map<String, String> smtpConfig);
|
||||
|
||||
List<IdentityProviderModel> getIdentityProviders();
|
||||
IdentityProviderModel getIdentityProviderById(String identityProviderId);
|
||||
void addIdentityProvider(IdentityProviderModel identityProvider);
|
||||
void removeIdentityProviderById(String providerId);
|
||||
void updateIdentityProvider(IdentityProviderModel identityProvider);
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.keycloak.models.BrowserSecurityHeaders;
|
||||
import org.keycloak.models.ClaimMask;
|
||||
import org.keycloak.models.ClientModel;
|
||||
import org.keycloak.models.FederatedIdentityModel;
|
||||
import org.keycloak.models.IdentityProviderModel;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.OAuthClientModel;
|
||||
import org.keycloak.models.PasswordPolicy;
|
||||
@@ -21,6 +22,7 @@ import org.keycloak.representations.idm.ApplicationRepresentation;
|
||||
import org.keycloak.representations.idm.ClaimRepresentation;
|
||||
import org.keycloak.representations.idm.CredentialRepresentation;
|
||||
import org.keycloak.representations.idm.FederatedIdentityRepresentation;
|
||||
import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
||||
import org.keycloak.representations.idm.OAuthClientRepresentation;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.representations.idm.RoleRepresentation;
|
||||
@@ -229,6 +231,21 @@ public class RepresentationToModel {
|
||||
UserModel user = createUser(session, newRealm, userRep, appMap);
|
||||
}
|
||||
}
|
||||
|
||||
if (rep.getIdentityProviders() != null) {
|
||||
for (IdentityProviderRepresentation identityProviderRepresentation : rep.getIdentityProviders()) {
|
||||
IdentityProviderModel identityProviderModel = new IdentityProviderModel();
|
||||
|
||||
identityProviderModel.setId(identityProviderRepresentation.getId());
|
||||
identityProviderModel.setProviderId(identityProviderRepresentation.getProviderId());
|
||||
identityProviderModel.setName(identityProviderRepresentation.getName());
|
||||
identityProviderModel.setEnabled(identityProviderRepresentation.isEnabled());
|
||||
identityProviderModel.setUpdateProfileFirstLogin(identityProviderRepresentation.isUpdateProfileFirstLogin());
|
||||
identityProviderModel.setConfig(identityProviderRepresentation.getConfig());
|
||||
|
||||
newRealm.addIdentityProvider(identityProviderModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateRealm(RealmRepresentation rep, RealmModel realm) {
|
||||
@@ -727,5 +744,4 @@ public class RepresentationToModel {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user