From 5a4aa5acf84535543c85948bc216384b2209d8ef Mon Sep 17 00:00:00 2001 From: 13009 Date: Tue, 18 Jun 2024 17:59:39 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/core/cipher/DefaultValidatorTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/cipher/DefaultValidatorTest.java b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/cipher/DefaultValidatorTest.java index a79f5b0..d6ecbb6 100644 --- a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/cipher/DefaultValidatorTest.java +++ b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/cipher/DefaultValidatorTest.java @@ -1,5 +1,6 @@ package com.czcb.scfs.api.core.cipher; +import com.czcb.scfs.api.core.Channel; import com.czcb.scfs.api.core.DefaultChannel; import com.czcb.scfs.api.core.KeyText; import com.czcb.scfs.api.core.Profile; @@ -95,7 +96,9 @@ class DefaultValidatorTest { .statusCode(200) .build(); - defaultValidator.isInvalidHttpCode(response); + Assertions.assertDoesNotThrow(() -> { + defaultValidator.isInvalidHttpCode(response); + }); } @Test @@ -240,10 +243,12 @@ class DefaultValidatorTest { .statusCode(200) .build(); - ValidationException validationException = Assertions.assertThrows(ValidationException.class, () -> defaultValidator.validateResponseSignature(response, new DefaultChannel.Builder() + Channel channel = new DefaultChannel.Builder() .channelNo("1010") .appNo("1111") - .build())); + .build(); + + ValidationException validationException = Assertions.assertThrows(ValidationException.class, () -> defaultValidator.validateResponseSignature(response, channel)); Assertions.assertEquals("校验失败, 签名[X-SCFS-Signature]不存在, Request-Id=123456789, HttpResponseBody=123", validationException.getLocalizedMessage()); } @@ -265,10 +270,12 @@ class DefaultValidatorTest { .statusCode(200) .build(); - ValidationException validationException = Assertions.assertThrows(ValidationException.class, () -> defaultValidator.validateResponseSignature(response, new DefaultChannel.Builder() + + Channel channel = new DefaultChannel.Builder() .channelNo("1010") .appNo("1111") - .build())); + .build(); + ValidationException validationException = Assertions.assertThrows(ValidationException.class, () -> defaultValidator.validateResponseSignature(response, channel)); Assertions.assertEquals("校验失败, 签名[X-SCFS-Signature=MTIzNDU2Nzg5]校验未通过, Request-Id=123456789, HttpResponseBody=123", validationException.getLocalizedMessage()); }