-
Notifications
You must be signed in to change notification settings - Fork 218
/
AuthorizationHeaderParserTest.java
37 lines (29 loc) · 1.15 KB
/
AuthorizationHeaderParserTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.jolokia.util;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
/**
* @author roland
* @since 26.05.14
*/
public class AuthorizationHeaderParserTest {
@Test
public void testParseAuthorizationPositive() throws Exception {
AuthorizationHeaderParser.Result result =
AuthorizationHeaderParser.parse("Basic cm9sYW5kOnMhY3IhdA==");
assertEquals(result.getUser(),"roland");
assertEquals(result.getPassword(),"s!cr!t");
assertTrue(result.isValid());
}
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*BasicAuthentication.*")
public void testParseAuthorizationWrongMethod() throws Exception {
AuthorizationHeaderParser.parse("Digest cm9sYW5kOnMhY3IhdA==");
}
@Test
public void testParseAuthorizationInvalidFormat() throws Exception {
AuthorizationHeaderParser.Result result =
AuthorizationHeaderParser.parse("Basic cm9sYAZ5kOnMhA=");
assertFalse(result.isValid());
}
}