package de.jeha.s3srv.security;

import org.junit.Test;

import java.security.SignatureException;

import static org.junit.Assert.assertEquals;

/**
 * @author jenshadlich@googlemail.com
 */
public class SignatureTest {

    @Test
    public void test() throws SignatureException {
        final String secretKey = "bar";
        final String stringToSign = "HEAD\n" +
                "\n" +
                "application/octet-stream\n" +
                "Wed, 29 Jun 2016 20:18:33 GMT\n" +
                "/test-bucket/";

        String hmac = Signature.calculateHmacSha1(stringToSign, secretKey);

        assertEquals("DuOzETffRFZL4izMkgOAdjMfORU=", hmac);
    }

}

@@ -357,24 +357,42 @@
 = %22HEAD%5Cn%22 +
+      // HTTP verb
 %0A           
@@ -398,24 +398,81 @@
       %22%5Cn%22 +
+                              // Content-MD5, here: empty
 %0A           
@@ -502,24 +502,45 @@
 -stream%5Cn%22 +
+      // Content-Type
 %0A           
@@ -579,16 +579,24 @@
 GMT%5Cn%22 +
+ // Date
 %0A       
@@ -620,16 +620,79 @@
 ucket/%22;
+                    // CanonicalizedResource, here: request uri
 %0A%0A      

add some doc