Skip to content

Commit

Permalink
SYMMETRICDS-437
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed May 12, 2011
1 parent 1054e1f commit 5a5ec1e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 40 deletions.
Expand Up @@ -56,17 +56,17 @@ public static Collection<Object[]> authenticationFilterParams() {
final Map<String, String> goodAuthentication = new HashMap<String, String>();
goodAuthentication.put(WebConstants.SECURITY_TOKEN, MockNodeService.GOOD_SECURITY_TOKEN);
goodAuthentication.put(WebConstants.NODE_ID, MockNodeService.GOOD_NODE_ID);
return Arrays.asList(new Object[][] { { "GET", "/ack", goodAuthentication }, { "POST", "/ack", goodAuthentication },
{ "PUT", "/ack", goodAuthentication }, { "DELETE", "/ack", goodAuthentication },
{ "TRACE", "/ack", goodAuthentication }, { "OPTIONS", "/ack", goodAuthentication },
{ "HEAD", "/ack", goodAuthentication }, { "GET", "/pull", goodAuthentication },
{ "POST", "/pull", goodAuthentication }, { "PUT", "/pull", goodAuthentication },
{ "DELETE", "/pull", goodAuthentication }, { "TRACE", "/pull", goodAuthentication },
{ "OPTIONS", "/pull", goodAuthentication }, { "HEAD", "/pull", goodAuthentication },
{ "GET", "/push", goodAuthentication }, { "POST", "/push", goodAuthentication },
{ "PUT", "/push", goodAuthentication }, { "DELETE", "/push", goodAuthentication },
{ "TRACE", "/push", goodAuthentication }, { "OPTIONS", "/push", goodAuthentication },
{ "HEAD", "/push", goodAuthentication } });
return Arrays.asList(new Object[][] { { "GET", "/sync/ack", goodAuthentication }, { "POST", "/sync/ack", goodAuthentication },
{ "PUT", "/sync/ack", goodAuthentication }, { "DELETE", "/sync/ack", goodAuthentication },
{ "TRACE", "/sync/ack", goodAuthentication }, { "OPTIONS", "/sync/ack", goodAuthentication },
{ "HEAD", "/sync/ack", goodAuthentication }, { "GET", "/sync/pull", goodAuthentication },
{ "POST", "/sync/pull", goodAuthentication }, { "PUT", "/sync/pull", goodAuthentication },
{ "DELETE", "/sync/pull", goodAuthentication }, { "TRACE", "/sync/pull", goodAuthentication },
{ "OPTIONS", "/sync/pull", goodAuthentication }, { "HEAD", "/sync/pull", goodAuthentication },
{ "GET", "/sync/push", goodAuthentication }, { "POST", "/sync/push", goodAuthentication },
{ "PUT", "/sync/push", goodAuthentication }, { "DELETE", "/sync/push", goodAuthentication },
{ "TRACE", "/sync/push", goodAuthentication }, { "OPTIONS", "/sync/push", goodAuthentication },
{ "HEAD", "/sync/push", goodAuthentication } });
}

