From bac7e2990154bcff600d7549381b1a8c8c9ee037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20M=C5=82odawski?= Date: Sat, 2 Nov 2024 11:58:23 +0100 Subject: [PATCH] Add files via upload Adding functionality for getting device information, improving testing --- pom.xml | 8 ++-- .../security/pkcs11/PKCS11SessionTest.java | 43 ------------------- 2 files changed, 4 insertions(+), 47 deletions(-) diff --git a/pom.xml b/pom.xml index 0881cb6..c42de55 100644 --- a/pom.xml +++ b/pom.xml @@ -6,11 +6,11 @@ pl.mlodawski.security credentials-support - 1.0 + 1.1 - 17 - 17 + 21 + 21 UTF-8 @@ -122,7 +122,7 @@ jar - 22 + 21 UTF-8 none false diff --git a/src/test/java/pl/mlodawski/security/pkcs11/PKCS11SessionTest.java b/src/test/java/pl/mlodawski/security/pkcs11/PKCS11SessionTest.java index 3791e5a..6ec2852 100644 --- a/src/test/java/pl/mlodawski/security/pkcs11/PKCS11SessionTest.java +++ b/src/test/java/pl/mlodawski/security/pkcs11/PKCS11SessionTest.java @@ -152,49 +152,6 @@ void logout_shouldCallCLogout() { verify(pkcs11Mock, times(1)).C_Logout(any(NativeLong.class)); } - @Test - void logout_failure_shouldThrowSessionLogoutException() { - when(pkcs11Mock.C_OpenSession(any(NativeLong.class), any(NativeLong.class), isNull(), isNull(), any(NativeLongByReference.class))) - .thenAnswer(invocation -> { - NativeLongByReference sessionRef = invocation.getArgument(4); - sessionRef.setValue(new NativeLong(1)); - return new NativeLong(Pkcs11Constants.CKR_OK); - }); - - when(pkcs11Mock.C_Login(any(NativeLong.class), any(NativeLong.class), any(), any(NativeLong.class))) - .thenReturn(new NativeLong(Pkcs11Constants.CKR_OK)); - - pkcs11Session = new PKCS11Session(pkcs11Mock, pin, slotId); - - when(pkcs11Mock.C_Logout(any(NativeLong.class))).thenThrow(new RuntimeException("Logout failed")); - - assertThrows(SessionLogoutException.class, () -> pkcs11Session.logout()); - } - - @Test - void close_shouldCallCLogoutAndCCloseSessionAndCFinalize() { - when(pkcs11Mock.C_OpenSession(any(NativeLong.class), any(NativeLong.class), isNull(), isNull(), any(NativeLongByReference.class))) - .thenAnswer(invocation -> { - NativeLongByReference sessionRef = invocation.getArgument(4); - sessionRef.setValue(new NativeLong(1)); - return new NativeLong(Pkcs11Constants.CKR_OK); - }); - - when(pkcs11Mock.C_Login(any(NativeLong.class), any(NativeLong.class), any(), any(NativeLong.class))) - .thenReturn(new NativeLong(Pkcs11Constants.CKR_OK)); - - pkcs11Session = new PKCS11Session(pkcs11Mock, pin, slotId); - - when(pkcs11Mock.C_Logout(any(NativeLong.class))).thenReturn(new NativeLong(Pkcs11Constants.CKR_OK)); - when(pkcs11Mock.C_CloseSession(any(NativeLong.class))).thenReturn(new NativeLong(Pkcs11Constants.CKR_OK)); - when(pkcs11Mock.C_Finalize(isNull())).thenReturn(new NativeLong(Pkcs11Constants.CKR_OK)); - - pkcs11Session.close(); - - verify(pkcs11Mock, times(1)).C_Logout(any(NativeLong.class)); - verify(pkcs11Mock, times(1)).C_CloseSession(any(NativeLong.class)); - verify(pkcs11Mock, times(1)).C_Finalize(isNull()); - } @Test void close_failure_shouldThrowSessionCloseException() {