コード例 #1
0
 /** Test of passwordCorrect method, of class PassCrypt. */
 @Test
 public void testPasswordCorrect() throws Exception {
   System.out.println("passwordCorrect");
   PassCrypt instance = new PassCrypt("username", "password");
   boolean expResult = true;
   boolean result = instance.passwordCorrect();
   assertEquals(expResult, result);
   // TODO review the generated test code and remove the default call to fail.
 }
コード例 #2
0
 /** Test of getEncryptedPasswordToString method, of class PassCrypt. */
 @Test
 public void testGetPasswordEncrypted() throws UnsupportedEncodingException {
   System.out.println("getPasswordEncrypted");
   byte[] password = "******".getBytes();
   PassCrypt instance = new PassCrypt("dus", "dus");
   String result = instance.getEncryptedPasswordToString(password);
   System.out.println(result);
   //        assertEquals(expResult, result);
   // TODO review the generated test code and remove the default call to fail.
   // fail("The test case is a prototype.");
 }
コード例 #3
0
  /** Test of encryptPassword method, of class PassCrypt. */
  @Test
  public void testEncryptAndDecryptPassword() throws Exception {
    System.out.println("encryptPassword");
    String passwordTXT = "This is a very secret password";
    PassCrypt instance = new PassCrypt();
    String resultEncryption = instance.encryptPassword(passwordTXT);

    System.out.println("decryptPassword");
    String passwordEncrypted = resultEncryption;
    String resultDecryptedPassword = instance.decryptPassword(passwordEncrypted);
    assertEquals(passwordTXT, resultDecryptedPassword);
  }
コード例 #4
0
  /** Test of passwordChange method, of class PassCrypt. */
  @Test
  public void testPasswordChange() throws Exception {
    System.out.println("passwordChange");
    String username = "******";
    String password = "******";
    PassCrypt instance = new PassCrypt("username", "password");

    instance.passwordChange(username, password);
    password = salt + password;
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] encPasswordTest = md.digest(password.getBytes("UTF-8"));
    String encPasswordTestString = instance.getEncryptedPasswordToString(encPasswordTest);

    XMLhandler xml = new XMLhandler();
    String encPassword = xml.getPassword();
    assertEquals(encPassword, encPasswordTestString);
    System.out.println("Testvalue: " + encPasswordTestString);
    System.out.println("Storedvalue: " + encPassword);
  }