@Test
Expand Down
Expand Up @@ -41,7 +41,7 @@
public class InetAddressFilterTest extends AbstractWebTest {
public static final String[] HTTP_METHODS = { "GET", "POST", "DELETE", "PUT", "TRACE", "OPTIONS" };

public static final String[] URIS = { "/ack", "/push", "/pull" };
public static final String[] URIS = { "/sync/ack", "/sync/push", "/sync/pull" };

public static final String COMBO_ADDRESS_FILTER = "105.100-10.5.15, 206.123.*.90, 184.*.209.210-99, 64-1.78.81.*, 164-120.*.181-50.*, 15-10.240-155.181-50.211-2";

Expand Down
Expand Up @@ -40,9 +40,7 @@
import org.springframework.mock.web.MockHttpServletResponse;

/**
* This simply makes sure the SymmetricFilter is setup correctly.
*
*
* This simply makes sure the SymmetricFilter is setup correctly.
*/
@RunWith(Parameterized.class)
public class SymmetricForbiddenFilterTest extends AbstractSymmetricFilterTest {
Expand All @@ -58,25 +56,25 @@ public static Collection<Object[]> authenticationFilterForbiddenParams() {
emptyAuthentication.put(WebConstants.SECURITY_TOKEN, "");
emptyAuthentication.put(WebConstants.NODE_ID, "");

return Arrays.asList(new Object[][] { { "GET", "/ack", null }, { "GET", "/ack/", null },
{ "GET", "/ack/more", null }, { "GET", "/ack?name=value", null },
{ "GET", "/ack?name=value&name=value", null },
{ "GET", String.format("/ack?%s=1&%s=2", WebConstants.SECURITY_TOKEN, WebConstants.NODE_ID), null },
{ "GET", "/ack", emptyAuthentication }, { "PUT", "/ack", null }, { "POST", "/ack", null },
{ "DELETE", "/ack", null }, { "TRACE", "/ack", null }, { "OPTIONS", "/ack", null },
{ "HEAD", "/ack", null }, { "GET", "/pull", null }, { "GET", "/pull/", null },
{ "GET", "/pull/more", null }, { "GET", "/pull?name=value", null },
{ "GET", "/pull?name=value&name=value", null },
{ "GET", String.format("/pull?%s=1&%s=2", WebConstants.SECURITY_TOKEN, WebConstants.NODE_ID), null },
{ "GET", "/pull", emptyAuthentication }, { "PUT", "/pull", null }, { "POST", "/pull", null },
{ "DELETE", "/pull", null }, { "TRACE", "/pull", null }, { "OPTIONS", "/pull", null },
{ "HEAD", "/pull", null }, { "GET", "/push", null }, { "GET", "/push/", null },
{ "GET", "/push/more", null }, { "GET", "/push?name=value", null },
{ "GET", "/push?name=value&name=value", null },
{ "GET", String.format("/push?%s=1&%s=2", WebConstants.SECURITY_TOKEN, WebConstants.NODE_ID), null },
{ "GET", "/push", emptyAuthentication }, { "PUT", "/push", null }, { "POST", "/push", null },
{ "DELETE", "/push", null }, { "TRACE", "/push", null }, { "OPTIONS", "/push", null },
{ "HEAD", "/push", null }, });
return Arrays.asList(new Object[][] { { "GET", "/sync/ack", null }, { "GET", "/sync/ack/", null },
{ "GET", "/sync/ack/more", null }, { "GET", "/sync/ack?name=value", null },
{ "GET", "/sync/ack?name=value&name=value", null },
{ "GET", String.format("/sync/ack?%s=1&%s=2", WebConstants.SECURITY_TOKEN, WebConstants.NODE_ID), null },
{ "GET", "/sync/ack", emptyAuthentication }, { "PUT", "/sync/ack", null }, { "POST", "/sync/ack", null },
{ "DELETE", "/sync/ack", null }, { "TRACE", "/sync/ack", null }, { "OPTIONS", "/sync/ack", null },
{ "HEAD", "/sync/ack", null }, { "GET", "/sync/pull", null }, { "GET", "/sync/pull/", null },
{ "GET", "/sync/pull/more", null }, { "GET", "/sync/pull?name=value", null },
{ "GET", "/sync/pull?name=value&name=value", null },
{ "GET", String.format("/sync/pull?%s=1&%s=2", WebConstants.SECURITY_TOKEN, WebConstants.NODE_ID), null },
{ "GET", "/sync/pull", emptyAuthentication }, { "PUT", "/sync/pull", null }, { "POST", "/sync/pull", null },
{ "DELETE", "/sync/pull", null }, { "TRACE", "/sync/pull", null }, { "OPTIONS", "/sync/pull", null },
{ "HEAD", "/sync/pull", null }, { "GET", "/sync/push", null }, { "GET", "/sync/push/", null },
{ "GET", "/sync/push/more", null }, { "GET", "/sync/push?name=value", null },
{ "GET", "/sync/push?name=value&name=value", null },
{ "GET", String.format("/sync/push?%s=1&%s=2", WebConstants.SECURITY_TOKEN, WebConstants.NODE_ID), null },
{ "GET", "/sync/push", emptyAuthentication }, { "PUT", "/sync/push", null }, { "POST", "/sync/push", null },
{ "DELETE", "/sync/push", null }, { "TRACE", "/sync/push", null }, { "OPTIONS", "/sync/push", null },
{ "HEAD", "/sync/push", null }, });
}

@Test
Expand Down
Expand Up @@ -38,9 +38,7 @@
import org.springframework.mock.web.MockHttpServletResponse;

/**
* This simply makes sure the SymmetricFilter is setup correctly.
*
*
* This simply makes sure the SymmetricFilter is setup correctly.
*/
@RunWith(Parameterized.class)
public class SymmetricRegistrationRequiredTest extends AbstractSymmetricFilterTest {
Expand All @@ -58,15 +56,14 @@ public static Collection<Object[]> authenticationFilterRegistrationRequiredParam
final Map<String, String> badAuthentication = new HashMap<String, String>();
badAuthentication.put(WebConstants.SECURITY_TOKEN, BAD_SECURITY_TOKEN);
badAuthentication.put(WebConstants.NODE_ID, BAD_NODE_ID);
return Arrays.asList(new Object[][] { { "GET", "/ack", badAuthentication },
{ "GET", "/pull", badAuthentication }, { "GET", "/push", badAuthentication } });
return Arrays.asList(new Object[][] { { "GET", "/sync/ack", badAuthentication },
{ "GET", "/sync/pull", badAuthentication }, { "GET", "/sync/push", badAuthentication } });
}

@Test
public void testAuthenticationFilterRegistrationRequired() throws Exception {
final SymmetricFilter filter = new SymmetricFilter();
filter.init(new MockFilterConfig(servletContext));

final MockHttpServletRequest request = TestSetupUtil.createMockHttpServletRequest(servletContext, method, uri,
parameters);
final MockHttpServletResponse response = new MockHttpServletResponse();
Expand Down

0 comments on commit 5a5ec1e

Please sign in to comment.