@@ -97,6 +97,7 @@ public void testInstantiateFormat8GCMCloudAccessWithWrongVaultVersion() {
9797 .withJWTId (UUID .randomUUID ().toString ())
9898 .withClaim ("format" , 9 )
9999 .withClaim ("cipherCombo" , "SIV_GCM" )
100+ .withClaim ("shorteningThreshold" , Integer .MAX_VALUE )
100101 .sign (algorithm );
101102 var in = new ByteArrayInputStream (token .getBytes (StandardCharsets .US_ASCII ));
102103 localProvider .write (CloudPath .of ("/vaultconfig.jwt" ), false , in , in .available (), Optional .empty (), ProgressListener .NO_PROGRESS_AWARE ).toCompletableFuture ().join ();
@@ -115,6 +116,7 @@ public void testInstantiateFormat8GCMCloudAccessWithWrongCiphermode() {
115116 .withJWTId (UUID .randomUUID ().toString ())
116117 .withClaim ("format" , 8 )
117118 .withClaim ("cipherCombo" , "FOO" )
119+ .withClaim ("shorteningThreshold" , Integer .MAX_VALUE )
118120 .sign (algorithm );
119121 var in = new ByteArrayInputStream (token .getBytes (StandardCharsets .US_ASCII ));
120122 localProvider .write (CloudPath .of ("/vaultconfig.jwt" ), false , in , in .available (), Optional .empty (), ProgressListener .NO_PROGRESS_AWARE ).toCompletableFuture ().join ();
@@ -133,12 +135,32 @@ public void testInstantiateFormat8GCMCloudAccessWithWrongKey() {
133135 var token = JWT .create ()
134136 .withJWTId (UUID .randomUUID ().toString ())
135137 .withClaim ("format" , 8 )
136- .withClaim ("cipherCombo" , "FOO" )
138+ .withClaim ("cipherCombo" , "SIV_GCM" )
139+ .withClaim ("shorteningThreshold" , Integer .MAX_VALUE )
137140 .sign (algorithm );
138141 var in = new ByteArrayInputStream (token .getBytes (StandardCharsets .US_ASCII ));
139142 localProvider .write (CloudPath .of ("/vaultconfig.jwt" ), false , in , in .available (), Optional .empty (), ProgressListener .NO_PROGRESS_AWARE ).toCompletableFuture ().join ();
140143
141144 Assertions .assertThrows (VaultKeyVerificationFailedException .class , () -> CloudAccess .vaultFormat8GCMCloudAccess (localProvider , CloudPath .of ("/" ), new byte [64 ]));
142145 }
143146
147+ @ Test
148+ @ DisplayName ("init with shorteningThreshold" )
149+ public void testInstantiateFormat8GCMCloudAccessWithShortening () {
150+ Assumptions .assumeFalse (localProvider .exists (CloudPath .of ("/vaultconfig.jwt" )).toCompletableFuture ().join ());
151+
152+ byte [] masterkey = new byte [64 ];
153+ Algorithm algorithm = Algorithm .HMAC256 (masterkey );
154+ var token = JWT .create ()
155+ .withJWTId (UUID .randomUUID ().toString ())
156+ .withClaim ("format" , 8 )
157+ .withClaim ("cipherCombo" , "SIV_GCM" )
158+ .withClaim ("shorteningThreshold" , 42 )
159+ .sign (algorithm );
160+ var in = new ByteArrayInputStream (token .getBytes (StandardCharsets .US_ASCII ));
161+ localProvider .write (CloudPath .of ("/vaultconfig.jwt" ), false , in , in .available (), Optional .empty (), ProgressListener .NO_PROGRESS_AWARE ).toCompletableFuture ().join ();
162+
163+ Assertions .assertThrows (VaultVerificationFailedException .class , () -> CloudAccess .vaultFormat8GCMCloudAccess (localProvider , CloudPath .of ("/" ), new byte [64 ]));
164+ }
165+
144166}
0 commit comments