You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by jinmeiliao <gi...@git.apache.org> on 2016/11/07 18:29:15 UTC

[GitHub] incubator-geode pull request #276: GEODE-1993: postprocess region/key

Github user jinmeiliao commented on a diff in the pull request:

    https://github.com/apache/incubator-geode/pull/276#discussion_r86821510
  
    --- Diff: geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java ---
    @@ -0,0 +1,185 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
    + * agreements. See the NOTICE file distributed with this work for additional information regarding
    + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance with the License. You may obtain a
    + * copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software distributed under the License
    + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
    + * or implied. See the License for the specific language governing permissions and limitations under
    + * the License.
    + */
    +package org.apache.geode.rest.internal.web;
    +
    +import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
    +import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
    +import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
    +import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_POST_PROCESSOR;
    +import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_REST_API;
    +import static org.apache.geode.rest.internal.web.GeodeRestClient.getCode;
    +import static org.apache.geode.rest.internal.web.GeodeRestClient.getContentType;
    +import static org.apache.geode.rest.internal.web.GeodeRestClient.getJsonArray;
    +import static org.apache.geode.rest.internal.web.GeodeRestClient.getJsonObject;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertTrue;
    +
    +import org.apache.commons.io.IOUtils;
    +import org.apache.geode.cache.Region;
    +import org.apache.geode.cache.RegionShortcut;
    +import org.apache.geode.cache.execute.FunctionService;
    +import org.apache.geode.internal.AvailablePortHelper;
    +import org.apache.geode.rest.internal.web.controllers.GetRegions;
    +import org.apache.geode.security.templates.SamplePostProcessor;
    +import org.apache.geode.security.templates.SampleSecurityManager;
    +import org.apache.geode.test.dunit.rules.ServerStarterRule;
    +import org.apache.geode.test.junit.categories.IntegrationTest;
    +import org.apache.geode.test.junit.categories.SecurityTest;
    +import org.apache.http.HttpResponse;
    +import org.json.JSONArray;
    +import org.json.JSONObject;
    +import org.junit.BeforeClass;
    +import org.junit.ClassRule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.springframework.http.MediaType;
    +
    +import java.net.URLEncoder;
    +import java.util.Properties;
    +
    +
    +@Category({IntegrationTest.class, SecurityTest.class})
    +public class RestSecurityPostProcessorTest {
    +
    +  static final String REGION_NAME = "AuthRegion";
    +
    +  static int restPort = AvailablePortHelper.getRandomAvailableTCPPort();
    +  static Properties properties = new Properties() {
    +    {
    +      setProperty(SampleSecurityManager.SECURITY_JSON,
    +          "org/apache/geode/management/internal/security/clientServer.json");
    +      setProperty(SECURITY_MANAGER, SampleSecurityManager.class.getName());
    +      setProperty(START_DEV_REST_API, "true");
    +      setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
    +      setProperty(HTTP_SERVICE_PORT, restPort + "");
    +      setProperty(SECURITY_POST_PROCESSOR, SamplePostProcessor.class.getName());
    +    }
    +  };
    +
    +  @ClassRule
    +  public static ServerStarterRule serverStarter = new ServerStarterRule(properties);
    +  private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
    +
    +  @BeforeClass
    +  public static void before() throws Exception {
    +    serverStarter.startServer();
    --- End diff --
    
    I think I just made a change in the rule that you don't need to call startServer anymore if you are using is as a rule.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---