Skip to content

Commit

Permalink
coar-notify-7 merge error IT fix
Browse files Browse the repository at this point in the history
  • Loading branch information
frabacche committed Jan 8, 2024
1 parent 1ab8bdc commit 46907cc
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;


/**
* This is the repository responsible to manage NotifyService Rest object
*
Expand Down Expand Up @@ -228,5 +229,4 @@ public Page<NotifyServiceRest> findManualServicesByInboundPattern(
public Class<NotifyServiceRest> getDomainClass() {
return NotifyServiceRest.class;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public Page<QAEventRest> findByTopic(@Parameter(value = "topic", required = true

@Override
@PreAuthorize("hasPermission(#id, 'QUALITYASSURANCEEVENT', 'DELETE')")
protected void delete(Context context, String eventId) throws AuthorizeException {
Item item = findTargetItem(context, eventId);
protected void delete(Context context, String id) throws AuthorizeException {
Item item = findTargetItem(context, id);
EPerson eperson = context.getCurrentUser();
qaEventService.deleteEventByEventId(eventId);
qaEventDao.storeEvent(context, eventId, eperson, item);
qaEventService.deleteEventByEventId(id);
qaEventDao.storeEvent(context, id, eperson, item);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Page<QATopicRest> findAll(Context context, Pageable pageable) {
}

@SearchRestMethod(name = "bySource")
@PreAuthorize("hasAuthority('AUTHENTICATED')")
@PreAuthorize("hasPermission(#source, 'QUALITYASSURANCETOPIC', 'READ')")
public Page<QATopicRest> findBySource(@Parameter(value = "source", required = true) String source,
Pageable pageable) {
Context context = obtainContext();
Expand All @@ -84,7 +84,7 @@ public Page<QATopicRest> findBySource(@Parameter(value = "source", required = tr
}

@SearchRestMethod(name = "byTarget")
@PreAuthorize("hasAuthority('AUTHENTICATED')")
@PreAuthorize("hasPermission(#target, 'QUALITYASSURANCETOPIC', 'READ')")
public Page<QATopicRest> findByTarget(@Parameter(value = "target", required = true) UUID target,
@Parameter(value = "source", required = true) String source,
Pageable pageable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.core.MediaType;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.RandomUtils;
import org.dspace.app.ldn.NotifyServiceEntity;
import org.dspace.app.ldn.service.NotifyService;
import org.dspace.app.rest.model.NotifyServiceInboundPatternRest;
import org.dspace.app.rest.model.NotifyServiceOutboundPatternRest;
import org.dspace.app.rest.model.NotifyServiceRest;
Expand All @@ -47,17 +50,22 @@
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
import org.dspace.builder.NotifyServiceBuilder;
import org.dspace.builder.NotifyServiceInboundPatternBuilder;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;


/**
* Integration test class for {@link NotifyServiceRestRepository}.
*
* @author Mohamed Eskander (mohamed.eskander at 4science.com)
*/
@Ignore
public class NotifyServiceRestRepositoryIT extends AbstractControllerIntegrationTest {

@Autowired
private NotifyService notifyService;

@Test
public void findAllUnAuthorizedTest() throws Exception {
getClient().perform(get("/api/ldn/ldnservices"))
Expand Down Expand Up @@ -713,6 +721,11 @@ public void notifyServiceNameRemoveOperationTest() throws Exception {
}

@Test
@Ignore
/*
* frabacche senseless because it's a mandatory+unique
* entity field and also table column!
*/
public void notifyServiceLdnUrlRemoveOperationTest() throws Exception {

context.turnOffAuthorisationSystem();
Expand Down Expand Up @@ -3473,5 +3486,20 @@ public void notifyServiceScoreAddOperationTest() throws Exception {
;
}

@Override
@After
public void destroy() throws Exception {
List<NotifyServiceEntity> notifyServiceEntities = notifyService.findAll(context);
if (CollectionUtils.isNotEmpty(notifyServiceEntities)) {
notifyServiceEntities.forEach(notifyServiceEntity -> {
try {
notifyService.delete(context, notifyServiceEntity);
} catch (SQLException e) {
throw new RuntimeException(e);
}
});
}

super.destroy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.dspace.qaevent.action.ASimpleMetadataAction;
import org.dspace.qaevent.dao.QAEventsDAO;
import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

Expand Down Expand Up @@ -986,7 +985,6 @@ public void deleteItemWithEventTest() throws Exception {
}

@Test
@Ignore
public void testEventDeletion() throws Exception {

context.turnOffAuthorisationSystem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.dspace.qaevent.QANotifyPatterns;
import org.dspace.services.ConfigurationService;
import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

Expand Down Expand Up @@ -322,7 +321,6 @@ public void findBySourceUnauthorizedTest() throws Exception {
.andExpect(status().isUnauthorized());
}

@Ignore
@Test
public void findBySourceForbiddenTest() throws Exception {
context.turnOffAuthorisationSystem();
Expand Down Expand Up @@ -435,7 +433,6 @@ public void findByTargetUnauthorizedTest() throws Exception {
.andExpect(status().isUnauthorized());
}

@Ignore
@Test
public void findByTargetForbiddenTest() throws Exception {
context.turnOffAuthorisationSystem();
Expand Down

0 comments on commit 46907cc

Please sign in to comment.