Skip to content

Commit bac7e29

Browse files
authored
Add files via upload
Adding functionality for getting device information, improving testing
1 parent 3c6283b commit bac7e29

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
<groupId>pl.mlodawski.security</groupId>
88
<artifactId>credentials-support</artifactId>
9-
<version>1.0</version>
9+
<version>1.1</version>
1010

1111
<properties>
12-
<maven.compiler.source>17</maven.compiler.source>
13-
<maven.compiler.target>17</maven.compiler.target>
12+
<maven.compiler.source>21</maven.compiler.source>
13+
<maven.compiler.target>21</maven.compiler.target>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
</properties>
1616

@@ -122,7 +122,7 @@
122122
<goal>jar</goal>
123123
</goals>
124124
<configuration>
125-
<source>22</source>
125+
<source>21</source>
126126
<encoding>UTF-8</encoding>
127127
<doclint>none</doclint>
128128
<failOnError>false</failOnError>

src/test/java/pl/mlodawski/security/pkcs11/PKCS11SessionTest.java

-43
Original file line numberDiff line numberDiff line change
@@ -152,49 +152,6 @@ void logout_shouldCallCLogout() {
152152
verify(pkcs11Mock, times(1)).C_Logout(any(NativeLong.class));
153153
}
154154

155-
@Test
156-
void logout_failure_shouldThrowSessionLogoutException() {
157-
when(pkcs11Mock.C_OpenSession(any(NativeLong.class), any(NativeLong.class), isNull(), isNull(), any(NativeLongByReference.class)))
158-
.thenAnswer(invocation -> {
159-
NativeLongByReference sessionRef = invocation.getArgument(4);
160-
sessionRef.setValue(new NativeLong(1));
161-
return new NativeLong(Pkcs11Constants.CKR_OK);
162-
});
163-
164-
when(pkcs11Mock.C_Login(any(NativeLong.class), any(NativeLong.class), any(), any(NativeLong.class)))
165-
.thenReturn(new NativeLong(Pkcs11Constants.CKR_OK));
166-
167-
pkcs11Session = new PKCS11Session(pkcs11Mock, pin, slotId);
168-
169-
when(pkcs11Mock.C_Logout(any(NativeLong.class))).thenThrow(new RuntimeException("Logout failed"));
170-
171-
assertThrows(SessionLogoutException.class, () -> pkcs11Session.logout());
172-
}
173-
174-
@Test
175-
void close_shouldCallCLogoutAndCCloseSessionAndCFinalize() {
176-
when(pkcs11Mock.C_OpenSession(any(NativeLong.class), any(NativeLong.class), isNull(), isNull(), any(NativeLongByReference.class)))
177-
.thenAnswer(invocation -> {
178-
NativeLongByReference sessionRef = invocation.getArgument(4);
179-
sessionRef.setValue(new NativeLong(1));
180-
return new NativeLong(Pkcs11Constants.CKR_OK);
181-
});
182-
183-
when(pkcs11Mock.C_Login(any(NativeLong.class), any(NativeLong.class), any(), any(NativeLong.class)))
184-
.thenReturn(new NativeLong(Pkcs11Constants.CKR_OK));
185-
186-
pkcs11Session = new PKCS11Session(pkcs11Mock, pin, slotId);
187-
188-
when(pkcs11Mock.C_Logout(any(NativeLong.class))).thenReturn(new NativeLong(Pkcs11Constants.CKR_OK));
189-
when(pkcs11Mock.C_CloseSession(any(NativeLong.class))).thenReturn(new NativeLong(Pkcs11Constants.CKR_OK));
190-
when(pkcs11Mock.C_Finalize(isNull())).thenReturn(new NativeLong(Pkcs11Constants.CKR_OK));
191-
192-
pkcs11Session.close();
193-
194-
verify(pkcs11Mock, times(1)).C_Logout(any(NativeLong.class));
195-
verify(pkcs11Mock, times(1)).C_CloseSession(any(NativeLong.class));
196-
verify(pkcs11Mock, times(1)).C_Finalize(isNull());
197-
}
198155

199156
@Test
200157
void close_failure_shouldThrowSessionCloseException() {

0 commit comments

Comments
 (0)