|
@@ -19,18 +19,13 @@
|
|
|
package org.apache.hadoop.lib.wsrs;
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
-import static org.junit.Assert.assertNotNull;
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
|
|
|
import java.security.Principal;
|
|
|
|
|
|
import javax.ws.rs.core.MultivaluedMap;
|
|
|
|
|
|
-import org.apache.hadoop.test.TestException;
|
|
|
-import org.apache.hadoop.test.TestExceptionHelper;
|
|
|
-import org.junit.Rule;
|
|
|
import org.junit.Test;
|
|
|
-import org.junit.rules.MethodRule;
|
|
|
import org.mockito.Mockito;
|
|
|
import org.slf4j.MDC;
|
|
|
|
|
@@ -40,9 +35,6 @@ import com.sun.jersey.core.spi.component.ComponentScope;
|
|
|
|
|
|
public class TestUserProvider {
|
|
|
|
|
|
- @Rule
|
|
|
- public MethodRule exceptionHelper = new TestExceptionHelper();
|
|
|
-
|
|
|
@Test
|
|
|
@SuppressWarnings("unchecked")
|
|
|
public void noUser() {
|
|
@@ -100,51 +92,4 @@ public class TestUserProvider {
|
|
|
assertEquals(up.getInjectable(null, null, Principal.class), up);
|
|
|
assertNull(up.getInjectable(null, null, String.class));
|
|
|
}
|
|
|
-
|
|
|
- @Test
|
|
|
- @TestException(exception = IllegalArgumentException.class)
|
|
|
- public void userNameEmpty() {
|
|
|
- UserProvider.UserParam userParam = new UserProvider.UserParam("username");
|
|
|
- userParam.parseParam("");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- @TestException(exception = IllegalArgumentException.class)
|
|
|
- public void userNameTooLong() {
|
|
|
- UserProvider.UserParam userParam = new UserProvider.UserParam("username");
|
|
|
- userParam.parseParam("a123456789012345678901234567890x");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- @TestException(exception = IllegalArgumentException.class)
|
|
|
- public void userNameInvalidStart() {
|
|
|
- UserProvider.UserParam userParam = new UserProvider.UserParam("username");
|
|
|
- userParam.parseParam("1x");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- @TestException(exception = IllegalArgumentException.class)
|
|
|
- public void userNameInvalidDollarSign() {
|
|
|
- UserProvider.UserParam userParam = new UserProvider.UserParam("username");
|
|
|
- userParam.parseParam("1$x");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void userNameMinLength() {
|
|
|
- UserProvider.UserParam userParam = new UserProvider.UserParam("username");
|
|
|
- assertNotNull(userParam.parseParam("a"));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void userNameMaxLength() {
|
|
|
- UserProvider.UserParam userParam = new UserProvider.UserParam("username");
|
|
|
- assertNotNull(userParam.parseParam("a123456789012345678901234567890"));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void userNameValidDollarSign() {
|
|
|
- UserProvider.UserParam userParam = new UserProvider.UserParam("username");
|
|
|
- assertNotNull(userParam.parseParam("a$"));
|
|
|
- }
|
|
|
-
|
|
|
}
|