-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
50 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,7 @@ | |
import com.github.cloudyrock.mongock.ChangeSet; | ||
import com.github.cloudyrock.mongock.driver.mongodb.springdata.v3.decorator.impl.MongockTemplate; | ||
import myconext.manage.ServiceProviderResolver; | ||
import myconext.model.EduID; | ||
import myconext.model.PublicKeyCredentials; | ||
import myconext.model.ServiceProvider; | ||
import myconext.model.User; | ||
import myconext.model.*; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.springframework.data.mongodb.core.query.Criteria; | ||
|
@@ -140,6 +137,29 @@ public void deleteSessionAfterUserUpdate(MongockTemplate mongoTemplate) { | |
mongoTemplate.remove(new Query(), "sessions"); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@ChangeSet(order = "007", id = "migrateUsers", author = "[email protected]") | ||
public void migrateUsers(MongockTemplate mongoTemplate) { | ||
Criteria criteria = Criteria.where("linkedAccounts").exists(true).type(JsonSchemaObject.Type.ARRAY).ne(new ArrayList<>()); | ||
List<User> users = mongoTemplate.find(new Query(criteria), User.class, "users"); | ||
users.forEach(user -> user.linkedAccountsSorted().stream() | ||
.filter(LinkedAccount::areNamesValidated) | ||
.findFirst() | ||
.ifPresent(linkedAccount -> { | ||
user.setGivenName(linkedAccount.getGivenName()); | ||
user.setFamilyName(linkedAccount.getFamilyName()); | ||
user.setChosenName(user.getGivenName()); | ||
linkedAccount.setPreferred(true); | ||
mongoTemplate.save(user); | ||
})); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@ChangeSet(order = "008", id = "deleteSessionAgain", author = "[email protected]") | ||
public void deleteSessionAgain(MongockTemplate mongoTemplate) { | ||
mongoTemplate.remove(new Query(), "sessions"); | ||
} | ||
|
||
protected User mergeEduIDs(User user) { | ||
List<EduID> eduIDS = user.getEduIDS(); | ||
//Make a copy to search in | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,6 @@ public void accountLinkingRequiredNotNeeded() throws IOException { | |
@Test | ||
public void accountLinkingWithValidatedNames() throws IOException { | ||
User user = userRepository.findOneUserByEmail("[email protected]"); | ||
LinkedAccount linkedAccount = user.linkedAccountsSorted().get(0); | ||
|
||
String authnContext = readFile("request_authn_context_validated_name.xml"); | ||
Response response = samlAuthnRequestResponseWithLoa(null, "relay", authnContext); | ||
|
@@ -146,8 +145,8 @@ public void accountLinkingWithValidatedNames() throws IOException { | |
String samlResponse = samlResponse(magicLinkResponse); | ||
|
||
assertTrue(samlResponse.contains(ACR.VALIDATE_NAMES)); | ||
assertTrue(samlResponse.contains(linkedAccount.getFamilyName())); | ||
assertTrue(samlResponse.contains(linkedAccount.getGivenName())); | ||
assertTrue(samlResponse.contains(user.getFamilyName())); | ||
assertTrue(samlResponse.contains(user.getGivenName())); | ||
} | ||
|
||
@Test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters