Search in sources :

Example 6 with EmailPasswordAuthToken

use of com.enonic.xp.security.auth.EmailPasswordAuthToken in project xp by enonic.

the class SecurityServiceImplTest method testAuthenticateByEmailPwdWrongPwd.

@Test
public void testAuthenticateByEmailPwdWrongPwd() throws Exception {
    runAsAdmin(() -> {
        final CreateUserParams createUser = CreateUserParams.create().userKey(PrincipalKey.ofUser(SYSTEM, "User1")).displayName("User 1").email("user1@enonic.com").login("User1").password("fisk").build();
        securityService.createUser(createUser);
        refresh();
        final EmailPasswordAuthToken authToken = new EmailPasswordAuthToken();
        authToken.setEmail("user1@enonic.com");
        authToken.setPassword("password");
        authToken.setIdProvider(SYSTEM);
        final AuthenticationInfo authInfo = securityService.authenticate(authToken);
        assertFalse(authInfo.isAuthenticated());
    });
}
Also used : CreateUserParams(com.enonic.xp.security.CreateUserParams) EmailPasswordAuthToken(com.enonic.xp.security.auth.EmailPasswordAuthToken) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) AbstractElasticsearchIntegrationTest(com.enonic.xp.repo.impl.elasticsearch.AbstractElasticsearchIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

AuthenticationInfo (com.enonic.xp.security.auth.AuthenticationInfo)6 EmailPasswordAuthToken (com.enonic.xp.security.auth.EmailPasswordAuthToken)6 UsernamePasswordAuthToken (com.enonic.xp.security.auth.UsernamePasswordAuthToken)3 Test (org.junit.jupiter.api.Test)3 AbstractElasticsearchIntegrationTest (com.enonic.xp.repo.impl.elasticsearch.AbstractElasticsearchIntegrationTest)2 CreateUserParams (com.enonic.xp.security.CreateUserParams)2 IdProvider (com.enonic.xp.security.IdProvider)1 IdProviders (com.enonic.xp.security.IdProviders)1 User (com.enonic.xp.security.User)1 VerifiedEmailAuthToken (com.enonic.xp.security.auth.VerifiedEmailAuthToken)1 VerifiedUsernameAuthToken (com.enonic.xp.security.auth.VerifiedUsernameAuthToken)1 Session (com.enonic.xp.session.Session)1