mCode = ResultCode.INVALID_CHARACTER_DETECT_IN_SERVER; if (xmlParser.isVirusException()) { mCode = ResultCode.VIRUS_DETECTED; mHttpPhrase = xmlParser.getMessage();
@Test public void testInvalidCharacterException() throws IOException, XmlPullParserException { String virusException = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<d:error xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\">\n" + " <s:exception>OC\\Connector\\Sabre\\Exception\\InvalidPath</s:exception>\n" + " <s:message>Wrong Path</s:message>\n" + "</d:error>"; InputStream is = new ByteArrayInputStream(virusException.getBytes()); ExceptionParser xmlParser = new ExceptionParser(is); Assert.assertTrue(xmlParser.isInvalidCharacterException()); Assert.assertFalse(xmlParser.isVirusException()); }
@Test public void testEmptyString() throws IOException, XmlPullParserException { String emptyString = ""; InputStream is = new ByteArrayInputStream(emptyString.getBytes()); ExceptionParser xmlParser = new ExceptionParser(is); Assert.assertFalse(xmlParser.isVirusException()); Assert.assertFalse(xmlParser.isInvalidCharacterException()); }
@Test public void testString() throws IOException, XmlPullParserException { String emptyString = ""; InputStream is = new ByteArrayInputStream(emptyString.getBytes()); ExceptionParser xmlParser = new ExceptionParser(is); Assert.assertFalse(xmlParser.isVirusException()); Assert.assertFalse(xmlParser.isInvalidCharacterException()); } }
@Test public void testInvalidCharacterUploadException() throws IOException, XmlPullParserException { String virusException = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<d:error xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\">\n" + " <s:exception>OCP\\Files\\InvalidPathException</s:exception>\n" + " <s:message>Wrong Path</s:message>\n" + "</d:error>"; InputStream is = new ByteArrayInputStream(virusException.getBytes()); ExceptionParser xmlParser = new ExceptionParser(is); Assert.assertTrue(xmlParser.isInvalidCharacterException()); Assert.assertFalse(xmlParser.isVirusException()); }
@Test public void testVirusException() throws IOException, XmlPullParserException { String virusException = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<d:error xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\">\n" + " <s:exception>OCA\\DAV\\Connector\\Sabre\\Exception\\UnsupportedMediaType" + "</s:exception>\n" + " <s:message>Virus Eicar-Test-Signature is detected in the file. " + "Upload cannot be completed.</s:message>\n" + "</d:error>"; InputStream is = new ByteArrayInputStream(virusException.getBytes()); ExceptionParser xmlParser = new ExceptionParser(is); Assert.assertTrue(xmlParser.isVirusException()); Assert.assertFalse(xmlParser.isInvalidCharacterException()); }