Ejemplo n.º 1
0
  @Test
  public void testGetItem2() throws Exception {

    String link = "link";
    final Item item = new Item(link, "login", "pass");

    // Compare items without password
    databaseControl.addItem(item, password);
    assertEquals(databaseControl.getItem(link, password), item);

    try {

      databaseControl.getItem("wronglink", password);
      fail("Didn't trigger NoSuchItemException.");

    } catch (NoSuchItemException nsie) {
    }

    // Crypted tests
    Password newPassword = new Password("NewPassword".getBytes());

    databaseControl.addItem(item, password);
    databaseControl.setPassword(password, newPassword);

    try {
      databaseControl.getItem(link, password);
      fail("Didn't trigger InvalidPasswordException!");
    } catch (InvalidPasswordException e) {
    }

    assertEquals(databaseControl.getItem(link, newPassword), item);
  }
Ejemplo n.º 2
0
  @Test
  public void testGetItem() throws Exception {

    String link = "link";

    Item item = new Item(link, "username", "password");
    databaseControl.addItem(item, password);
    assertEquals(databaseControl.getItem(link, password), item);
  }