Skip to content

Commit

Permalink
Allow merging of accounts that are members of the same group (#9909)
Browse files Browse the repository at this point in the history
* Remove unused import

* Merge users with same groups

* Added additional line in Permalinks config

Added an additional line to restart Payara after changing settings in Permalinks section

* Revert "#9717 grant CREATE instead of ALL per pdurbin"

This reverts commit f71274e.

* CREATE instead of ALL for public schema

* Added: getZipDownloadLimit and getEmbargoEnabled API info endpoints

* Added: docs for new info API endpoints

* Fixed: missing guides reference in config.rst

* Changed: :MaxEmbargoDurationInMonths setting directly exposed via API info endpoint

* Changed: updated release notes

* Changed: private Info.java method renamed

* stub out page on API design, esp paths #9880

* remove embargo example, no longer used in #9881

* typo #9880

* Remove unused GPL-licensed code

For unknown reasons, in 2009 several files from the JDK were copied into
the Dataverse codebase, instead of referenced.
It appears that these classes weren't really used.

* Removed unused code

---------

Co-authored-by: Jérôme ROUCOU <[email protected]>
Co-authored-by: Pradyumna Sridhara <[email protected]>
Co-authored-by: Philip Durbin <[email protected]>
Co-authored-by: GPortas <[email protected]>
Co-authored-by: bencomp <[email protected]>
Co-authored-by: jeromeroucou <[email protected]>
  • Loading branch information
7 people authored Jun 3, 2024
1 parent e6b5856 commit 26be8e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import edu.harvard.iq.dataverse.UserNotification;
import edu.harvard.iq.dataverse.authorization.AuthenticatedUserLookup;
import edu.harvard.iq.dataverse.authorization.providers.builtin.BuiltinUser;
import edu.harvard.iq.dataverse.authorization.providers.oauth2.OAuth2TokenData;
import edu.harvard.iq.dataverse.authorization.users.ApiToken;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import edu.harvard.iq.dataverse.batch.util.LoggingUtil;
Expand All @@ -25,7 +24,6 @@
import edu.harvard.iq.dataverse.engine.command.RequiredPermissions;
import edu.harvard.iq.dataverse.engine.command.exception.CommandException;
import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException;
import edu.harvard.iq.dataverse.passwordreset.PasswordResetData;
import edu.harvard.iq.dataverse.search.IndexResponse;
import edu.harvard.iq.dataverse.search.savedsearch.SavedSearch;
import edu.harvard.iq.dataverse.workflows.WorkflowComment;
Expand Down Expand Up @@ -177,6 +175,7 @@ protected void executeImpl(CommandContext ctxt) throws CommandException {

ctxt.em().createNativeQuery("Delete from OAuth2TokenData where user_id ="+consumedAU.getId()).executeUpdate();

ctxt.em().createNativeQuery("DELETE FROM explicitgroup_authenticateduser consumed USING explicitgroup_authenticateduser ongoing WHERE consumed.containedauthenticatedusers_id="+ongoingAU.getId()+" AND ongoing.containedauthenticatedusers_id="+consumedAU.getId()).executeUpdate();
ctxt.em().createNativeQuery("UPDATE explicitgroup_authenticateduser SET containedauthenticatedusers_id="+ongoingAU.getId()+" WHERE containedauthenticatedusers_id="+consumedAU.getId()).executeUpdate();

ctxt.actionLog().changeUserIdentifierInHistory(consumedAU.getIdentifier(), ongoingAU.getIdentifier());
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.harvard.iq.dataverse.authorization.DataverseRole;
import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import jakarta.json.Json;
Expand Down Expand Up @@ -206,15 +207,13 @@ public void testMergeAccounts(){
String aliasInOwner = "groupFor" + dataverseAlias;
String displayName = "Group for " + dataverseAlias;
String user2identifier = "@" + usernameConsumed;
String target2identifier = "@" + targetname;
Response createGroup = UtilIT.createGroup(dataverseAlias, aliasInOwner, displayName, superuserApiToken);
createGroup.prettyPrint();
createGroup.then().assertThat()
.statusCode(CREATED.getStatusCode());

String groupIdentifier = JsonPath.from(createGroup.asString()).getString("data.identifier");

List<String> roleAssigneesToAdd = new ArrayList<>();
roleAssigneesToAdd.add(user2identifier);
List<String> roleAssigneesToAdd = Arrays.asList(user2identifier, target2identifier);
Response addToGroup = UtilIT.addToGroup(dataverseAlias, aliasInOwner, roleAssigneesToAdd, superuserApiToken);
addToGroup.prettyPrint();
addToGroup.then().assertThat()
Expand Down

0 comments on commit 26be8e1

Please sign in to comment.