Merge pull request #3677 from mposolda/master
Fix LDAP tests with MSAD, RHDS and OpenLDAP
This commit is contained in:
commit
761714036e
4 changed files with 15 additions and 22 deletions
|
@ -50,7 +50,7 @@ public class PersistentUserSessionEntity {
|
|||
@Column(name = "REALM_ID", length = 36)
|
||||
protected String realmId;
|
||||
|
||||
@Column(name="USER_ID", length = 36)
|
||||
@Column(name="USER_ID", length = 255)
|
||||
protected String userId;
|
||||
|
||||
@Column(name = "LAST_SESSION_REFRESH")
|
||||
|
|
|
@ -32,8 +32,7 @@ public class MongoAuthorizationStoreFactory implements AuthorizationStoreFactory
|
|||
@Override
|
||||
public StoreFactory create(KeycloakSession session) {
|
||||
MongoConnectionProvider connection = session.getProvider(MongoConnectionProvider.class);
|
||||
AuthorizationProvider provider = session.getProvider(AuthorizationProvider.class);
|
||||
return new MongoStoreFactory(connection.getInvocationContext(), provider);
|
||||
return new MongoStoreFactory(connection.getInvocationContext(), session);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.keycloak.authorization.store.ResourceStore;
|
|||
import org.keycloak.authorization.store.ScopeStore;
|
||||
import org.keycloak.authorization.store.StoreFactory;
|
||||
import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
|
||||
|
@ -32,31 +33,35 @@ import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
|
|||
public class MongoStoreFactory implements StoreFactory {
|
||||
|
||||
private final MongoStoreInvocationContext invocationContext;
|
||||
private final AuthorizationProvider authorizationProvider;
|
||||
private final KeycloakSession session;
|
||||
|
||||
public MongoStoreFactory(MongoStoreInvocationContext invocationContext, AuthorizationProvider authorizationProvider) {
|
||||
public MongoStoreFactory(MongoStoreInvocationContext invocationContext, KeycloakSession session) {
|
||||
this.invocationContext = invocationContext;
|
||||
this.authorizationProvider = authorizationProvider;
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyStore getPolicyStore() {
|
||||
return new MongoPolicyStore(this.invocationContext, this.authorizationProvider);
|
||||
return new MongoPolicyStore(this.invocationContext, getAuthorizationProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceServerStore getResourceServerStore() {
|
||||
return new MongoResourceServerStore(this.invocationContext, this.authorizationProvider);
|
||||
return new MongoResourceServerStore(this.invocationContext, getAuthorizationProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceStore getResourceStore() {
|
||||
return new MongoResourceStore(this.invocationContext, this.authorizationProvider);
|
||||
return new MongoResourceStore(this.invocationContext, getAuthorizationProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScopeStore getScopeStore() {
|
||||
return new MongoScopeStore(this.invocationContext, this.authorizationProvider);
|
||||
return new MongoScopeStore(this.invocationContext, getAuthorizationProvider());
|
||||
}
|
||||
|
||||
private AuthorizationProvider getAuthorizationProvider() {
|
||||
return session.getProvider(AuthorizationProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -206,19 +206,8 @@ public class LDAPBinaryAttributesTest {
|
|||
// Expected
|
||||
}
|
||||
|
||||
|
||||
// Try to update him with some bad value for jpegPhoto. It will fail
|
||||
try {
|
||||
joe.getAttributes().remove("someOtherPhoto");
|
||||
joe.getAttributes().put(LDAPConstants.JPEG_PHOTO, Arrays.asList("foobar"));
|
||||
adminClient.realm("test").users().get(joe.getId()).update(joe);
|
||||
Assert.fail("Not expected to successfully update user");
|
||||
} catch (ClientErrorException cee) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
|
||||
// Remove jpegPhoto attribute and assert it was successfully removed
|
||||
joe.getAttributes().remove("someOtherPhoto");
|
||||
joe.getAttributes().remove(LDAPConstants.JPEG_PHOTO);
|
||||
adminClient.realm("test").users().get(joe.getId()).update(joe);
|
||||
getUserAndAssertPhoto("joephoto", false);
|
||||
|
|
Loading…
Reference in a new issue