forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEODE-6174: Added rest controller to process post request to /geode-m… (
apache#3066) * GEODE-6174: Added rest controller to process post request to /geode-management/v2/regions Co-authored-by: Jens Deppe <[email protected]> Co-authored-by: Peter Tran <[email protected]> * add geode-web-management module to process the management rest api * inject security service into the authProvider instead of static lookup
- Loading branch information
1 parent
2951e61
commit 8c1629a
Showing
25 changed files
with
1,983 additions
and
58 deletions.
There are no files selected for viewing
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
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
58 changes: 58 additions & 0 deletions
58
...rationTest/java/org/apache/geode/management/internal/RegionManagementIntegrationTest.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,58 @@ | ||
/* | ||
* 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.management.internal; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
|
||
import org.apache.geode.cache.configuration.RegionConfig; | ||
import org.apache.geode.test.junit.rules.GeodeDevRestClient; | ||
import org.apache.geode.test.junit.rules.LocatorStarterRule; | ||
import org.apache.geode.test.junit.rules.RequiresGeodeHome; | ||
|
||
public class RegionManagementIntegrationTest { | ||
|
||
@ClassRule | ||
public static LocatorStarterRule locator = | ||
new LocatorStarterRule().withHttpService().withAutoStart(); | ||
|
||
@ClassRule | ||
public static RequiresGeodeHome requiresGeodeHome = new RequiresGeodeHome(); | ||
|
||
public static GeodeDevRestClient restClient; | ||
|
||
@BeforeClass | ||
public static void setUpClass() throws Exception { | ||
restClient = | ||
new GeodeDevRestClient("/geode-management/v2", "localhost", locator.getHttpPort(), false); | ||
} | ||
|
||
@Test | ||
public void sanityCheck() throws Exception { | ||
RegionConfig regionConfig = new RegionConfig(); | ||
regionConfig.setName("customers"); | ||
regionConfig.setRefid("REPLICATE"); | ||
|
||
ObjectMapper mapper = new ObjectMapper(); | ||
String json = mapper.writeValueAsString(regionConfig); | ||
|
||
restClient.doPostAndAssert("/regions", json, null, null) | ||
.hasStatusCode(201) | ||
.hasResponseBody().isEqualTo("customers"); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...st/java/org/apache/geode/management/internal/RegionManagementSecurityIntegrationTest.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,86 @@ | ||
/* | ||
* 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.management.internal; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
|
||
import org.apache.geode.cache.configuration.RegionConfig; | ||
import org.apache.geode.security.SimpleTestSecurityManager; | ||
import org.apache.geode.test.junit.rules.GeodeDevRestClient; | ||
import org.apache.geode.test.junit.rules.LocatorStarterRule; | ||
import org.apache.geode.test.junit.rules.RequiresGeodeHome; | ||
|
||
public class RegionManagementSecurityIntegrationTest { | ||
|
||
@ClassRule | ||
public static LocatorStarterRule locator = new LocatorStarterRule().withHttpService() | ||
.withSecurityManager(SimpleTestSecurityManager.class).withAutoStart(); | ||
|
||
@ClassRule | ||
public static RequiresGeodeHome requiresGeodeHome = new RequiresGeodeHome(); | ||
|
||
public static GeodeDevRestClient restClient; | ||
|
||
@BeforeClass | ||
public static void setUpClass() { | ||
restClient = | ||
new GeodeDevRestClient("/geode-management/v2", "localhost", locator.getHttpPort(), false); | ||
} | ||
|
||
private RegionConfig regionConfig; | ||
private String json; | ||
|
||
@Before | ||
public void before() throws JsonProcessingException { | ||
regionConfig = new RegionConfig(); | ||
regionConfig.setName("customers"); | ||
regionConfig.setRefid("REPLICATE"); | ||
ObjectMapper mapper = new ObjectMapper(); | ||
json = mapper.writeValueAsString(regionConfig); | ||
} | ||
|
||
@Test | ||
public void sanityCheck_not_authorized() throws Exception { | ||
restClient.doPostAndAssert("/regions", json, "test", "test") | ||
.hasStatusCode(403) | ||
.hasResponseBody().isEqualTo("Access is denied"); | ||
} | ||
|
||
@Test | ||
public void sanityCheckWithNoCredentials() throws Exception { | ||
restClient.doPostAndAssert("/regions", json, null, null) | ||
.hasStatusCode(401); | ||
} | ||
|
||
@Test | ||
public void sanityCheckWithWrongCredentials() throws Exception { | ||
restClient.doPostAndAssert("/regions", json, "test", "invalid_pswd") | ||
.hasStatusCode(401); | ||
} | ||
|
||
@Test | ||
public void sanityCheck_success() throws Exception { | ||
restClient.doPostAndAssert("/regions", json, "dataManage", "dataManage") | ||
.hasStatusCode(201) | ||
.hasResponseBody().isEqualTo("customers"); | ||
} | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.