use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class SignatureTests method setupMock.
private MockEndpoint setupMock() {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived(payload);
return mock;
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class PGPDataFormatTest method testExceptionDecryptorIncorrectInputFormatPGPSignedData.
@Test
public void testExceptionDecryptorIncorrectInputFormatPGPSignedData() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
createSignature(bos);
MockEndpoint mock = getMockEndpoint("mock:exception");
mock.expectedMessageCount(1);
template.sendBody("direct:subkeyUnmarshal", bos.toByteArray());
assertMockEndpointsSatisfied();
checkThrownException(mock, IllegalArgumentException.class, null, "The input message body has an invalid format.");
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class PGPDataFormatTest method testExceptionDecryptorIncorrectInputFormatNoPGPMessage.
@Test
public void testExceptionDecryptorIncorrectInputFormatNoPGPMessage() throws Exception {
String payload = "Not Correct Format";
MockEndpoint mock = getMockEndpoint("mock:exception");
mock.expectedMessageCount(1);
template.sendBody("direct:subkeyUnmarshal", payload);
assertMockEndpointsSatisfied();
checkThrownException(mock, IllegalArgumentException.class, null, "The input message body has an invalid format.");
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class PGPDataFormatTest method testVerifyExceptionNoPassphraseSpecifiedForSignatureKeyUserId.
@Test
public void testVerifyExceptionNoPassphraseSpecifiedForSignatureKeyUserId() throws Exception {
MockEndpoint exception = setupExpectations(context, 1, "mock:exception");
String payload = "Hi Alice, Be careful Eve is listening, signed Bob";
Map<String, Object> headers = new HashMap<String, Object>();
// add signature user id which does not have a passphrase
headers.put(PGPKeyAccessDataFormat.SIGNATURE_KEY_USERID, "userIDWithNoPassphrase");
// the following entry is necessary for the dynamic test
headers.put(PGPKeyAccessDataFormat.KEY_USERID, "second");
template.sendBodyAndHeaders("direct:several-signer-keys", payload, headers);
assertMockEndpointsSatisfied();
checkThrownException(exception, IllegalArgumentException.class, null, "No passphrase specified for signature key user ID");
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class PGPDataFormatTest method testExceptionForSignatureVerificationOptionNoSignatureAllowed.
@Test
public void testExceptionForSignatureVerificationOptionNoSignatureAllowed() throws Exception {
decryptor.setSignatureVerificationOption(PGPKeyAccessDataFormat.SIGNATURE_VERIFICATION_OPTION_NO_SIGNATURE_ALLOWED);
MockEndpoint mock = getMockEndpoint("mock:exception");
mock.expectedMessageCount(1);
template.sendBody("direct:subkey", "Test Message");
assertMockEndpointsSatisfied();
checkThrownException(mock, PGPException.class, null, "PGP message contains a signature although a signature is not expected");
}
Aggregations