コード例 #1
0
  public void testLongNames() {
    int maxLogin = UserDefaults.get().getMaxUserLength();
    int maxPassword = UserDefaults.get().getMaxPasswordLength();
    int emailLength = UserDefaults.get().getMaxEmailLength();
    Config.get().setString(UserDefaults.MAX_USER_LENGTH, String.valueOf(5));
    Config.get().setString(UserDefaults.MAX_PASSWORD_LENGTH, String.valueOf(5));
    Config.get().setString(UserDefaults.MAX_EMAIL_LENGTH, String.valueOf(5));

    String invalidLogin = TestUtils.randomString();
    String invalidPassword = "******";
    String invalidEmail = "*****@*****.**";
    String validPrefix = "Sr.";

    // Test invalid values
    command.setLogin(invalidLogin);
    command.setEmail(invalidEmail);
    command.setPassword(invalidPassword);
    command.setPrefix(validPrefix);
    command.setFirstNames("testuser");
    command.setLastName("testuser");
    // We should get 4 errors (login, email, password, prefix)
    Object[] errors = command.validate();
    Config.get().setString(UserDefaults.MAX_USER_LENGTH, String.valueOf(maxLogin));
    Config.get().setString(UserDefaults.MAX_PASSWORD_LENGTH, String.valueOf(maxPassword));
    Config.get().setString(UserDefaults.MAX_EMAIL_LENGTH, String.valueOf(emailLength));
    assertEquals(3, errors.length);
  }
コード例 #2
0
ファイル: UserHandler.java プロジェクト: pgervase/spacewalk
 private String getDefaultPasswordForPamAuth() {
   // taken from line 169 of CreateUserAction
   // this is utter crap.  We don't require a password when
   // we set use pam authentication, yet the password field
   // in the database is NOT NULL.  So we have to create this
   // stupid HACK!  Actually this is beyond HACK.
   return RandomStringUtils.random(UserDefaults.get().getMinPasswordLength());
 }