From 68a53e89f10c379b8f667224620641c1e7984990 Mon Sep 17 00:00:00 2001 From: John Jiang Date: Sat, 13 Jan 2024 10:17:26 +0800 Subject: [PATCH] more assertThrows on doPhase --- .../sun/security/ec/ECDHKeyAgreementParamValidation.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/jdk/sun/security/ec/ECDHKeyAgreementParamValidation.java b/test/jdk/sun/security/ec/ECDHKeyAgreementParamValidation.java index a1e9d740df213..ce43bd3034907 100644 --- a/test/jdk/sun/security/ec/ECDHKeyAgreementParamValidation.java +++ b/test/jdk/sun/security/ec/ECDHKeyAgreementParamValidation.java @@ -87,11 +87,10 @@ public void testDoPhaseWithInvalidKey() throws Exception { KeyAgreement ka = KeyAgreement.getInstance("ECDH"); ka.init(kpP256.getPrivate()); - try { - ka.doPhase(kpP384.getPublic(), true); - } catch (InvalidKeyException e) { - // Do nothing - } + + Assertions.assertThrows( + InvalidKeyException.class, + () -> ka.doPhase(kpP384.getPublic(), true)); // Should not generate share key with SECP256R1 private key and SECP384R1 public key Assertions.assertThrows(IllegalStateException.class, ka::generateSecret);