Ejemplo n.º 1
0
 @Test
 public void missingKeys() throws GeneralSecurityException {
   Biscuit biscuit = new Biscuit.Builder().build();
   assertNull(biscuit.get("404"));
   biscuit.read(new StringReader("k:\n- algorithm: none\n  ciphertext: aGVsbG8K"));
   assertNull(biscuit.get("404"));
   assertNull(biscuit.getString("404"));
   assertNotNull(biscuit.get("k"));
   assertNotNull(biscuit.getString("k"));
 }
Ejemplo n.º 2
0
 @Test
 public void emptyCiphertext() throws GeneralSecurityException {
   Biscuit biscuit = new Biscuit.Builder().build();
   assertNull(biscuit.get("404"));
   assertNull(biscuit.getString("404"));
   biscuit.read(new StringReader("k:\n- algorithm: none\n  ciphertext: \"\""));
   biscuit.read(new StringReader("no_ciphertext:\n- algorithm: none\n"));
   assertNull(biscuit.get("404"));
   assertNull(biscuit.getString("404"));
   assertNotNull(biscuit.get("no_ciphertext"));
   assertNotNull(biscuit.getString("no_ciphertext"));
   assertNotNull(biscuit.get("k"));
   assertNotNull(biscuit.getString("k"));
 }
Ejemplo n.º 3
0
 private void commonTests(Biscuit biscuit) throws GeneralSecurityException {
   String expectedMd5 = "748c617aaee4b9263761ed851769a314";
   for (String algo : new String[] {"none", "aesgcm256", "secretbox"}) {
     assertEquals("v-" + algo, biscuit.getString("k-" + algo));
     byte[] digest = MessageDigest.getInstance("MD5").digest(biscuit.get("k-" + algo + "-big"));
     assertArrayEquals(DatatypeConverter.parseHexBinary(expectedMd5), digest);
   }
 }
Ejemplo n.º 4
0
 @Test
 public void secretsFromJsonFile() throws GeneralSecurityException, IOException {
   Biscuit biscuit = new Biscuit.Builder().build();
   biscuit.readFile(getClass().getResource("secrets.json").getFile());
   assertEquals("v-aesgcm256", biscuit.getString("launchcodes"));
 }