我有一个TOTP Authenticator项目,它使用TOTP (RFC 6238)生成一个六位数的一次性密码。在内部它使用来自 Apache Commons Codec 的Base32类:
Base32 base32 = new Base32();
在commons-codec升级1.14 -> 1.15之后,单元测试开始失败:
@Test
void testInvalidBase32Value() {
String secretKey = "AHXQ2W5P6AGKYVK";
Executable when = () -> generator.generateOtp(secretKey);
assertThrows(IllegalArgumentException.class, when);
}
org.opentest4j.AssertionFailedError: Expected java.lang.IllegalArgumentException to be thrown, but nothing was thrown.
如何修复测试?