|
@@ -201,6 +201,8 @@ public class ReceiptBillGatewayTest {
|
|
|
verify("SHA1withRSA", AdapayCore.apiBase + exchange.getRequestURI() + body,
|
|
verify("SHA1withRSA", AdapayCore.apiBase + exchange.getRequestURI() + body,
|
|
|
exchange.getRequestHeaders().getFirst("Signature"));
|
|
exchange.getRequestHeaders().getFirst("Signature"));
|
|
|
String data = "{\"status\":\"succeeded\",\"prod_mode\":true,\"bill_download_url\":\"https://jarvisfile.oss-cn-shanghai.aliyuncs.com/test\"}";
|
|
String data = "{\"status\":\"succeeded\",\"prod_mode\":true,\"bill_download_url\":\"https://jarvisfile.oss-cn-shanghai.aliyuncs.com/test\"}";
|
|
|
|
|
+ if ("unconfirmedHost".equals(mode)) data = data.replace("jarvisfile.oss-cn-shanghai.aliyuncs.com/test",
|
|
|
|
|
+ "files.example.org/private-file?Signature=private-signature");
|
|
|
if ("pending".equals(mode)) data = "{\"status\":\"pending\",\"prod_mode\":true}";
|
|
if ("pending".equals(mode)) data = "{\"status\":\"pending\",\"prod_mode\":true}";
|
|
|
if ("ticket401".equals(mode)) {
|
|
if ("ticket401".equals(mode)) {
|
|
|
status = 401;
|
|
status = 401;
|
|
@@ -307,6 +309,33 @@ public class ReceiptBillGatewayTest {
|
|
|
assertEquals(1, downloads);
|
|
assertEquals(1, downloads);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test public void huifuIdentifiesUnconfirmedDownloadDomainWithoutExposingSignedUrl() throws Exception {
|
|
|
|
|
+ mode = "unconfirmedHost";
|
|
|
|
|
+ ReceiptBillDto bill = fetch("101", "HUIFU", DAY);
|
|
|
|
|
+ assertEquals("ERROR", bill.getStatus());
|
|
|
|
|
+ assertTrue(bill.getMessage(), bill.getMessage().contains("下载地址校验失败:未登记的账单下载域名(files.example.org)"));
|
|
|
|
|
+ assertFalse(bill.getMessage().contains("private-"));
|
|
|
|
|
+ assertEquals(1, tickets);
|
|
|
|
|
+ assertEquals(0, downloads);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test public void downloadPreservesSignedPathAndQueryWithStandardPorts() throws Exception {
|
|
|
|
|
+ String host = "jarvisfile.oss-cn-shanghai.aliyuncs.com";
|
|
|
|
|
+ String resource = "/app%2Ffile.zip?Signature=a%2Bb%3D&Expires=123";
|
|
|
|
|
+ for (String origin : Arrays.asList("HTTP://" + host.toUpperCase(Locale.ROOT) + ":80", "https://" + host + ":443")) {
|
|
|
|
|
+ assertEquals("https://" + host + resource, BillHttp.download(origin + resource, host).toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String origin : Arrays.asList("https://" + host + ":444", "https://user@" + host,
|
|
|
|
|
+ "ftp://" + host, "https://" + host + "/#fragment", "https://" + host + ".example.org")) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ BillHttp.download(origin + resource, host);
|
|
|
|
|
+ fail("地址应被拒绝");
|
|
|
|
|
+ } catch (BillHttp.Failure expected) {
|
|
|
|
|
+ assertFalse(expected.getMessage().contains("Signature"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Test public void huifuUnsignedOrEmptyRejectionsStayAtTicketStage() throws Exception {
|
|
@Test public void huifuUnsignedOrEmptyRejectionsStayAtTicketStage() throws Exception {
|
|
|
for (String scenario : Arrays.asList("empty401", "plain401")) {
|
|
for (String scenario : Arrays.asList("empty401", "plain401")) {
|
|
|
mode = scenario;
|
|
mode = scenario;
|