|
|
|
|
@ -60,6 +60,8 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
"/api/v1/institution-identifiers/quota-verifications";
|
|
|
|
|
private static final String CONTROL_SIGNATURE_BASE_PATH =
|
|
|
|
|
"/api/v1/institution-identifiers/control-system-signatures";
|
|
|
|
|
private static final String COMMERCIAL_BANK_CONTROL_SIGNATURE_BASE_PATH =
|
|
|
|
|
"/api/v1/institution-identifiers/commercial-bank/control-system-signatures";
|
|
|
|
|
private static final String QUOTA_CONTROL_BASE_PATH =
|
|
|
|
|
"/api/v1/institution-identifiers/quota-control-bits";
|
|
|
|
|
private static final String CENTRAL_QUOTA_CONTROL_BASE_PATH =
|
|
|
|
|
@ -280,6 +282,10 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.andExpect(jsonPath("$.data.signature").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").doesNotExist())
|
|
|
|
|
.andExpect(jsonPath("$.data.quotaRequestMessage").doesNotExist());
|
|
|
|
|
mvc.perform(get(CENTRAL_QUOTA_REQUEST_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(7));
|
|
|
|
|
mvc.perform(post(QUOTA_BASE_PATH + "/steps/send").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(6))
|
|
|
|
|
@ -296,7 +302,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(6));
|
|
|
|
|
mvc.perform(get(CENTRAL_QUOTA_REQUEST_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(2))
|
|
|
|
|
.andExpect(jsonPath("$.data.quotaRequestId").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.amount").value(1589.85))
|
|
|
|
|
.andExpect(jsonPath("$.data.orgId").value("ORG_3A4B5C6D7E8F"))
|
|
|
|
|
@ -307,15 +313,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.andExpect(jsonPath("$.data.requestMessage").doesNotExist());
|
|
|
|
|
mvc.perform(post(CENTRAL_QUOTA_REQUEST_BASE_PATH + "/steps/receive")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(2))
|
|
|
|
|
.andExpect(jsonPath("$.data.quotaRequestId").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.orgId").value("ORG_3A4B5C6D7E8F"))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(7));
|
|
|
|
|
mvc.perform(post(CENTRAL_QUOTA_REQUEST_BASE_PATH + "/steps/receive")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(2));
|
|
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
|
|
|
|
|
|
TransactionInformationIdentifierEntity persisted = transactionMapper.selectList(null).get(0);
|
|
|
|
|
assertThat(persisted.getStatus()).isEqualTo("QUOTA_RECEIVED");
|
|
|
|
|
@ -328,7 +326,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.extracting(TransactionInformationIdentifierOperationLogEntity::getOperation)
|
|
|
|
|
.containsExactly("DIGEST", "ASSEMBLE", "QUOTA_DIGEST", "QUOTA_SIGN",
|
|
|
|
|
"QUOTA_DIGEST", "QUOTA_SIGN", "QUOTA_SIGN",
|
|
|
|
|
"QUOTA_PACKAGE", "QUOTA_SEND", "QUOTA_RECEIVE");
|
|
|
|
|
"QUOTA_PACKAGE", "QUOTA_SEND");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@ -395,51 +393,105 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
assertThat(verified.getQuotaSignatureValid()).isTrue();
|
|
|
|
|
assertThat(verified.getQuotaDigestMatches()).isTrue();
|
|
|
|
|
|
|
|
|
|
mvc.perform(post(VERIFICATION_BASE_PATH + "/steps/concatenate-original-text")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.originalText").value(verificationOriginalText));
|
|
|
|
|
mvc.perform(post(VERIFICATION_BASE_PATH + "/steps/hash")
|
|
|
|
|
.header("Authorization", authorization)
|
|
|
|
|
.contentType("application/json")
|
|
|
|
|
.content("{\"originalText\":\"" + verificationOriginalText + "\"}"))
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
assertThat(transactionMapper.selectList(null).get(0).getQuotaSignatureDigest()).isNull();
|
|
|
|
|
mvc.perform(post(VERIFICATION_BASE_PATH + "/steps/recover-signature-digest")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"publicKey\":\"" + bankPublicKey + "\"}"))
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
mvc.perform(post(VERIFICATION_BASE_PATH + "/steps/compare-digests")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.h1EqualsH2").value(true));
|
|
|
|
|
mvc.perform(post(VERIFICATION_BASE_PATH + "/steps/compare-digests")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.h1EqualsH2").value(true));
|
|
|
|
|
assertThat(transactionMapper.selectList(null)).hasSize(1);
|
|
|
|
|
assertThat(transactionMapper.selectList(null).get(0).getId()).isEqualTo(stepSixRecordId);
|
|
|
|
|
verified = transactionMapper.selectList(null).get(0);
|
|
|
|
|
|
|
|
|
|
mvc.perform(post(CONTROL_SIGNATURE_BASE_PATH + "/steps/prepare")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
|
String controlOriginalText = verified.getAmount().setScale(2).toPlainString() + "|"
|
|
|
|
|
+ verified.getInstitutionIdentifier() + "|" + verified.getTransactionIdentifier();
|
|
|
|
|
mvc.perform(post(CONTROL_SIGNATURE_BASE_PATH + "/steps/digest")
|
|
|
|
|
.header("Authorization", authorization)
|
|
|
|
|
.contentType("application/json")
|
|
|
|
|
.content("{\"originalText\":\"999.00|"
|
|
|
|
|
+ verified.getInstitutionIdentifier() + "|" + verified.getTransactionIdentifier()
|
|
|
|
|
+ "\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.allOf(
|
|
|
|
|
org.hamcrest.Matchers.containsString("与当前用户前序数据不一致"),
|
|
|
|
|
org.hamcrest.Matchers.containsString("第2次错误"))));
|
|
|
|
|
assertThat(controlSignatureMapper.selectList(null)).isEmpty();
|
|
|
|
|
String firstDigest = mvc.perform(post(CONTROL_SIGNATURE_BASE_PATH + "/steps/digest")
|
|
|
|
|
.header("Authorization", authorization)
|
|
|
|
|
.contentType("application/json")
|
|
|
|
|
.content("{\"originalText\":\"" + controlOriginalText + "\"}"))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("DIGESTED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.originalText").value(controlOriginalText))
|
|
|
|
|
.andExpect(jsonPath("$.data.digest").value(cryptography.sm3(controlOriginalText)))
|
|
|
|
|
.andExpect(jsonPath("$.data.controlId").value(org.hamcrest.Matchers.matchesPattern(
|
|
|
|
|
"CTRL_\\d{8}_\\d{3}")))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.status").doesNotExist())
|
|
|
|
|
.andExpect(jsonPath("$.data.originalText").doesNotExist())
|
|
|
|
|
.andExpect(jsonPath("$.data.controlId").doesNotExist())
|
|
|
|
|
.andReturn().getResponse().getContentAsString();
|
|
|
|
|
String repeatedDigest = mvc.perform(post(CONTROL_SIGNATURE_BASE_PATH + "/steps/digest")
|
|
|
|
|
.header("Authorization", authorization)
|
|
|
|
|
.contentType("application/json")
|
|
|
|
|
.content("{\"originalText\":\"" + controlOriginalText + "\"}"))
|
|
|
|
|
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
|
|
|
|
assertThat(com.jayway.jsonpath.JsonPath.<Number>read(repeatedDigest, "$.data.id").longValue())
|
|
|
|
|
.isEqualTo(com.jayway.jsonpath.JsonPath.<Number>read(firstDigest, "$.data.id").longValue());
|
|
|
|
|
assertThat(com.jayway.jsonpath.JsonPath.<String>read(repeatedDigest, "$.data.digest"))
|
|
|
|
|
.isEqualTo(com.jayway.jsonpath.JsonPath.<String>read(firstDigest, "$.data.digest"));
|
|
|
|
|
assertThat(controlSignatureMapper.selectList(null)).hasSize(1);
|
|
|
|
|
mvc.perform(post(CONTROL_SIGNATURE_BASE_PATH + "/steps/sign")
|
|
|
|
|
.header("Authorization", authorization)
|
|
|
|
|
.contentType("application/json")
|
|
|
|
|
.content("{\"privateKey\":\"WRONG_CENTRAL_PRIVATE_KEY\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第2次错误")));
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第3次错误")));
|
|
|
|
|
mvc.perform(post(CONTROL_SIGNATURE_BASE_PATH + "/steps/sign")
|
|
|
|
|
.header("Authorization", authorization)
|
|
|
|
|
.contentType("application/json")
|
|
|
|
|
.content("{\"privateKey\":\"" + centralPrivateKey + "\"}"))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("SIGNED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.signingKeyId").value(InstitutionKeyService.CENTRAL_FIRST_KEY))
|
|
|
|
|
.andExpect(jsonPath("$.data.signature").value(org.hamcrest.Matchers.matchesPattern("[0-9A-F]+")));
|
|
|
|
|
.andExpect(jsonPath("$.data.signature").value(org.hamcrest.Matchers.matchesPattern("[0-9A-F]+")))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1));
|
|
|
|
|
mvc.perform(post(CONTROL_SIGNATURE_BASE_PATH + "/steps/package").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("PACKAGED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.responseMessage").value(org.hamcrest.Matchers.containsString(
|
|
|
|
|
"\"cbCtrlSignature\"")));
|
|
|
|
|
mvc.perform(get(COMMERCIAL_BANK_CONTROL_SIGNATURE_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.ctrlId").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.amount").value(1589.85))
|
|
|
|
|
.andExpect(jsonPath("$.data.orgId").value("ORG_3A4B5C6D7E8F"))
|
|
|
|
|
.andExpect(jsonPath("$.data.txnId").value(org.hamcrest.Matchers.startsWith("TXN_")))
|
|
|
|
|
.andExpect(jsonPath("$.data.cbCtrlSignature").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(6));
|
|
|
|
|
mvc.perform(post(CONTROL_SIGNATURE_BASE_PATH + "/steps/send").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("SENT"));
|
|
|
|
|
mvc.perform(get(COMMERCIAL_BANK_CONTROL_SIGNATURE_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(2))
|
|
|
|
|
.andExpect(jsonPath("$.data.ctrlId").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.amount").value(1589.85))
|
|
|
|
|
.andExpect(jsonPath("$.data.orgId").value("ORG_3A4B5C6D7E8F"))
|
|
|
|
|
.andExpect(jsonPath("$.data.txnId").value(org.hamcrest.Matchers.startsWith("TXN_")))
|
|
|
|
|
.andExpect(jsonPath("$.data.cbCtrlSignature").isNotEmpty())
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(6));
|
|
|
|
|
|
|
|
|
|
ControlSystemSignatureEntity persisted = controlSignatureMapper.selectList(null).get(0);
|
|
|
|
|
TransactionInformationIdentifierEntity transaction = transactionMapper.selectList(null).get(0);
|
|
|
|
|
@ -458,7 +510,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
new LambdaQueryWrapper<StuModuleScoreDetailsEntity>()
|
|
|
|
|
.eq(StuModuleScoreDetailsEntity::getUserId, USER_ID)
|
|
|
|
|
.eq(StuModuleScoreDetailsEntity::getSerialNumber, 3));
|
|
|
|
|
assertThat(score.getCompletionStatus()).isEqualTo("2");
|
|
|
|
|
assertThat(score.getCompletionStatus()).isEqualTo("3");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@ -466,64 +518,155 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
flowsStepSixDataThroughCentralBankSignatureAndCommercialBankReceive();
|
|
|
|
|
InstitutionKeySubject subject = new InstitutionKeySubject(USER_ID, SCHOOL_ID, CLASS_ID);
|
|
|
|
|
String bankPrivateKey = keyService.commercialBankKey(subject, "module-four-tester").getPrivateKey();
|
|
|
|
|
String transactionIdentifier = transactionMapper.selectList(null).get(0).getTransactionIdentifier();
|
|
|
|
|
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/static-segment")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"amount\":1590.85,\"institutionIdentifier\":\"ORG_3A4B5C6D7E8F\"," +
|
|
|
|
|
"\"transactionIdentifier\":\"" + transactionIdentifier + "\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第3次错误")));
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/static-segment")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"amount\":1589.85,\"institutionIdentifier\":\"ORG_3A4B5C6D7E8F\"," +
|
|
|
|
|
"\"transactionIdentifier\":\"" + transactionIdentifier + "\"}"))
|
|
|
|
|
mvc.perform(get(CENTRAL_QUOTA_CONTROL_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.quotaId").value(org.hamcrest.Matchers.nullValue()))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(6));
|
|
|
|
|
mvc.perform(get(QUOTA_CONTROL_BASE_PATH + "/segments/static")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isNotFound())
|
|
|
|
|
.andExpect(jsonPath("$.message").value("当前没有步骤八额度控制位记录"));
|
|
|
|
|
mvc.perform(get(QUOTA_CONTROL_BASE_PATH + "/segments/dynamic")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isNotFound())
|
|
|
|
|
.andExpect(jsonPath("$.message").value("当前没有步骤八额度控制位记录"));
|
|
|
|
|
String staticSegmentResponse = mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/static-segment")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("STATIC_READY"))
|
|
|
|
|
.andExpect(jsonPath("$.data.staticSegment").value(
|
|
|
|
|
org.hamcrest.Matchers.matchesPattern("STATIC_[0-9A-F]{64}")))
|
|
|
|
|
.andExpect(jsonPath("$.data.receiveStatus").value(1));
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/dynamic-segment")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"randomValue\":\"7G8H9I0J\",\"timestamp\":\"20260730153600\"}"))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.status").doesNotExist())
|
|
|
|
|
.andReturn().getResponse().getContentAsString();
|
|
|
|
|
String staticSegment = com.jayway.jsonpath.JsonPath.read(staticSegmentResponse, "$.data.staticSegment");
|
|
|
|
|
mvc.perform(get(QUOTA_CONTROL_BASE_PATH + "/segments/static")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.dynamicSegment").value("DYN_7G8H9I0J_20260730153600"));
|
|
|
|
|
.andExpect(jsonPath("$.data.staticSegment").value(staticSegment))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1));
|
|
|
|
|
mvc.perform(get(QUOTA_CONTROL_BASE_PATH + "/segments/dynamic")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isNotFound())
|
|
|
|
|
.andExpect(jsonPath("$.message").value("当前尚未生成步骤八动态段"));
|
|
|
|
|
String firstDynamicSegmentResponse = mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/dynamic-segment")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.dynamicSegment").value(
|
|
|
|
|
org.hamcrest.Matchers.matchesPattern("DYN_[A-Z0-9]{8}_\\d{14}")))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.status").doesNotExist())
|
|
|
|
|
.andReturn().getResponse().getContentAsString();
|
|
|
|
|
String firstDynamicSegment = com.jayway.jsonpath.JsonPath.read(
|
|
|
|
|
firstDynamicSegmentResponse, "$.data.dynamicSegment");
|
|
|
|
|
mvc.perform(get(QUOTA_CONTROL_BASE_PATH + "/segments/dynamic")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.dynamicSegment").value(firstDynamicSegment))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1));
|
|
|
|
|
long stepEightRecordId = quotaControlBitMapper.selectList(null).get(0).getId();
|
|
|
|
|
String secondDynamicSegmentResponse = mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/dynamic-segment")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.dynamicSegment").value(
|
|
|
|
|
org.hamcrest.Matchers.matchesPattern("DYN_[A-Z0-9]{8}_\\d{14}")))
|
|
|
|
|
.andReturn().getResponse().getContentAsString();
|
|
|
|
|
String secondDynamicSegment = com.jayway.jsonpath.JsonPath.read(
|
|
|
|
|
secondDynamicSegmentResponse, "$.data.dynamicSegment");
|
|
|
|
|
assertThat(secondDynamicSegment).isNotEqualTo(firstDynamicSegment);
|
|
|
|
|
assertThat(quotaControlBitMapper.selectList(null)).hasSize(1);
|
|
|
|
|
assertThat(quotaControlBitMapper.selectList(null).get(0).getId()).isEqualTo(stepEightRecordId);
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/read-central-bank-signature")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.centralBankSignatureSegment").value(
|
|
|
|
|
org.hamcrest.Matchers.startsWith("CB_CTRL_")));
|
|
|
|
|
org.hamcrest.Matchers.startsWith("CB_CTRL_")))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1))
|
|
|
|
|
.andExpect(jsonPath("$.data.status").doesNotExist())
|
|
|
|
|
.andExpect(jsonPath("$.data.completeControlBit").doesNotExist());
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/assemble").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.completeControlBit").value(
|
|
|
|
|
org.hamcrest.Matchers.containsString("|DYN_7G8H9I0J_20260730153600|CB_CTRL_")));
|
|
|
|
|
.andExpect(jsonPath("$.data.completeControlBit").value(org.hamcrest.Matchers.allOf(
|
|
|
|
|
org.hamcrest.Matchers.containsString("|DYN_"),
|
|
|
|
|
org.hamcrest.Matchers.containsString("|CB_CTRL_"))));
|
|
|
|
|
String completeControlBit = quotaControlBitMapper.selectList(null).get(0).getCompleteControlBit();
|
|
|
|
|
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/sign")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"privateKey\":\"" + bankPrivateKey + "\",\"hashAlgorithm\":\"SM3\"}"))
|
|
|
|
|
.content("{\"privateKey\":\"" + bankPrivateKey + "\",\"completeControlBit\":\""
|
|
|
|
|
+ completeControlBit + "\",\"hashAlgorithm\":\"SM3\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第4次错误")));
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/sign")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"privateKey\":\"WRONG_BANK_PRIVATE_KEY\",\"hashAlgorithm\":\"SM2\"}"))
|
|
|
|
|
.content("{\"privateKey\":\"" + bankPrivateKey + "\",\"completeControlBit\":\""
|
|
|
|
|
+ completeControlBit + "_TAMPERED\",\"hashAlgorithm\":\"SM2\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第5次错误")));
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.allOf(
|
|
|
|
|
org.hamcrest.Matchers.containsString("完整额度控制位与步骤八拼接结果不一致"),
|
|
|
|
|
org.hamcrest.Matchers.containsString("第5次错误"))));
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/sign")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"privateKey\":\"" + bankPrivateKey + "\",\"hashAlgorithm\":\"SM2\"}"))
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("SIGNED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.bankSignature").value(org.hamcrest.Matchers.matchesPattern("[0-9A-F]+")));
|
|
|
|
|
.content("{\"privateKey\":\"WRONG_BANK_PRIVATE_KEY\",\"completeControlBit\":\""
|
|
|
|
|
+ completeControlBit + "\",\"hashAlgorithm\":\"SM2\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第6次错误")));
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/sign")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"privateKey\":\"" + bankPrivateKey + "\",\"completeControlBit\":\""
|
|
|
|
|
+ completeControlBit + "\",\"hashAlgorithm\":\"SM2\"}"))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.signature").value(org.hamcrest.Matchers.matchesPattern("[0-9A-F]+")))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(1));
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/package").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("PACKAGED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.requestMessage").value(org.hamcrest.Matchers.containsString("\"quotaId\"")));
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/static-segment")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.staticSegment").value(
|
|
|
|
|
org.hamcrest.Matchers.matchesPattern("STATIC_[0-9A-F]{64}")));
|
|
|
|
|
QuotaControlBitEntity resetByStatic = quotaControlBitMapper.selectList(null).get(0);
|
|
|
|
|
assertThat(resetByStatic.getId()).isEqualTo(stepEightRecordId);
|
|
|
|
|
assertThat(resetByStatic.getStatus()).isEqualTo("STATIC_READY");
|
|
|
|
|
assertThat(resetByStatic.getDynamicSegment()).isNull();
|
|
|
|
|
assertThat(resetByStatic.getCentralBankSignatureSegment()).isNull();
|
|
|
|
|
assertThat(resetByStatic.getCompleteControlBit()).isNull();
|
|
|
|
|
assertThat(resetByStatic.getBankSignature()).isNull();
|
|
|
|
|
assertThat(resetByStatic.getRequestMessage()).isNull();
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/dynamic-segment")
|
|
|
|
|
.header("Authorization", authorization)).andExpect(status().isOk());
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/read-central-bank-signature")
|
|
|
|
|
.header("Authorization", authorization)).andExpect(status().isOk());
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/assemble")
|
|
|
|
|
.header("Authorization", authorization)).andExpect(status().isOk());
|
|
|
|
|
String regeneratedCompleteControlBit = quotaControlBitMapper.selectList(null).get(0).getCompleteControlBit();
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/sign")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"privateKey\":\"" + bankPrivateKey + "\",\"completeControlBit\":\""
|
|
|
|
|
+ regeneratedCompleteControlBit + "\",\"hashAlgorithm\":\"SM2\"}"))
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/package").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk());
|
|
|
|
|
mvc.perform(post(QUOTA_CONTROL_BASE_PATH + "/steps/send").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("SENT"))
|
|
|
|
|
.andExpect(jsonPath("$.data.receiveStatus").value(1));
|
|
|
|
|
mvc.perform(get(CENTRAL_QUOTA_CONTROL_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.receiveStatus").value(1));
|
|
|
|
|
mvc.perform(post(CENTRAL_QUOTA_CONTROL_BASE_PATH + "/steps/receive").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk()).andExpect(jsonPath("$.data.status").value("RECEIVED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.receiveStatus").value(2));
|
|
|
|
|
mvc.perform(get(CENTRAL_QUOTA_CONTROL_BASE_PATH).header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value(2))
|
|
|
|
|
.andExpect(jsonPath("$.data.quotaId").value(org.hamcrest.Matchers.startsWith("QC_")))
|
|
|
|
|
.andExpect(jsonPath("$.data.staticSegment").value(
|
|
|
|
|
org.hamcrest.Matchers.matchesPattern("STATIC_[0-9A-F]{64}")))
|
|
|
|
|
.andExpect(jsonPath("$.data.dynamicSegment").value(
|
|
|
|
|
org.hamcrest.Matchers.matchesPattern("DYN_[A-Z0-9]{8}_\\d{14}")))
|
|
|
|
|
.andExpect(jsonPath("$.data.cbSignatureSegment").value(
|
|
|
|
|
org.hamcrest.Matchers.startsWith("CB_CTRL_")))
|
|
|
|
|
.andExpect(jsonPath("$.data.bankSignature").value(
|
|
|
|
|
org.hamcrest.Matchers.matchesPattern("[0-9A-F]+")))
|
|
|
|
|
.andExpect(jsonPath("$.data.length()").value(6));
|
|
|
|
|
mvc.perform(post(CENTRAL_QUOTA_CONTROL_BASE_PATH + "/steps/receive")
|
|
|
|
|
.header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isNotFound());
|
|
|
|
|
|
|
|
|
|
QuotaControlBitEntity stored = quotaControlBitMapper.selectList(null).get(0);
|
|
|
|
|
assertThat(stored.getStatus()).isEqualTo("RECEIVED");
|
|
|
|
|
@ -533,7 +676,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
StuModuleScoreDetailsEntity score = scoreMapper.selectOne(new LambdaQueryWrapper<StuModuleScoreDetailsEntity>()
|
|
|
|
|
.eq(StuModuleScoreDetailsEntity::getUserId, USER_ID)
|
|
|
|
|
.eq(StuModuleScoreDetailsEntity::getSerialNumber, 3));
|
|
|
|
|
assertThat(score.getCompletionStatus()).isEqualTo("5");
|
|
|
|
|
assertThat(score.getCompletionStatus()).isEqualTo("6");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@ -544,7 +687,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"amount\":1590.85}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第6次错误")));
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第7次错误")));
|
|
|
|
|
mvc.perform(post(STANDARD_CURRENCY_BASE_PATH + "/steps/decompose")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"amount\":1589.85}"))
|
|
|
|
|
@ -560,7 +703,7 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.content("{\"prefix\":\"RMB\",\"idRule\":\"批次号+枚序号+随机校验码\"," +
|
|
|
|
|
"\"currencyStatus\":\"待生效\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第7次错误")));
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("第8次错误")));
|
|
|
|
|
mvc.perform(post(STANDARD_CURRENCY_BASE_PATH + "/steps/confirm-rule")
|
|
|
|
|
.header("Authorization", authorization).contentType("application/json")
|
|
|
|
|
.content("{\"prefix\":\"DC\",\"idRule\":\"批次号+枚序号+随机校验码\"," +
|
|
|
|
|
@ -586,10 +729,18 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
assertThat(currencies.stream().map(StandardCurrencyEntity::getDenomination)
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add)).isEqualByComparingTo("1589.85");
|
|
|
|
|
assertThat(currencies.stream().map(StandardCurrencyEntity::getCurrencyId).distinct().count()).isEqualTo(27);
|
|
|
|
|
List<Long> currencyIds = currencies.stream().map(StandardCurrencyEntity::getId)
|
|
|
|
|
.collect(java.util.stream.Collectors.toList());
|
|
|
|
|
long batchId = standardCurrencyBatchMapper.selectList(null).get(0).getId();
|
|
|
|
|
mvc.perform(post(STANDARD_CURRENCY_BASE_PATH + "/steps/generate").header("Authorization", authorization))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString("当前状态:GENERATED")));
|
|
|
|
|
.andExpect(status().isOk())
|
|
|
|
|
.andExpect(jsonPath("$.data.status").value("GENERATED"))
|
|
|
|
|
.andExpect(jsonPath("$.data.currencies.length()").value(27));
|
|
|
|
|
assertThat(standardCurrencyBatchMapper.selectList(null)).hasSize(1);
|
|
|
|
|
assertThat(standardCurrencyBatchMapper.selectList(null).get(0).getId()).isEqualTo(batchId);
|
|
|
|
|
assertThat(standardCurrencyMapper.selectList(null)).hasSize(27);
|
|
|
|
|
assertThat(standardCurrencyMapper.selectList(null).stream().map(StandardCurrencyEntity::getId)
|
|
|
|
|
.collect(java.util.stream.Collectors.toList())).containsExactlyElementsOf(currencyIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@ -642,9 +793,9 @@ class TransactionInformationIdentifierControllerTest {
|
|
|
|
|
.contentType("application/json")
|
|
|
|
|
.content("{\"originalText\":\"1589.85|ORG_3A4B5C6D7E8F|TXN_"
|
|
|
|
|
+ "7A8B9C0D1E2F3A4B5C6D7E8F9A0B1C2D3E4F5A6B7C8D9E0F1A2B3C4D5E6F\"}"))
|
|
|
|
|
.andExpect(status().isBadRequest())
|
|
|
|
|
.andExpect(status().isNotFound())
|
|
|
|
|
.andExpect(jsonPath("$.message").value(org.hamcrest.Matchers.containsString(
|
|
|
|
|
"请先接收步骤五额度请求报文")));
|
|
|
|
|
"当前没有额度请求记录")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|