use of com.helger.phase4.messaging.domain.AS4UserMessage in project phase4 by phax.
the class UserMessageFailureForgeryTest method testWrongAttachmentIDShouldFail.
@Test
public void testWrongAttachmentIDShouldFail() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_XML_GZ)).mimeType(CMimeType.APPLICATION_GZIP).build(), s_aResMgr));
final AS4UserMessage aMsg = MockMessages.createUserMessageNotSigned(m_eSoapVersion, null, aAttachments);
final Document aDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aMsg.getAsSoapDocument(), m_eSoapVersion, aMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault());
final NodeList nList = aDoc.getElementsByTagName("eb:PartInfo");
for (int i = 0; i < nList.getLength(); i++) {
final Node nNode = nList.item(i);
final Element aElement = (Element) nNode;
if (aElement.hasAttribute("href"))
aElement.setAttribute("href", MessageHelperMethods.PREFIX_CID + "invalid" + i);
}
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aDoc, aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Aggregations