Exemplo n.º 1
0
  @Test
  public void testCreateAuthorizationHeader() {
    Date now = DateUtil.now();

    String method = "POST";
    String hostname = "api.tuppari.com";
    String path = "/test";
    String query = "a=v1&b=v2";

    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Host", "api.tuppari.com");
    headers.put("Content-type", "application/json");
    headers.put("X-Tuppari-Operation", "CreateApplication");

    Map<String, Object> body = new LinkedHashMap<String, Object>();
    body.put("applicationName", "example1");
    String accessKeyId = "accessKeyId";
    String accessSecretKey = "accessSecretKey";

    String authorization =
        SignUtil.createAuthorizationHeader(
            method, hostname, path, query, headers, body, now, accessKeyId, accessSecretKey);
    assertThat(
        authorization,
        is(
            "HMAC-SHA256 Credential=accessKeyId,SignedHeaders=content-type;host;x-tuppari-operation,Signature=050f8711271747d4f63a3caa3ffb420e4cd5a0e9d9dda8ba7e4faad6794c40d0"));
  }