use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class AS4eSENSCEFOneWayFuncTest method testEsens_TA03.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile: One-Way/Push MEP. SMSH and RMSH exchange several AS4 User
* Messages.<br>
* <br>
* Predicate: <br>
* Each exchanged AS4 message contains single ORIGIN and DESTINATION elements.
* <br>
* Goal: "Both UserMessage/PartyInfo/From and UserMessage/PartyInfo/To must
* not include more than one PartyId element"
*
* @throws Exception
* In case of error
*/
@Test
public void testEsens_TA03() throws Exception {
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(m_aPayload != null, null);
final Ebms3CollaborationInfo aEbms3CollaborationInfo;
final Ebms3PartyInfo aEbms3PartyInfo;
aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(m_aESENSOneWayPMode.getID(), DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, AS4TestConstants.CEF_INITIATOR_ID, CAS4.DEFAULT_RESPONDER_URL, AS4TestConstants.CEF_RESPONDER_ID);
aEbms3PartyInfo.getTo().addPartyId(MessageHelperMethods.createEbms3PartyId("Second ID"));
// Check if we added a second party id
assertTrue(aEbms3PartyInfo.getTo().getPartyId().size() == 2);
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
aUserMessage.setPartyInfo(aEbms3PartyInfo);
aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
aUserMessage.setMessageProperties(aEbms3MessageProperties);
aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
aUserMessage.setMessageInfo(aEbms3MessageInfo);
final Document aDoc = new AS4UserMessage(ESoapVersion.AS4_DEFAULT, aUserMessage).getAsSoapDocument(m_aPayload);
sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class UserMessageSoapBodyPayloadTest method testUserMessageSOAPBodyPayloadSignedSuccess.
@Test
public void testUserMessageSOAPBodyPayloadSignedSuccess() throws Exception {
final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
final Document aDoc = MockMessages.createUserMessageSigned(m_eSoapVersion, aPayload, aAttachments, s_aResMgr);
final String sResponse = sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
assertTrue(sResponse.contains(ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI()));
assertTrue(sResponse.contains(ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI()));
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class UserMessageSoapBodyPayloadTest method testUserMessageSOAPBodyPayloadSignedEncryptedSuccess.
@Test
public void testUserMessageSOAPBodyPayloadSignedEncryptedSuccess() throws Exception {
final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
Document aDoc = MockMessages.createUserMessageSigned(m_eSoapVersion, aPayload, aAttachments, s_aResMgr);
aDoc = AS4Encryptor.encryptSoapBodyPayload(m_aCryptoFactory, m_eSoapVersion, aDoc, false, m_aCryptParams);
final String sResponse = sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
assertTrue(sResponse.contains(ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI()));
assertTrue(sResponse.contains(ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI()));
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class CEFProfileTest method testUserMessageFinalRecipientButNoOriginalSender.
@Test
public void testUserMessageFinalRecipientButNoOriginalSender() throws Exception {
final Ebms3MessageProperties aEbms3MessageProperties = new Ebms3MessageProperties();
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
aEbms3Properties.removeIf(x -> x.getName().equals(CAS4.ORIGINAL_SENDER));
assertEquals(1, aEbms3Properties.size());
aEbms3Properties.add(_createRandomProperty());
aEbms3MessageProperties.setProperty(aEbms3Properties);
m_aEbms3UserMessage.setMessageProperties(aEbms3MessageProperties);
final Document aDoc = AS4UserMessage.create(m_eSoapVersion, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, "'originalSender' property is empty or not existant but mandatory");
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class CEFProfileTest method testUserMessageOriginalSenderButNoFinalRecipient.
@Test
public void testUserMessageOriginalSenderButNoFinalRecipient() throws Exception {
final Ebms3MessageProperties aEbms3MessageProperties = new Ebms3MessageProperties();
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
aEbms3Properties.removeIf(x -> x.getName().equals(CAS4.FINAL_RECIPIENT));
assertEquals(1, aEbms3Properties.size());
aEbms3Properties.add(_createRandomProperty());
aEbms3MessageProperties.setProperty(aEbms3Properties);
m_aEbms3UserMessage.setMessageProperties(aEbms3MessageProperties);
final Document aDoc = AS4UserMessage.create(m_eSoapVersion, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, "'finalRecipient' property is empty or not existant but mandatory");
}
Aggregations