mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Add test to check that user with read rights can see hidden metadata
(cherry picked from commit 03496c36d4
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
40bb9491a5
commit
42959d5db8
@@ -14,6 +14,7 @@ import static org.dspace.app.rest.matcher.MetadataMatcher.matchMetadata;
|
||||
import static org.dspace.app.rest.matcher.MetadataMatcher.matchMetadataDoesNotExist;
|
||||
import static org.dspace.builder.OrcidHistoryBuilder.createOrcidHistory;
|
||||
import static org.dspace.builder.OrcidQueueBuilder.createOrcidQueue;
|
||||
import static org.dspace.core.Constants.READ;
|
||||
import static org.dspace.core.Constants.WRITE;
|
||||
import static org.dspace.orcid.OrcidOperation.DELETE;
|
||||
import static org.dspace.profile.OrcidEntitySyncPreference.ALL;
|
||||
@@ -3028,6 +3029,39 @@ public class ItemRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHiddenMetadataForUserWithReadRights() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build();
|
||||
|
||||
Item item = ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Public item 1")
|
||||
.withProvenanceData("Provenance data")
|
||||
.build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
|
||||
ResourcePolicyBuilder.createResourcePolicy(context)
|
||||
.withUser(eperson)
|
||||
.withAction(READ)
|
||||
.withDspaceObject(item)
|
||||
.build();
|
||||
|
||||
String token = getAuthToken(eperson.getEmail(), password);
|
||||
|
||||
getClient(token).perform(get("/api/core/items/" + item.getID()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$", ItemMatcher.matchItemProperties(item)))
|
||||
.andExpect(jsonPath("$.metadata", matchMetadata("dc.title", "Public item 1")))
|
||||
.andExpect(jsonPath("$.metadata", matchMetadataDoesNotExist("dc.description.provenance")));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntityTypePerson() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
Reference in New Issue
Block a user