use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class PModeCheckTest method testPModeWrongMPC.
@Test
public void testPModeWrongMPC() throws Exception {
final PMode aPMode = MockPModeGenerator.getTestPMode(SOAP_VERSION);
aPMode.getLeg1().getBusinessInfo().setMPCID("wrongmpc-id");
final IPModeManager aPModeMgr = MetaAS4Manager.getPModeMgr();
try {
for (final String sPModeID : aPModeMgr.getAllIDs()) {
aPModeMgr.deletePMode(sPModeID);
}
assertTrue(aPModeMgr.getAllIDs().isEmpty());
aPModeMgr.createOrUpdatePMode(aPMode);
// Needed since different ids set in message and pmode otherwise
m_aEbms3UserMessage.setCollaborationInfo(MessageHelperMethods.createEbms3CollaborationInfo(aPMode.getInitiatorID() + "-" + aPMode.getResponderID(), DEFAULT_AGREEMENT, null, CAS4.DEFAULT_SERVICE_URL, CAS4.DEFAULT_ACTION_URL, AS4TestConstants.TEST_CONVERSATION_ID));
final Document aSignedDoc = AS4UserMessage.create(SOAP_VERSION, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
sendPlainMessageAndWait(new HttpXMLEntity(aSignedDoc, SOAP_VERSION.getMimeType()), false, EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getErrorCode());
} finally {
// The MockPModeGenerator generates automatically a PMode, we need
// too delete it after we are done with the test
MetaAS4Manager.getPModeMgr().deletePMode(aPMode.getID());
aPModeMgr.deletePMode(aPMode.getID());
}
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class PModeCheckTest method testWrongMPCShouldReturnFailure.
@Test
public void testWrongMPCShouldReturnFailure() throws Exception {
m_aEbms3UserMessage.setMpc("http://random.com/testmpc");
final Document aDoc = AS4UserMessage.create(SOAP_VERSION, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
sendPlainMessageAndWait(new HttpXMLEntity(aDoc, SOAP_VERSION.getMimeType()), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class PModeCheckTest method testPModeLegProtocolAddressReject.
/**
* Is ESENS specific, EBMS3 specification is the protocol an optional element.
* Maybe refactoring into a test if http and SMTP addresses later on get
* converted right
*
* @throws Exception
* In case of an error
*/
@Test
@Ignore("The PMode leg protocol address is curently not used, therefore the wrong address never pops up")
public void testPModeLegProtocolAddressReject() throws Exception {
final String sInvalidPModeID = "pmode-" + GlobalIDFactory.getNewPersistentIntID();
final PMode aPMode = MockPModeGenerator.getTestPMode(SOAP_VERSION);
aPMode.setLeg1(new PModeLeg(PModeLegProtocol.createForDefaultSoapVersion("TestsimulationAddressWrong"), null, null, null, null));
final IPModeManager aPModeMgr = MetaAS4Manager.getPModeMgr();
try {
aPModeMgr.createOrUpdatePMode(aPMode);
final Wrapper<String> aMsgID = new Wrapper<>();
final Document aDoc = modifyUserMessage(sInvalidPModeID, null, null, createDefaultProperties(), null, null, x -> aMsgID.set(x));
final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aDoc, SOAP_VERSION, aMsgID.get(), null, s_aResMgr, false, AS4SigningParams.createDefault());
sendPlainMessageAndWait(new HttpXMLEntity(aSignedDoc, SOAP_VERSION.getMimeType()), false, EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getErrorCode());
} finally {
aPModeMgr.deletePMode(aPMode.getID());
}
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class PModeCheckTest method testUserMessageMissingProperties.
@Test
public void testUserMessageMissingProperties() throws Exception {
m_aEbms3UserMessage.setMessageProperties(null);
final Document aDoc = AS4UserMessage.create(SOAP_VERSION, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
sendPlainMessageAndWait(new HttpXMLEntity(aDoc, SOAP_VERSION.getMimeType()), false, "");
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class PModeCheckTest method testNoResponderInMessageInvalidShouldReturnErrorMessage.
@Test
public void testNoResponderInMessageInvalidShouldReturnErrorMessage() throws Exception {
final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
// never forget this!
domFactory.setNamespaceAware(true);
final DocumentBuilder builder = domFactory.newDocumentBuilder();
final Document aDoc = builder.parse(new ClassPathResource("testfiles/NoResponder.xml").getInputStream());
sendPlainMessageAndWait(new HttpXMLEntity(aDoc, SOAP_VERSION.getMimeType()), false, EEbmsError.EBMS_INVALID_HEADER.getErrorCode());
}
Aggregations