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

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

Fix DDC renamed packages

parent be05727a
No related branches found
No related tags found
No related merge requests found
Pipeline #110245 failed
package eu.europa.ec.smp.spi.handler; package eu.europa.ec.smp.spi.handler;
import eu.europa.ec.dynamicdiscovery.core.extension.impl.OasisSMP10ServiceGroupReader; import eu.europa.ec.dynamicdiscovery.core.extension.impl.oasis10.OasisSMP10ServiceGroupReader;
import eu.europa.ec.dynamicdiscovery.core.validator.OasisSmpSchemaValidator; import eu.europa.ec.dynamicdiscovery.core.validator.OasisSmpSchemaValidator;
import eu.europa.ec.dynamicdiscovery.exception.TechnicalException; import eu.europa.ec.dynamicdiscovery.exception.TechnicalException;
import eu.europa.ec.dynamicdiscovery.exception.XmlInvalidAgainstSchemaException; import eu.europa.ec.dynamicdiscovery.exception.XmlInvalidAgainstSchemaException;
...@@ -189,7 +189,7 @@ public class OasisSMPServiceGroup10Handler extends AbstractOasisSMPHandler { ...@@ -189,7 +189,7 @@ public class OasisSMPServiceGroup10Handler extends AbstractOasisSMPHandler {
throw new ResourceException(INVALID_RESOURCE, "Error occurred while validation Oasis SMP 1.0 ServiceGroup extension: [" + ids + "] with error: " + ExceptionUtils.getRootCauseMessage(e), e); throw new ResourceException(INVALID_RESOURCE, "Error occurred while validation Oasis SMP 1.0 ServiceGroup extension: [" + ids + "] with error: " + ExceptionUtils.getRootCauseMessage(e), e);
} }
// if service group // if service group
ServiceGroup serviceGroup = null; ServiceGroup serviceGroup;
try { try {
serviceGroup = reader.parseNative(new ByteArrayInputStream(bytearray)); serviceGroup = reader.parseNative(new ByteArrayInputStream(bytearray));
} catch (TechnicalException e) { } catch (TechnicalException e) {
......
package eu.europa.ec.smp.spi.handler; package eu.europa.ec.smp.spi.handler;
import eu.europa.ec.dynamicdiscovery.core.extension.impl.OasisSMP20ServiceGroupReader; import eu.europa.ec.dynamicdiscovery.core.extension.impl.oasis20.OasisSMP20ServiceGroupReader;
import eu.europa.ec.dynamicdiscovery.core.validator.OasisSmpSchemaValidator; import eu.europa.ec.dynamicdiscovery.core.validator.OasisSmpSchemaValidator;
import eu.europa.ec.dynamicdiscovery.exception.TechnicalException; import eu.europa.ec.dynamicdiscovery.exception.TechnicalException;
import eu.europa.ec.dynamicdiscovery.exception.XmlInvalidAgainstSchemaException; import eu.europa.ec.dynamicdiscovery.exception.XmlInvalidAgainstSchemaException;
...@@ -85,7 +85,7 @@ public class OasisSMPServiceGroup20Handler extends AbstractOasisSMPHandler { ...@@ -85,7 +85,7 @@ public class OasisSMPServiceGroup20Handler extends AbstractOasisSMPHandler {
LOG.warn("Empty document input stream for service-group [{}]!", identifier); LOG.warn("Empty document input stream for service-group [{}]!", identifier);
return; return;
} }
ServiceGroup serviceGroup = null; ServiceGroup serviceGroup;
try { try {
serviceGroup = reader.parseNative(resourceData.getResourceInputStream()); serviceGroup = reader.parseNative(resourceData.getResourceInputStream());
} catch (TechnicalException e) { } catch (TechnicalException e) {
...@@ -172,11 +172,11 @@ public class OasisSMPServiceGroup20Handler extends AbstractOasisSMPHandler { ...@@ -172,11 +172,11 @@ public class OasisSMPServiceGroup20Handler extends AbstractOasisSMPHandler {
OasisSmpSchemaValidator.validateOasisSMP20ServiceGroupSchema(bytearray); OasisSmpSchemaValidator.validateOasisSMP20ServiceGroupSchema(bytearray);
} catch (IOException | XmlInvalidAgainstSchemaException e) { } catch (IOException | XmlInvalidAgainstSchemaException e) {
String ids = identifier != null ? String ids = identifier != null ?
Stream.of(identifier).map(identifier1 -> identifier1.toString()).collect(Collectors.joining(",")) : ""; Stream.of(identifier).map(ResourceIdentifier::toString).collect(Collectors.joining(",")) : "";
throw new ResourceException(INVALID_RESOURCE, "Error occurred while validation Oasis SMP 2.0 ServiceGroup: [" + ids + "] with error: " + ExceptionUtils.getRootCauseMessage(e), e); throw new ResourceException(INVALID_RESOURCE, "Error occurred while validation Oasis SMP 2.0 ServiceGroup: [" + ids + "] with error: " + ExceptionUtils.getRootCauseMessage(e), e);
} }
// if service group // if service group
ServiceGroup serviceGroup = null; ServiceGroup serviceGroup;
try { try {
serviceGroup = reader.parseNative(new ByteArrayInputStream(bytearray)); serviceGroup = reader.parseNative(new ByteArrayInputStream(bytearray));
} catch (TechnicalException e) { } catch (TechnicalException e) {
......
package eu.europa.ec.smp.spi.handler; package eu.europa.ec.smp.spi.handler;
import eu.europa.ec.dynamicdiscovery.core.extension.impl.OasisSMP10ServiceMetadataReader; import eu.europa.ec.dynamicdiscovery.core.extension.impl.oasis10.OasisSMP10ServiceMetadataReader;
import eu.europa.ec.dynamicdiscovery.core.validator.OasisSmpSchemaValidator; import eu.europa.ec.dynamicdiscovery.core.validator.OasisSmpSchemaValidator;
import eu.europa.ec.dynamicdiscovery.exception.TechnicalException; import eu.europa.ec.dynamicdiscovery.exception.TechnicalException;
import eu.europa.ec.dynamicdiscovery.exception.XmlInvalidAgainstSchemaException; import eu.europa.ec.dynamicdiscovery.exception.XmlInvalidAgainstSchemaException;
...@@ -173,7 +173,7 @@ public class OasisSMPServiceMetadata10Handler extends AbstractOasisSMPHandler { ...@@ -173,7 +173,7 @@ public class OasisSMPServiceMetadata10Handler extends AbstractOasisSMPHandler {
throw new ResourceException(INVALID_RESOURCE, "Error occurred while validation Oasis SMP 1.0 ServiceMetadata: [" + identifier + "] with error: " + ExceptionUtils.getRootCauseMessage(e), e); throw new ResourceException(INVALID_RESOURCE, "Error occurred while validation Oasis SMP 1.0 ServiceMetadata: [" + identifier + "] with error: " + ExceptionUtils.getRootCauseMessage(e), e);
} }
ServiceMetadata serviceMetadata = null; ServiceMetadata serviceMetadata;
try { try {
serviceMetadata = (ServiceMetadata) reader.parseNative(new ByteArrayInputStream(bytearray)); serviceMetadata = (ServiceMetadata) reader.parseNative(new ByteArrayInputStream(bytearray));
} catch (TechnicalException e) { } catch (TechnicalException e) {
......
package eu.europa.ec.smp.spi.handler; package eu.europa.ec.smp.spi.handler;
import eu.europa.ec.dynamicdiscovery.core.extension.impl.OasisSMP20ServiceMetadataReader; import eu.europa.ec.dynamicdiscovery.core.extension.impl.oasis20.OasisSMP20ServiceMetadataReader;
import eu.europa.ec.dynamicdiscovery.core.validator.OasisSmpSchemaValidator; import eu.europa.ec.dynamicdiscovery.core.validator.OasisSmpSchemaValidator;
import eu.europa.ec.dynamicdiscovery.exception.TechnicalException; import eu.europa.ec.dynamicdiscovery.exception.TechnicalException;
import eu.europa.ec.dynamicdiscovery.exception.XmlInvalidAgainstSchemaException; import eu.europa.ec.dynamicdiscovery.exception.XmlInvalidAgainstSchemaException;
......
...@@ -13,18 +13,17 @@ ...@@ -13,18 +13,17 @@
package eu.europa.ec.smp.spi.converter; package eu.europa.ec.smp.spi.converter;
import eu.europa.ec.dynamicdiscovery.core.extension.impl.OasisSMP10ServiceGroupReader; import eu.europa.ec.dynamicdiscovery.core.extension.impl.oasis10.OasisSMP10ServiceGroupReader;
import eu.europa.ec.dynamicdiscovery.exception.BindException; import eu.europa.ec.dynamicdiscovery.exception.BindException;
import eu.europa.ec.smp.spi.testutils.XmlTestUtils; import eu.europa.ec.smp.spi.testutils.XmlTestUtils;
import gen.eu.europa.ec.ddc.api.smp10.ServiceGroup; import gen.eu.europa.ec.ddc.api.smp10.ServiceGroup;
import org.hamcrest.CoreMatchers; import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert; import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
/** /**
* Created by gutowpa on 11/04/2017. * Created by gutowpa on 11/04/2017.
...@@ -46,7 +45,7 @@ class ServiceGroupConverterTest { ...@@ -46,7 +45,7 @@ class ServiceGroupConverterTest {
ServiceGroup serviceGroup = testInstance.parseNative(new ByteArrayInputStream(inputDoc)); ServiceGroup serviceGroup = testInstance.parseNative(new ByteArrayInputStream(inputDoc));
//then //then
assertNotNull(serviceGroup); Assertions.assertNotNull(serviceGroup);
} }
...@@ -55,7 +54,7 @@ class ServiceGroupConverterTest { ...@@ -55,7 +54,7 @@ class ServiceGroupConverterTest {
//given //given
byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceGroupWithDOCTYPE.xml"); byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceGroupWithDOCTYPE.xml");
//when then //when then
BindException result = assertThrows(BindException.class, () -> testInstance.parseNative(new ByteArrayInputStream(inputDoc))); BindException result = Assertions.assertThrows(BindException.class, () -> testInstance.parseNative(new ByteArrayInputStream(inputDoc)));
MatcherAssert.assertThat(result.getCause().getMessage(), CoreMatchers.containsString("DOCTYPE is disallowed")); MatcherAssert.assertThat(result.getCause().getMessage(), CoreMatchers.containsString("DOCTYPE is disallowed"));
} }
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
package eu.europa.ec.smp.spi.converter; package eu.europa.ec.smp.spi.converter;
import eu.europa.ec.dynamicdiscovery.core.extension.impl.OasisSMP10ServiceMetadataReader; import eu.europa.ec.dynamicdiscovery.core.extension.impl.oasis10.OasisSMP10ServiceMetadataReader;
import eu.europa.ec.dynamicdiscovery.exception.BindException; import eu.europa.ec.dynamicdiscovery.exception.BindException;
import eu.europa.ec.smp.spi.testutils.XmlTestUtils; import eu.europa.ec.smp.spi.testutils.XmlTestUtils;
import gen.eu.europa.ec.ddc.api.smp10.RedirectType; import gen.eu.europa.ec.ddc.api.smp10.RedirectType;
...@@ -22,16 +22,14 @@ import gen.eu.europa.ec.ddc.api.smp10.ServiceInformationType; ...@@ -22,16 +22,14 @@ import gen.eu.europa.ec.ddc.api.smp10.ServiceInformationType;
import gen.eu.europa.ec.ddc.api.smp10.ServiceMetadata; import gen.eu.europa.ec.ddc.api.smp10.ServiceMetadata;
import org.hamcrest.CoreMatchers; import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert; import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
...@@ -43,13 +41,10 @@ public class ServiceMetadataConverterTest { ...@@ -43,13 +41,10 @@ public class ServiceMetadataConverterTest {
private static final String NS = "http://docs.oasis-open.org/bdxr/ns/SMP/2016/05"; private static final String NS = "http://docs.oasis-open.org/bdxr/ns/SMP/2016/05";
private static final String RES_PATH = "/examples/oasis-smp-1.0/"; private static final String RES_PATH = "/examples/oasis-smp-1.0/";
@Rule
public ExpectedException expectedExeption = ExpectedException.none();
OasisSMP10ServiceMetadataReader testInstance = new OasisSMP10ServiceMetadataReader(); OasisSMP10ServiceMetadataReader testInstance = new OasisSMP10ServiceMetadataReader();
@Test @Test
public void testUnmarshalServiceInformation() throws Exception { void testUnmarshalServiceInformation() throws Exception {
//given //given
byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithServiceOk.xml"); byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithServiceOk.xml");
...@@ -69,7 +64,7 @@ public class ServiceMetadataConverterTest { ...@@ -69,7 +64,7 @@ public class ServiceMetadataConverterTest {
} }
@Test @Test
public void testUnmarshalServiceInformationUtf8() throws Exception { void testUnmarshalServiceInformationUtf8() throws Exception {
//given //given
byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithServiceInformationUtf8.xml"); byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithServiceInformationUtf8.xml");
...@@ -83,7 +78,7 @@ public class ServiceMetadataConverterTest { ...@@ -83,7 +78,7 @@ public class ServiceMetadataConverterTest {
} }
@Test @Test
public void testUnmarshalRedirect() throws Exception { void testUnmarshalRedirect() throws Exception {
//given //given
byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithRedirect.xml"); byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithRedirect.xml");
...@@ -100,7 +95,7 @@ public class ServiceMetadataConverterTest { ...@@ -100,7 +95,7 @@ public class ServiceMetadataConverterTest {
} }
@Test @Test
public void testUnmarshalMalformedInput() throws Exception { void testUnmarshalMalformedInput() {
byte[] inputDoc ="this is malformed XML body".getBytes(); byte[] inputDoc ="this is malformed XML body".getBytes();
...@@ -110,7 +105,7 @@ public class ServiceMetadataConverterTest { ...@@ -110,7 +105,7 @@ public class ServiceMetadataConverterTest {
} }
@Test @Test
public void testInvalidDocumentNamespace() throws Exception { void testInvalidDocumentNamespace() throws Exception {
//given //given
byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataMissingMandatoryFields.xml"); byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataMissingMandatoryFields.xml");
//when then //when then
...@@ -119,7 +114,7 @@ public class ServiceMetadataConverterTest { ...@@ -119,7 +114,7 @@ public class ServiceMetadataConverterTest {
} }
@Test @Test
public void testToSignedServiceMetadataDocument() throws Exception { void testToSignedServiceMetadataDocument() throws Exception {
//given //given
byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithServiceOk.xml"); byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithServiceOk.xml");
...@@ -139,7 +134,7 @@ public class ServiceMetadataConverterTest { ...@@ -139,7 +134,7 @@ public class ServiceMetadataConverterTest {
} }
@Test @Test
public void testVulnerabilityParsingDTD() throws Exception { void testVulnerabilityParsingDTD() throws Exception {
byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithDOCTYPE.xml"); byte[] inputDoc = XmlTestUtils.loadDocumentAsByteArray(RES_PATH + "ServiceMetadataWithDOCTYPE.xml");
......
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