1 package com.github.davidmoten.aws.lw.client.internal.auth;
2
3 import static com.github.davidmoten.aws.lw.client.internal.auth.AwsSignatureVersion4.getCanonicalizedResourcePath;
4 import static org.junit.Assert.assertEquals;
5
6 import java.net.MalformedURLException;
7 import java.net.URL;
8
9 import org.junit.Test;
10
11 public class AwsSignatureVersion4Test {
12
13 @Test
14 public void testPath() throws MalformedURLException {
15 assertEquals("/", getCanonicalizedResourcePath(new URL("https://")));
16 }
17
18 @Test
19 public void testPath2() throws MalformedURLException {
20 assertEquals("/hi", getCanonicalizedResourcePath(new URL("https://blah.com/hi")));
21 }
22
23 @Test(expected=RuntimeException.class)
24 public void testSignBadAlgorithmThrows() {
25 AwsSignatureVersion4.sign("hi there", new byte[] {1,2,3,4}, "doesnotexist");
26 }
27
28 @Test(expected=RuntimeException.class)
29 public void testSignBadKeyThrows2() {
30 AwsSignatureVersion4.sign("hi there", new byte[] {}, AwsSignatureVersion4.ALGORITHM_HMAC_SHA256);
31 }
32
33 }