44
55package ch .iterate .hub .workflows ;
66
7- import ch .cyberduck .core .Host ;
8-
97import org .cryptomator .cryptolib .common .P384KeyPair ;
108import org .junit .jupiter .api .Test ;
119import org .mockito .Mockito ;
3836class WoTServiceImplTest {
3937
4038 @ Test
41- void getTrustLevelsPerUserId () throws ParseException , JOSEException , ApiException , AccessException , SecurityFailure {
39+ void testGetTrustLevelsPerUserId () throws ParseException , JOSEException , ApiException , AccessException , SecurityFailure {
4240 final List <String > bobSignatureChain = new LinkedList <>();
4341 int len = 5 ;
4442
@@ -86,17 +84,15 @@ void getTrustLevelsPerUserId() throws ParseException, JOSEException, ApiExceptio
8684
8785 final UsersResourceApi usersMock = Mockito .mock (UsersResourceApi .class );
8886 final WoTServiceImpl wot = new WoTServiceImpl (usersMock );
89- final Host hub = Mockito .mock (Host .class );
9087 Mockito .when (usersMock .apiUsersMeGet (true )).thenReturn (alice );
9188 Mockito .when (usersMock .apiUsersGet ()).thenReturn (Arrays .asList (alice , bob , oscar ));
9289 Mockito .when (usersMock .apiUsersTrustedGet ()).thenReturn (Arrays .asList (bobTrust , oscarTrust ));
9390
9491 assertEquals (Collections .singletonMap (bob .getId (), 5 ), wot .getTrustLevelsPerUserId (aliceKeys ));
9592 }
9693
97-
9894 @ Test
99- void verify () throws ParseException , JOSEException , ApiException , AccessException , SecurityFailure {
95+ void testVerify () throws ParseException , JOSEException , ApiException , AccessException , SecurityFailure {
10096 final List <String > signatureChain = new LinkedList <>();
10197 int len = 5 ;
10298
@@ -106,9 +102,9 @@ void verify() throws ParseException, JOSEException, ApiException, AccessExceptio
106102 .name ("bob" )
107103 .ecdhPublicKey (encodePublicKey (bobKeys .ecdhKeyPair ().getPublic ()))
108104 .ecdsaPublicKey (encodePublicKey (bobKeys .ecdsaKeyPair ().getPublic ()));
105+
109106 UserKeys previousKeys = bobKeys ;
110107 UserDto previousUser = bob ;
111-
112108 for (int i = 0 ; i < len ; i ++) {
113109 final UserKeys userKeys = UserKeys .create ();
114110 final UserDto user = new UserDto ()
@@ -126,7 +122,6 @@ void verify() throws ParseException, JOSEException, ApiException, AccessExceptio
126122 final UserKeys aliceKeys = previousKeys ;
127123
128124 final UsersResourceApi usersMock = Mockito .mock (UsersResourceApi .class );
129- final Host hub = Mockito .mock (Host .class );
130125 Mockito .when (usersMock .apiUsersMeGet (true )).thenReturn (alice );
131126
132127 final WoTServiceImpl wot = new WoTServiceImpl (usersMock );
@@ -135,7 +130,7 @@ void verify() throws ParseException, JOSEException, ApiException, AccessExceptio
135130 }
136131
137132 @ Test
138- void sign () throws ApiException , ParseException , JOSEException , AccessException , SecurityFailure {
133+ void testSign () throws ApiException , ParseException , JOSEException , AccessException , SecurityFailure {
139134 final UserKeys aliceKeys = UserKeys .create ();
140135 final P384KeyPair bobEcdhKeys = P384KeyPair .generate ();
141136 final P384KeyPair bobEcdsaKeys = P384KeyPair .generate ();
@@ -148,7 +143,6 @@ void sign() throws ApiException, ParseException, JOSEException, AccessException,
148143 final String expectedSignature = WoT .sign (aliceKeys .ecdsaKeyPair ().getPrivate (), alice .getId (), bob );
149144
150145 final UsersResourceApi usersMock = Mockito .mock (UsersResourceApi .class );
151- final Host hub = Mockito .mock (Host .class );
152146 Mockito .when (usersMock .apiUsersMeGet (true )).thenReturn (alice );
153147 final WoTServiceImpl wot = new WoTServiceImpl (usersMock );
154148 final TrustedUserDto expectedTrust = new TrustedUserDto ().trustedUserId (bob .getId ()).signatureChain (Collections .singletonList (expectedSignature ));
@@ -158,4 +152,4 @@ void sign() throws ApiException, ParseException, JOSEException, AccessException,
158152 Mockito .verify (usersMock , times (1 )).apiUsersTrustedUserIdPut (eq (bob .getId ()), anyString ());
159153 assertEquals (expectedTrust , trust );
160154 }
161- }
155+ }
0 commit comments