@Test
    void testSign() throws Exception {
        HttpPost request = new HttpPost("https://ecr.us-east-1.amazonaws.com/");
        request.setHeader("host", "ecr.us-east-1.amazonaws.com");
        request.setHeader("Content-Type", "application/x-amz-json-1.1");
        request.setHeader("X-Amz-Target", "AmazonEC2ContainerRegistry_V20150921.GetAuthorizationToken");
        request.setEntity(new StringEntity("{\"registryIds\":[\"012345678901\"]}", StandardCharsets.UTF_8));

        AwsSigner4 signer = new AwsSigner4("us-east-1", "ecr");

        Date signingTime = AwsSigner4Request.TIME_FORMAT.parse("20150830T123600Z");
        AwsSigner4Request sr = new AwsSigner4Request("us-east-1", "service", request, signingTime);
        AuthConfig credentials = new AuthConfig("AKIDEXAMPLE", "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY", null, null);
 
        Assertions.assertEquals(TASK1, signer.task1(sr));

        Assertions.assertEquals(TASK2, signer.task2(sr));

        StringBuilder dst = new StringBuilder();
        AwsSigner4.hexEncode(dst, signer.task3(sr, credentials));
        Assertions.assertEquals(TASK3, dst.toString());

        Assertions.assertEquals(TASK4, signer.task4(sr, credentials));
    }
Test aws request signing

@author chas
@since 2016-12-21
src/test/java/io/fabric8/maven/docker/access/ecr/AwsSigner4RequestTest.java