package manage.validations;

import manage.TestUtils;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class XMLFormatValidatorTest implements TestUtils {

    private XMLFormatValidator subject = new XMLFormatValidator();

    @Test
    public void validate() throws Exception {
        assertTrue(subject.validate("nope").isPresent());
        assertFalse(subject.validate(readFile("/xml/expected_metadata_export_saml20_sp.xml")).isPresent());
    }

}
@@ -106,62 +106,9 @@
 ert.
-assertFalse;%0Aimport static org.junit.Assert.assertTrue
+*
 ;%0A%0Ap
@@ -344,24 +344,24 @@
 Present());%0A
-
         asse
@@ -463,9 +463,582 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void validateWithXxe() %7B%0A        String xxe = %22%3C?xml version=%5C%221.0%5C%22 encoding=%5C%22ISO-8859-1%5C%22?%3E%5Cn%22 +%0A                %22%3C!DOCTYPE foo %5B%5Cn%22 +%0A                %22  %3C!ELEMENT foo ANY %3E%5Cn%22 +%0A                %22  %3C!ENTITY xxe SYSTEM %5C%22http://www.attacker.com/text.txt%5C%22 %3E%5D%3E%5Cn%22 +%0A                %22%3Cfoo%3E&xxe;%3C/foo%3E%22;%0A%0A        String result = subject.validate(xxe).orElse(null);%0A%0A        assertNotNull(result);%0A        assertTrue(result.contains(%22DOCTYPE is disallowed when the feature %5C%22http://apache.org/xml/features/disallow-doctype-decl%5C%22 set to true.%22));%0A    %7D%0A%0A
 %7D

Resolve XXE vulnerability in XML validation - add test