@Test( expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Only non-negative integer values are allowed") public void testCreateAggregationRequestWithNegativeLevel_ThrowsNullPointerException() throws Exception { pduFactory.createAggregationRequest(requestContext, dataHash, -42L); }
@Test( expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = ".*\\(404\\):Response error 404: Not found") public void testExtensionResponseWithError() throws Exception { pduFactory.readExtensionResponse( extensionContext, loadTlv("pdu/extension/extension-response-v1-header-error.tlv")); }
@Test( expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "DataHash can not be null") public void testCreateAggregationRequestWithoutDataHash_ThrowsNullPointerException() throws Exception { pduFactory.createAggregationRequest(requestContext, null, DEFAULT_LEVEL); }
@Test( expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = "Received PDU v2 response to PDU v1 request. Configure the SDK to use PDU v2 format for the given Extender") public void testReadV2ExtensionResponse() throws Exception { pduFactory.readExtensionResponse( extensionContext, loadTlv("pdu/extension/extension-response-v2-with-error.tlv")); }
@Test( expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = ".*request IDs do not match, sent \\'[0-9]+\\' received \\'4321\\'") public void testExtensionRequestIdsMismatch() throws Exception { pduFactory.readExtensionResponse( extensionContext, loadTlv("pdu/extension/extension-response-v1-ok-request-id-4321.tlv")); }
@Test( expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = ".*\\(404\\):Not found") public void testExtensionRequest404ErrorWithResponse() throws Exception { pduFactory.readExtensionResponse( new KSIRequestContext(new KSIServiceCredentials("anon", "anon"), 4321L, 42L, 42L), loadTlv("pdu/extension/extension-response-v1-with-error-payload.tlv")); }
@Test( expectedExceptions = InvalidMessageAuthenticationCodeException.class, expectedExceptionsMessageRegExp = "Invalid MAC code. Expected.*") public void testExtensionResponseInvalidHMAC_ThrowsInvalidMessageAuthenticationCodeException() throws Exception { pduFactory.readExtensionResponse( extensionContext, loadTlv("pdu/extension/extension-response-v1-invalid-hmac.tlv")); }
@Test( expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = ".*\\(5\\):Response error 5: Invalid request format") public void testAggregationResponseContains203ErrorMessage_ThrowsKSIProtocolException() throws Exception { pduFactory.readAggregationResponse( requestContext, loadTlv("pdu/aggregation/aggregation-response-v1-203-error.tlv")); }
@Test( expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = ".*request IDs do not match, sent .* received .*") public void testAggregationResponseContainsInvalidRequestId_ThrowsKSIProtocolException() throws Exception { pduFactory.readAggregationResponse( new KSIRequestContext(new KSIServiceCredentials("anon", "anon"), 1L, 42L, 42L), loadTlv("pdu/aggregation/aggregation-response-v1.tlv")); }
@Test( expectedExceptions = InvalidMessageAuthenticationCodeException.class, expectedExceptionsMessageRegExp = "Invalid MAC code. Expected.*") public void testAggregationResponseContainsInvalidMac_ThrowsInvalidMessageAuthenticationCodeException() throws Exception { pduFactory.readAggregationResponse( requestContext, loadTlv("pdu/aggregation/aggregation-response-v1-invalid-mac.tlv")); }
@Test( expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = ".*Response message does not contain response payload element") public void testExtensionResponseEmpty() throws Exception { pduFactory.readExtensionResponse( extensionContext, loadTlv("pdu/extension/extension-response-v1-missing-response-payload.tlv")); }
@Test( expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = ".*\\(769\\):Server error") public void testAggregationResponseContainsErrorMessageInside202TLVMessage_ThrowsKSIProtocolException() throws Exception { pduFactory.readAggregationResponse( requestContext, loadTlv("pdu/aggregation/aggregation-response-v1-202-error.tlv")); }
@Test( expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = ".*Response message does not contain response payload element") public void testAggregationResponseDoesNotContainResponseTlvTag_ThrowsKSIProtocolException() throws Exception { pduFactory.readAggregationResponse( requestContext, loadTlv("pdu/aggregation/aggregation-response-v1-missing-response-tag.tlv")); }
@Test public void testCreateAggregationRequest_Ok() throws Exception { AggregationRequest request = pduFactory.createAggregationRequest(requestContext, dataHash, DEFAULT_LEVEL); Assert.assertNotNull(request); }