Skip to content
Snippets Groups Projects
Commit 985c6f5f authored by Martin Vogel's avatar Martin Vogel
Browse files

fix: add missed test that was removed on the laste merge

parent 7872148a
No related branches found
No related tags found
No related merge requests found
......@@ -357,6 +357,58 @@ class SubscriberClientTest {
assertThat(receivedSubmission.getSubmissionMetadata().getContentStructure().getData().getHash().getContent(), is("bla"));
}
@Test
void testUnknownAdditionalReferenceInfoProperty() throws JsonProcessingException {
final var dataPayload = "{ some : 'data foo' }";
final var submissionId = UUID.randomUUID();
final CryptoService cryptoService = new JWECryptoService(new HashService());
final Map<String, Map<String, Object>> metadata = Map.of(
"contentStructure", Map.of(
"data", Map.of(
"hash", Map.of(
"type", SignatureType.SHA_512,
"content", cryptoService.hashBytes(dataPayload.getBytes())
),
"submissionSchema", Map.of(
"schemaUri", URI.create("https://dummy.schema.url"),
"mimeType", MimeType.APPLICATION_JSON
)
),
"attachments", Collections.EMPTY_LIST),
"additionalReferenceInfo", Map.of(
"x-sender", "SOME_ADDITIONAL_UNKNOWN_PROPERTY",
"senderReference", "sender_123")
);
final byte[] metadataBytes = mapper.writeValueAsBytes(metadata);
final RSAKey encryptionKey = privateKey;
final RSAKey decryptionKey = encryptionKey.toPublicJWK();
final String encryptedData = cryptoService.encryptString(decryptionKey, dataPayload);
final String encryptedMetadata = cryptoService.encryptBytes(decryptionKey, metadataBytes);
final var submission = new Submission();
submission.setSubmissionId(submissionId);
submission.setEncryptedData(encryptedData);
submission.setEncryptedMetadata(encryptedMetadata);
when(subscriberMock.getSubmission(any())).thenReturn(submission);
when(subscriberMock.validateMetadata(any())).thenReturn(ValidationResult.ok());
when(subscriberMock.validateHashIntegrity(any(), any())).thenReturn(ValidationResult.ok());
when(subscriberMock.decryptStringContent(encryptionKey, submission.getEncryptedData())).thenReturn(dataPayload.getBytes());
when(subscriberMock.decryptStringContent(encryptionKey, submission.getEncryptedMetadata())).thenReturn(metadataBytes);
// When
final var receivedSubmission = underTest.requestSubmission(submissionId);
// Then
assertNotNull(receivedSubmission.getSubmissionMetadata());
assertThat(receivedSubmission.getSubmissionMetadata().getAdditionalReferenceInfo().getSenderReference(), is("sender_123"));
}
@Test
void testCorruptedData() throws JsonProcessingException {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment