Skip to content

Commit

Permalink
cadc-test-vos: allow 200 or 201 after put to negotiated transfer URL
Browse files Browse the repository at this point in the history
cavern: added missing set content-type prop in PutAction
  • Loading branch information
pdowler committed Dec 18, 2023
1 parent dcc9d6e commit d596c7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import java.net.URI;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -111,6 +112,8 @@
public class TransferTest extends VOSTest {
private static final Logger log = Logger.getLogger(TransferTest.class);

private static final List<Integer> PUT_OK = Arrays.asList(new Integer[] { 200, 201});

protected TransferTest(URI resourceID, File testCert) {
super(resourceID, testCert);
}
Expand Down Expand Up @@ -165,7 +168,7 @@ public void syncPushPullTest() {
HttpUpload put = new HttpUpload(content, putURL);
put.run();
log.info("put: " + put.getResponseCode() + " " + put.getThrowable());
Assert.assertEquals(201, put.getResponseCode());
Assert.assertTrue(PUT_OK.contains(put.getResponseCode()));
Assert.assertNull(put.getThrowable());

// Create a pull-from-vospace Transfer for the node
Expand Down Expand Up @@ -202,7 +205,7 @@ public void syncPushPullTest() {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
HttpGet get = new HttpGet(getURL, bos);
get.run();
log.info("get: " + get.getResponseCode() + " " + get.getThrowable());
log.info("get: " + get.getResponseCode() + " " + get.getContentType() + " " + get.getThrowable());
Assert.assertEquals(200, get.getResponseCode());
Assert.assertNull(get.getThrowable());
Assert.assertEquals(content.getBytes().length, get.getContentLength());
Expand Down
11 changes: 11 additions & 0 deletions cavern/src/main/java/org/opencadc/cavern/files/PutAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@ public void doAction() throws Exception {
csp.setValue(actualMD5.toASCIIString());
}
}
// set/update content-type attr
String contentType = syncInput.getHeader("content-type");
if (contentType != null) {
NodeProperty ctp = node.getProperty(VOS.PROPERTY_URI_TYPE);
if (ctp == null) {
ctp = new NodeProperty(VOS.PROPERTY_URI_TYPE, contentType);
node.getProperties().add(ctp);
} else {
ctp.setValue(contentType);
}
}

nodePersistence.put(node);
successful = true;
Expand Down

0 comments on commit d596c7b

Please sign in to comment.