mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
DS-3908 Restore authz state as early as possible in tests
This commit is contained in:
@@ -604,13 +604,10 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
context.turnOffAuthorisationSystem();
|
||||
parentCommunity = CommunityBuilder.createCommunity(context).withName("Community").withLogo("logo_community")
|
||||
.build();
|
||||
context.restoreAuthSystemState();
|
||||
String token = getAuthToken(asUser.getEmail(), password);
|
||||
|
||||
try {
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/bitstreams/"
|
||||
+ parentCommunity.getLogo().getID(), expectedStatus);
|
||||
} finally {
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/bitstreams/"
|
||||
+ parentCommunity.getLogo().getID(), expectedStatus);
|
||||
}
|
||||
}
|
||||
|
@@ -641,13 +641,9 @@ public class CollectionRestRepositoryIT extends AbstractControllerIntegrationTes
|
||||
context.turnOffAuthorisationSystem();
|
||||
parentCommunity = CommunityBuilder.createCommunity(context).withName("Community").build();
|
||||
Collection col = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection").build();
|
||||
context.restoreAuthSystemState();
|
||||
String token = getAuthToken(asUser.getEmail(), password);
|
||||
|
||||
try {
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/collections/"
|
||||
+ col.getID(), expectedStatus);
|
||||
} finally {
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/collections/" + col.getID(), expectedStatus);
|
||||
}
|
||||
}
|
||||
|
@@ -866,13 +866,10 @@ public class CommunityRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
private void runPatchMetadataTests(EPerson asUser, int expectedStatus) throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
parentCommunity = CommunityBuilder.createCommunity(context).withName("Community").build();
|
||||
context.restoreAuthSystemState();
|
||||
String token = getAuthToken(asUser.getEmail(), password);
|
||||
|
||||
try {
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/communities/"
|
||||
+ parentCommunity.getID(), expectedStatus);
|
||||
} finally {
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/communities/"
|
||||
+ parentCommunity.getID(), expectedStatus);
|
||||
}
|
||||
}
|
||||
|
@@ -1046,14 +1046,10 @@ public class EPersonRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
private void runPatchMetadataTests(EPerson asUser, int expectedStatus) throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
EPerson ePerson = EPersonBuilder.createEPerson(context).withEmail("user@test.com").build();
|
||||
context.restoreAuthSystemState();
|
||||
String token = getAuthToken(asUser.getEmail(), password);
|
||||
|
||||
try {
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/eperson/epersons/" + ePerson.getID(),
|
||||
expectedStatus);
|
||||
} finally {
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/eperson/epersons/" + ePerson.getID(), expectedStatus);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -249,13 +249,9 @@ public class GroupRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
private void runPatchMetadataTests(EPerson asUser, int expectedStatus) throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
Group group = GroupBuilder.createGroup(context).withName("Group").build();
|
||||
context.restoreAuthSystemState();
|
||||
String token = getAuthToken(asUser.getEmail(), password);
|
||||
|
||||
try {
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/eperson/groups/"
|
||||
+ group.getID(), expectedStatus);
|
||||
} finally {
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/eperson/groups/" + group.getID(), expectedStatus);
|
||||
}
|
||||
}
|
||||
|
@@ -1762,13 +1762,10 @@ public class ItemRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
.withName("Sub Community").build();
|
||||
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
|
||||
Item item = ItemBuilder.createItem(context, col1).build();
|
||||
context.restoreAuthSystemState();
|
||||
String token = getAuthToken(asUser.getEmail(), password);
|
||||
|
||||
try {
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/items/" + item.getID(), expectedStatus);
|
||||
} finally {
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/items/" + item.getID(), expectedStatus);
|
||||
}
|
||||
|
||||
}
|
@@ -83,13 +83,9 @@ public class SiteRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
private void runPatchMetadataTests(EPerson asUser, int expectedStatus) throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
Site site = SiteBuilder.createSite(context).build();
|
||||
context.restoreAuthSystemState();
|
||||
String token = getAuthToken(asUser.getEmail(), password);
|
||||
|
||||
try {
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/sites/" + site.getID(), expectedStatus);
|
||||
} finally {
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
|
||||
new MetadataPatchSuite().runWith(getClient(token), "/api/core/sites/" + site.getID(), expectedStatus);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user