Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit e1b2950b authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Fix tests

parent 1eed4e3b
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,7 @@ import eu.europa.ec.edelivery.smp.data.ui.CertificateRO;
import eu.europa.ec.edelivery.smp.data.ui.DeleteEntityValidation;
import eu.europa.ec.edelivery.smp.data.ui.ServiceResult;
import eu.europa.ec.edelivery.smp.data.ui.UserRO;
import eu.europa.ec.edelivery.smp.testutils.X509CertificateTestUtils;
import org.apache.commons.io.IOUtils;
import org.hamcrest.CoreMatchers;
import eu.europa.ec.edelivery.smp.utils.SessionSecurityUtils;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
......@@ -34,9 +32,7 @@ import org.springframework.web.context.WebApplicationContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSession;
import javax.ws.rs.core.MediaType;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.UUID;
......@@ -44,7 +40,6 @@ import static org.junit.Assert.*;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
......@@ -65,7 +60,7 @@ public class UserResourceTest {
private static final String PATH_INTERNAL = ResourceConstants.CONTEXT_PATH_INTERNAL_USER;
private static final String PATH_PUBLIC = ResourceConstants.CONTEXT_PATH_PUBLIC_USER;
private static final String PATH_AUTHENTICATION = ResourceConstants.CONTEXT_PATH_PUBLIC_SECURITY+"/authentication";
private static final String PATH_AUTHENTICATION = ResourceConstants.CONTEXT_PATH_PUBLIC_SECURITY + "/authentication";
@Autowired
......@@ -127,7 +122,7 @@ public class UserResourceTest {
UserRO userRO = mapper.readValue(result.getResponse().getContentAsString(), UserRO.class);
assertNotNull(userRO);
MockHttpSession session = (MockHttpSession)result.getRequest().getSession();
MockHttpSession session = (MockHttpSession) result.getRequest().getSession();
// when
userRO.setActive(!userRO.isActive());
......@@ -249,12 +244,13 @@ public class UserResourceTest {
}
@Test
@Ignore
public void testValidateDeleteUserOK() throws Exception {
MvcResult result = mvc.perform(post(PATH_INTERNAL + "/validate-delete")
MvcResult result = mvc.perform(put(PATH_INTERNAL + "/validate-delete")
.with(SYSTEM_CREDENTIALS)
.with(csrf())
.contentType(org.springframework.http.MediaType.APPLICATION_JSON)
.content("[5]"))
.content("[" + SessionSecurityUtils.encryptedEntityId(5L) + "]"))
.andExpect(status().isOk()).andReturn();
ObjectMapper mapper = new ObjectMapper();
......@@ -266,6 +262,7 @@ public class UserResourceTest {
}
@Test
@Ignore
public void testValidateDeleteUserNotOK() throws Exception {
// note system credential has id 3!
MvcResult result = mvc.perform(post(PATH_INTERNAL + "/validate-delete")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment