Exemplo n.º 1
0
  @Test
  public void testCreateSignature_2() throws ParseException {
    String secretKey1 = "secretKey1";
    String secretKey2 = "secretKey2";

    String stringToSign =
        "SHA256\n"
            + "19700101T000000Z\n"
            + "152176000cc08c7d9d0558bc3a50368aa38619a695ad20f50bec1344429cb315";

    Date now = DateUtil.now();
    String host = "api.tuppari.com";
    String expectedSignature = "4815ff1681a278e7c852902ea3604f17831a80a78dc0ff82f5142598a034509b";

    String result1 = SignUtil.createSignature(secretKey1, stringToSign, now, host);
    String result2 = SignUtil.createSignature(secretKey2, stringToSign, now, host);

    assertThat(result1, not(equalTo(result2)));
  }
Exemplo n.º 2
0
  @Test
  public void testCreateSignature_1() throws ParseException {
    String secretKey = "secretKey1";
    String stringToSign =
        "SHA256\n"
            + "19700101T000000Z\n"
            + "152176000cc08c7d9d0558bc3a50368aa38619a695ad20f50bec1344429cb315";

    Date now = DateUtil.now();
    String host = "api.tuppari.com";
    String expectedSignature = "4815ff1681a278e7c852902ea3604f17831a80a78dc0ff82f5142598a034509b";

    // Check with the same secret key, siganature returns same signature
    for (int i = 0; i < 1000; ++i) {
      String result = SignUtil.createSignature(secretKey, stringToSign, now, host);
      assertThat(result, is(expectedSignature));
    }
  }