|
@@ -40,6 +40,26 @@ class OmgCheckMacSignerTest {
|
|
|
() -> signer.sign(Map.of("CheckMacValue", "caller-value"), HASH_KEY, HASH_IV));
|
|
() -> signer.sign(Map.of("CheckMacValue", "caller-value"), HASH_KEY, HASH_IV));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void rejectsNullHashKey() {
|
|
|
|
|
+ assertThrows(IllegalArgumentException.class, () -> signer.sign(officialFields(), null, HASH_IV));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void rejectsNullHashIv() {
|
|
|
|
|
+ assertThrows(IllegalArgumentException.class, () -> signer.sign(officialFields(), HASH_KEY, null));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void rejectsEmptyHashKey() {
|
|
|
|
|
+ assertThrows(IllegalArgumentException.class, () -> signer.sign(officialFields(), "", HASH_IV));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void rejectsEmptyHashIv() {
|
|
|
|
|
+ assertThrows(IllegalArgumentException.class, () -> signer.sign(officialFields(), HASH_KEY, ""));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Test
|
|
@Test
|
|
|
void leavesInputUnchangedAndReturnsUppercaseSha256Hex() {
|
|
void leavesInputUnchangedAndReturnsUppercaseSha256Hex() {
|
|
|
Map<String, String> fields = new LinkedHashMap<>(officialFields());
|
|
Map<String, String> fields = new LinkedHashMap<>(officialFields());
|
|
@@ -53,13 +73,13 @@ class OmgCheckMacSignerTest {
|
|
|
|
|
|
|
|
private static Map<String, String> officialFields() {
|
|
private static Map<String, String> officialFields() {
|
|
|
Map<String, String> fields = new LinkedHashMap<>();
|
|
Map<String, String> fields = new LinkedHashMap<>();
|
|
|
- fields.put("TradeDesc", "促銷方案");
|
|
|
|
|
|
|
+ fields.put("TradeDesc", "\u4FC3\u92B7\u65B9\u6848");
|
|
|
fields.put("PaymentType", "aio");
|
|
fields.put("PaymentType", "aio");
|
|
|
fields.put("MerchantTradeDate", "2013/03/12 15:30:23");
|
|
fields.put("MerchantTradeDate", "2013/03/12 15:30:23");
|
|
|
fields.put("MerchantTradeNo", "funpoint20130312153023");
|
|
fields.put("MerchantTradeNo", "funpoint20130312153023");
|
|
|
fields.put("MerchantID", "2000132");
|
|
fields.put("MerchantID", "2000132");
|
|
|
fields.put("ReturnURL", "https://www.funpoint.com.tw/receive.php");
|
|
fields.put("ReturnURL", "https://www.funpoint.com.tw/receive.php");
|
|
|
- fields.put("ItemName", "Apple iphone 7 手機殼");
|
|
|
|
|
|
|
+ fields.put("ItemName", "Apple iphone 7 \u624B\u6A5F\u6BBC");
|
|
|
fields.put("TotalAmount", "1000");
|
|
fields.put("TotalAmount", "1000");
|
|
|
fields.put("ChoosePayment", "ALL");
|
|
fields.put("ChoosePayment", "ALL");
|
|
|
fields.put("EncryptType", "1");
|
|
fields.put("EncryptType", "1");
|