|
37 | 37 | import org.eclipse.biscuit.error.LogicError; |
38 | 38 | import org.eclipse.biscuit.token.builder.Block; |
39 | 39 | import org.junit.jupiter.api.Assertions; |
| 40 | +import org.junit.jupiter.api.BeforeEach; |
40 | 41 | import org.junit.jupiter.api.Test; |
41 | 42 |
|
42 | 43 | public class BiscuitTest { |
43 | 44 |
|
| 45 | + private SecureRandom rng; |
| 46 | + |
| 47 | + @BeforeEach |
| 48 | + public void setUp() throws NoSuchAlgorithmException { |
| 49 | + byte[] seed = {0, 0, 0, 0}; |
| 50 | + rng = SecureRandom.getInstance("SHA1PRNG"); |
| 51 | + rng.setSeed(seed); |
| 52 | + } |
| 53 | + |
44 | 54 | @Test |
45 | 55 | public void testBasic() |
46 | 56 | throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, Error { |
47 | | - byte[] seed = {0, 0, 0, 0}; |
48 | | - SecureRandom rng = new SecureRandom(seed); |
49 | 57 |
|
50 | 58 | System.out.println("preparing the authority block"); |
51 | 59 |
|
@@ -177,9 +185,6 @@ public void testBasic() |
177 | 185 |
|
178 | 186 | @Test |
179 | 187 | public void testFolders() throws NoSuchAlgorithmException, Error { |
180 | | - byte[] seed = {0, 0, 0, 0}; |
181 | | - SecureRandom rng = new SecureRandom(seed); |
182 | | - |
183 | 188 | System.out.println("preparing the authority block"); |
184 | 189 |
|
185 | 190 | KeyPair root = KeyPair.generate(Schema.PublicKey.Algorithm.Ed25519, rng); |
@@ -288,10 +293,7 @@ public void testMultipleAttenuation() |
288 | 293 | } |
289 | 294 |
|
290 | 295 | @Test |
291 | | - public void testReset() throws Error { |
292 | | - byte[] seed = {0, 0, 0, 0}; |
293 | | - SecureRandom rng = new SecureRandom(seed); |
294 | | - |
| 296 | + public void testReset() throws Error, NoSuchAlgorithmException { |
295 | 297 | System.out.println("preparing the authority block"); |
296 | 298 |
|
297 | 299 | KeyPair root = KeyPair.generate(Schema.PublicKey.Algorithm.Ed25519, rng); |
@@ -361,10 +363,7 @@ public void testReset() throws Error { |
361 | 363 | } |
362 | 364 |
|
363 | 365 | @Test |
364 | | - public void testEmptyAuthorizer() throws Error { |
365 | | - byte[] seed = {0, 0, 0, 0}; |
366 | | - SecureRandom rng = new SecureRandom(seed); |
367 | | - |
| 366 | + public void testEmptyAuthorizer() throws Error, NoSuchAlgorithmException { |
368 | 367 | System.out.println("preparing the authority block"); |
369 | 368 |
|
370 | 369 | KeyPair root = KeyPair.generate(Schema.PublicKey.Algorithm.Ed25519, rng); |
@@ -405,9 +404,6 @@ public void testEmptyAuthorizer() throws Error { |
405 | 404 | @Test |
406 | 405 | public void testBasicWithNamespaces() |
407 | 406 | throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, Error { |
408 | | - byte[] seed = {0, 0, 0, 0}; |
409 | | - SecureRandom rng = new SecureRandom(seed); |
410 | | - |
411 | 407 | System.out.println("preparing the authority block"); |
412 | 408 |
|
413 | 409 | KeyPair root = KeyPair.generate(Schema.PublicKey.Algorithm.Ed25519, rng); |
@@ -535,9 +531,6 @@ public void testBasicWithNamespaces() |
535 | 531 | @Test |
536 | 532 | public void testBasicWithNamespacesWithAddAuthorityFact() |
537 | 533 | throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, Error { |
538 | | - byte[] seed = {0, 0, 0, 0}; |
539 | | - SecureRandom rng = new SecureRandom(seed); |
540 | | - |
541 | 534 | System.out.println("preparing the authority block"); |
542 | 535 |
|
543 | 536 | KeyPair root = KeyPair.generate(Schema.PublicKey.Algorithm.Ed25519, rng); |
@@ -664,9 +657,6 @@ public void testBasicWithNamespacesWithAddAuthorityFact() |
664 | 657 | @Test |
665 | 658 | public void testRootKeyId() |
666 | 659 | throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, Error { |
667 | | - byte[] seed = {0, 0, 0, 0}; |
668 | | - SecureRandom rng = new SecureRandom(seed); |
669 | | - |
670 | 660 | System.out.println("preparing the authority block"); |
671 | 661 |
|
672 | 662 | KeyPair root = KeyPair.generate(Schema.PublicKey.Algorithm.Ed25519, rng); |
@@ -739,9 +729,6 @@ public Optional<PublicKey> getRootKey(Optional<Integer> keyId) { |
739 | 729 | @Test |
740 | 730 | public void testCheckAll() |
741 | 731 | throws Error, NoSuchAlgorithmException, SignatureException, InvalidKeyException { |
742 | | - byte[] seed = {0, 0, 0, 0}; |
743 | | - SecureRandom rng = new SecureRandom(seed); |
744 | | - |
745 | 732 | System.out.println("preparing the authority block"); |
746 | 733 |
|
747 | 734 | KeyPair root = KeyPair.generate(Schema.PublicKey.Algorithm.Ed25519, rng); |
|
0 commit comments