use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class UserMessageOneAttachmentTest method testUserMessageOneAttachmentSignedMimeSuccess.
@Test
public void testUserMessageOneAttachmentSignedMimeSuccess() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML)).mimeTypeXML().build(), s_aResMgr));
final AS4UserMessage aMsg = MockMessages.createUserMessageNotSigned(m_eSOAPVersion, null, aAttachments);
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSOAPVersion, AS4Signer.createSignedMessage(m_aCryptoFactory, aMsg.getAsSoapDocument(), m_eSOAPVersion, aMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault()), aAttachments);
final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
assertTrue(sResponse.contains(ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI()));
assertTrue(sResponse.contains(ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI()));
}
use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class TwoWayMEPTest method testReceiveUserMessageWithMimeAsResponseSuccess.
@Test
public void testReceiveUserMessageWithMimeAsResponseSuccess() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML)).mimeTypeXML().build(), s_aResMgr));
final Document aDoc = modifyUserMessage(m_aPMode.getID(), (String) null, // Alias for encryption
"ph-as4", createDefaultProperties(), aAttachments, null, null);
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aDoc, aAttachments);
final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
assertTrue(sResponse.contains(AS4TestConstants.USERMESSAGE_ASSERTCHECK));
assertFalse(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
assertTrue(sResponse.contains(m_aPMode.getLeg2().getSecurity().getX509SignatureAlgorithm().getAlgorithmURI()));
// Checking if he adds the attachment to the response message, the mock spi
// just adds the xml that gets sent in the original message and adds it to
// the response
assertTrue(sResponse.contains(m_aPMode.getLeg2().getSecurity().getX509EncryptionAlgorithm().getAlgorithmURI()));
}
use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class AS4CEFOneWayFuncTest method testAS4_TA15.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile (One-Way/Push MEP). SMSH sends an AS4 User Message with a
* compressed payload to the RMSH.<br>
* <br>
* Predicate: <br>
* The RMSH delivers the message with decompressed payload to the consumer.
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA15() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
final Document aDoc = createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr);
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aDoc, aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
// How to check message if it is decompressed hmm?
}
use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class AS4CEFOneWayFuncTest method testAS4_TA18.
/**
* Prerequisite:<br>
* eSENS_TA13<br>
* Simulated SMSH sends a signed AS4 User Message with a signed then
* compressed payload to the RMSH.<br>
* <br>
* Predicate: <br>
* The SMSH receives a WS-Security SOAP Fault.
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA18() throws Exception {
// signed then compressed
// Should return an error because the uncompressed attachment was signed and
// not the compressed one
ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().build(), s_aResMgr));
final Document aDoc = createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr);
aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aDoc, aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class UserMessageCompressionTest method testUserMessageWithCompressedAttachmentSuccessful.
@Category(IHolodeckTests.class)
@Test
public void testUserMessageWithCompressedAttachmentSuccessful() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSOAPVersion, MockMessages.createUserMessageNotSigned(m_eSOAPVersion, null, aAttachments).getAsSoapDocument(), aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
}
Aggregations