Search in sources :

Example 11 with User

use of org.mamute.model.User in project mamute by caelum.

the class InputRule method isAllowed.

public boolean isAllowed() {
    if (!env.supports("feature.input.rule"))
        return true;
    User current = user.getCurrent();
    boolean isAllowed = input.can(current);
    if (isAllowed)
        input.ping(current);
    return isAllowed;
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser)

Example 12 with User

use of org.mamute.model.User in project mamute by caelum.

the class DaoManager method randomUser.

public User randomUser() {
    this.session.beginTransaction();
    String email = String.format("acceptance%d@brutal.com", randomizer.nextLong());
    User user = new User(SanitizedText.fromTrustedText("Acceptance Test User"), email);
    LoginMethod brutalLogin = LoginMethod.brutalLogin(user, email, "123456");
    user.add(brutalLogin);
    this.userDao.save(user);
    this.loginMethodDao.save(brutalLogin);
    this.session.getTransaction().commit();
    return user;
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) LoginMethod(org.mamute.model.LoginMethod)

Example 13 with User

use of org.mamute.model.User in project mamute by caelum.

the class LDAPAuthenticator method authenticate.

public boolean authenticate(String username, String password) {
    // auth credentials
    if (!ldap.authenticate(username, password)) {
        return false;
    }
    String email = ldap.getEmail(username);
    User retrieved = users.findByEmail(email);
    if (retrieved == null) {
        retrieved = users.findByMailAndLegacyPasswordAndUpdatePassword(email, password);
    }
    if (retrieved == null) {
        return false;
    }
    system.login(retrieved);
    return true;
}
Also used : User(org.mamute.model.User)

Example 14 with User

use of org.mamute.model.User in project mamute by caelum.

the class CommentQuestionTest method login.

@Before
public void login() {
    DaoManager manager = new DaoManager();
    User author = manager.randomUser();
    manager.createQuestion(author);
}
Also used : User(org.mamute.model.User) DaoManager(org.mamute.integration.util.DaoManager) Before(org.junit.Before)

Example 15 with User

use of org.mamute.model.User in project mamute by caelum.

the class VoteUpDownTest method login.

@Before
public void login() {
    DaoManager manager = new DaoManager();
    User author = manager.randomUser();
    Question question = manager.createQuestion(author);
    manager.answerQuestion(author, question);
    loginWithALotOfKarma();
    questionPage = home().toFirstQuestionPage();
}
Also used : User(org.mamute.model.User) Question(org.mamute.model.Question) DaoManager(org.mamute.integration.util.DaoManager) Before(org.junit.Before)

Aggregations

User (org.mamute.model.User)97 Test (org.junit.Test)56 Question (org.mamute.model.Question)28 LoggedUser (org.mamute.model.LoggedUser)25 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)9 UserFlow (br.com.caelum.vraptor.test.requestflow.UserFlow)9 Answer (org.mamute.model.Answer)9 LoginMethod (org.mamute.model.LoginMethod)9 Post (br.com.caelum.vraptor.Post)7 Before (org.junit.Before)7 Tag (org.mamute.model.Tag)7 QuestionInformation (org.mamute.model.QuestionInformation)6 Email (org.apache.commons.mail.Email)5 UserPersonalInfo (org.mamute.dto.UserPersonalInfo)5 ReputationEvent (org.mamute.model.ReputationEvent)5 ArrayList (java.util.ArrayList)4 Watcher (org.mamute.model.watch.Watcher)4 DateTime (org.joda.time.DateTime)3 Elements (org.jsoup.select.Elements)3 DaoManager (org.mamute.integration.util.DaoManager)3