Fix errors in testsuite when Mongo model is used
This commit is contained in:
parent
1f78aa90d5
commit
b2cc74bf58
4 changed files with 26 additions and 19 deletions
|
@ -249,16 +249,18 @@ public class MongoDBImpl implements NoSQL {
|
|||
throw new IllegalArgumentException("Property " + listPropertyName + " doesn't exist on object " + object);
|
||||
}
|
||||
List<S> list = (List<S>)listProperty.getValue(object);
|
||||
|
||||
// If list is null, we skip both object and DB update
|
||||
if (list != null) {
|
||||
list.remove(itemToPull);
|
||||
}
|
||||
|
||||
// Pull item from DB
|
||||
Object dbItemToPull = typeConverter.convertApplicationObjectToDBObject(itemToPull, Object.class);
|
||||
BasicDBObject query = new BasicDBObject("_id", new ObjectId(oidProperty.getValue(object)));
|
||||
BasicDBObject pullObject = new BasicDBObject(listPropertyName, dbItemToPull);
|
||||
BasicDBObject pullCommand = new BasicDBObject("$pull", pullObject);
|
||||
getDBCollectionForType(type).update(query, pullCommand);
|
||||
// Pull item from DB
|
||||
Object dbItemToPull = typeConverter.convertApplicationObjectToDBObject(itemToPull, Object.class);
|
||||
BasicDBObject query = new BasicDBObject("_id", new ObjectId(oidProperty.getValue(object)));
|
||||
BasicDBObject pullObject = new BasicDBObject(listPropertyName, dbItemToPull);
|
||||
BasicDBObject pullCommand = new BasicDBObject("$pull", pullObject);
|
||||
getDBCollectionForType(type).update(query, pullCommand);
|
||||
}
|
||||
}
|
||||
|
||||
// Possibility to add user-defined converters
|
||||
|
|
|
@ -128,7 +128,10 @@ public class UserAdapter implements UserModel {
|
|||
|
||||
@Override
|
||||
public void addRequiredAction(RequiredAction action) {
|
||||
noSQL.pushItemToList(user, "requiredActions", action);
|
||||
// Push action only if it's not already here
|
||||
if (user.getRequiredActions() == null || !user.getRequiredActions().contains(action)) {
|
||||
noSQL.pushItemToList(user, "requiredActions", action);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -87,15 +87,13 @@ public class PasswordCredentialHandler {
|
|||
public void update(NoSQL noSQL, UserData user, String password,
|
||||
Date effectiveDate, Date expiryDate) {
|
||||
|
||||
// Try to look if user already has password
|
||||
// Delete existing password of user
|
||||
NoSQLQuery query = noSQL.createQueryBuilder()
|
||||
.andCondition("userId", user.getId())
|
||||
.build();
|
||||
noSQL.removeObjects(PasswordData.class, query);
|
||||
|
||||
PasswordData passwordData = noSQL.loadSingleObject(PasswordData.class, query);
|
||||
if (passwordData == null) {
|
||||
passwordData = new PasswordData();
|
||||
}
|
||||
PasswordData passwordData = new PasswordData();
|
||||
|
||||
String passwordSalt = generateSalt();
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
<artifactId>keycloak-testsuite-integration</artifactId>
|
||||
<name>Keycloak Integration TestSuite</name>
|
||||
<description />
|
||||
|
||||
<description />
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -21,7 +21,7 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
|
@ -72,7 +72,7 @@
|
|||
<artifactId>keycloak-forms</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.logging</groupId>
|
||||
<artifactId>jboss-logging</artifactId>
|
||||
|
@ -185,6 +185,10 @@
|
|||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -198,7 +202,7 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jboss-managed</id>
|
||||
|
|
Loading…
Reference in a new issue