forked from bigjosh/subethasmtp
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bac27e
commit 8db2f97
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/test/java/org/subethamail/smtp/PlainAuthenticationHandlerFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.subethamail.smtp; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
import org.subethamail.smtp.auth.LoginFailedException; | ||
import org.subethamail.smtp.auth.PlainAuthenticationHandlerFactory; | ||
import org.subethamail.smtp.auth.UsernamePasswordValidator; | ||
|
||
public class PlainAuthenticationHandlerFactoryTest { | ||
|
||
@Test | ||
public void test() throws RejectException { | ||
MessageContext context = Mockito.mock(MessageContext.class); | ||
UsernamePasswordValidator validator = (username, password, c) -> { | ||
if (!username.equals("fred") || !password.equals("blah")) { | ||
throw new LoginFailedException(); | ||
} | ||
}; | ||
AuthenticationHandler auth = new PlainAuthenticationHandlerFactory(validator).create(); | ||
try { | ||
auth.auth("AUTH PLAIN b", context); | ||
Assert.fail(); | ||
} catch (RejectException e) { | ||
assertEquals("Invalid command argument, not a valid Base64 string", e.getMessage()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,4 +243,5 @@ public void testBadPass() throws Exception { | |
send("bad-password"); | ||
expect("501"); | ||
} | ||
|
||
} |