Exemplo n.º 1
0
 @Test
 public void setDeleteAt() throws IOException, DateParseException {
   expectStatusCode(202, false);
   prepareMetadata();
   final Date date = DateUtils.parseDate("Mon, 03 Sep 2001 05:40:33 GMT");
   object.setDeleteAt(date);
   verifyHeaderValue(Long.toString(date.getTime() / 1000), X_DELETE_AT, "POST");
 }
Exemplo n.º 2
0
 protected void prepareBytes(byte[] bytes, String md5) {
   expectStatusCode(200, false);
   prepareHeader(
       response,
       AbstractDownloadObjectCommand.ETAG,
       md5 == null ? DigestUtils.md5Hex(bytes) : md5);
   prepareHeader(
       response, AbstractDownloadObjectCommand.CONTENT_LENGTH, Long.toString(bytes.length));
   httpEntity = new ByteArrayEntity(bytes);
   new NonStrictExpectations() {
     {
       response.getEntity();
       result = httpEntity;
     }
   };
 }
Exemplo n.º 3
0
  protected void testTempUrl(final String method, final LocalTime localTime) {
    final String password = "******";
    final long todayInMS = 1369581129861L;
    final long oneDayInSeconds = 86400L;
    final long tomorrowInSeconds = todayInMS / 1000 + oneDayInSeconds;

    final AbstractStoredObject object = createStoredObjectForTempURL(password);
    // Make sure that a fixed date is used
    useFixedDateForToday(todayInMS);
    // Check whether the secure URL contains the right signature and expiry date
    final String secureUrl;
    if (method.equals("GET")) {
      secureUrl = object.getTempGetUrl(oneDayInSeconds);
    } else {
      secureUrl = object.getTempPutUrl(oneDayInSeconds);
    }
    assertTrue(
        "Does not contain the timestamp of 'tomorrow'",
        secureUrl.contains(Long.toString(tomorrowInSeconds)));
    String plainText = method + "\n" + tomorrowInSeconds + "\n/internal/path/alpha/some-image.jpg";
    String signature = HashSignature.getSignature(password, plainText);
    assertTrue("The signature of the secure URL", secureUrl.contains(signature));
  }