Skip to content

Commit

Permalink
ALFREDAPI-563-get-content [Update] Fix @GetMapping(value = "/v1/nodes…
Browse files Browse the repository at this point in the history
…/{space}/{store}/{guid}/content") Content-Type

  * Add integration-test check for content-type.
  • Loading branch information
codingBenVdS committed Nov 22, 2024
1 parent 33e3ac8 commit 457f78a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Alfred API - Changelog

* [ALFREDAPI-563](https://xenitsupport.jira.com/browse/ALFREDAPI-563) Fix @GetMapping(value = "/v1/nodes/{space}/{store}/{guid}/content") Content-Type


## 6.0.0 (2024-08-22)
From this version onward Dynamic Extensions for integration-testing is replaced by [remote-junit](https://github.com/ruediste/remote-junit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,31 @@ public void testSetNodeContent() {
}
}, false, true);
assertEquals("This is the content", content);

String contentHeader = transactionService.getRetryingTransactionHelper()
.doInTransaction(() -> {
ContentInputStream c = ns.getContent(nodeRef);
return c.getMimetype();
}, false, true);
assertEquals("text/plain", contentHeader);

// Test the Content-Header of the set file via GET method.
transactionService.getRetryingTransactionHelper()
.doInTransaction(() -> {
HttpGet httpGet = new HttpGet(url);

try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
assertEquals(200, response.getStatusLine().getStatusCode());
InputStream inputStream = response.getEntity().getContent();
assertEquals("This is the content",
IOUtils.toString(inputStream, Charset.defaultCharset()));
ContentInputStream c = ns.getContent(nodeRef);
assertEquals("text/plain",
c.getMimetype());
inputStream.close();
}
return null;
}, false, true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ public ResponseEntity<?> getContent(@PathVariable String space, @PathVariable St
return writeNotFoundResponse(nodeRef);
}
return ResponseEntity.ok()
.header("Content-Type", contentInputStream.getMimetype())
.body(new InputStreamResource(contentInputStream.getInputStream()));
}

Expand Down

0 comments on commit 457f78a

Please sign in to comment.