Repository: incubator-brooklyn Updated Branches: refs/heads/master 3e11e3eaa -> c2e55c0f0
Fix REST api location returning config Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/4c7be585 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/4c7be585 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/4c7be585 Branch: refs/heads/master Commit: 4c7be5850226243bc34e84ac4fe880816d6631f9 Parents: 2f9e0e6 Author: Aled Sage <[email protected]> Authored: Mon Jul 13 16:48:32 2015 +0100 Committer: Aled Sage <[email protected]> Committed: Mon Jul 13 17:36:24 2015 +0100 ---------------------------------------------------------------------- .../rest/transform/LocationTransformer.java | 2 +- .../rest/resources/LocationResourceTest.java | 35 ++++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c7be585/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java ---------------------------------------------------------------------- diff --git a/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java b/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java index 6df1d4f..32304bc 100644 --- a/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java +++ b/usage/rest-server/src/main/java/brooklyn/rest/transform/LocationTransformer.java @@ -178,7 +178,7 @@ public class LocationTransformer { configOrig.put(LocationConfigKeys.DISPLAY_NAME.getName(), configExtra.get(LocationConfigKeys.DISPLAY_NAME.getName())); } } - Map<String, ?> config = level!=LocationDetailLevel.NONE ? null : copyConfig(configOrig, level); + Map<String, ?> config = level==LocationDetailLevel.NONE ? null : copyConfig(configOrig, level); return new LocationSummary( l.getId(), http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4c7be585/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java ---------------------------------------------------------------------- diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java b/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java index 4ff3a5d..11a889c 100644 --- a/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java +++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/LocationResourceTest.java @@ -34,12 +34,6 @@ import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.Test; -import brooklyn.location.jclouds.JcloudsLocation; -import brooklyn.rest.domain.CatalogLocationSummary; -import brooklyn.rest.domain.LocationSummary; -import brooklyn.rest.testing.BrooklynRestResourceTest; -import brooklyn.test.Asserts; - import com.google.api.client.repackaged.com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; @@ -48,6 +42,14 @@ import com.google.common.collect.Iterables; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; +import brooklyn.location.LocationSpec; +import brooklyn.location.basic.SimulatedLocation; +import brooklyn.location.jclouds.JcloudsLocation; +import brooklyn.rest.domain.CatalogLocationSummary; +import brooklyn.rest.domain.LocationSummary; +import brooklyn.rest.testing.BrooklynRestResourceTest; +import brooklyn.test.Asserts; + @Test(singleThreaded = true) public class LocationResourceTest extends BrooklynRestResourceTest { @@ -148,6 +150,27 @@ public class LocationResourceTest extends BrooklynRestResourceTest { assertEquals(location.getSpec(), "brooklyn.catalog:"+locationName+":"+locationVersion); } + @SuppressWarnings("deprecation") + @Test + public void testGetLocationConfig() { + SimulatedLocation parentLoc = (SimulatedLocation) getManagementContext().getLocationManager().createLocation(LocationSpec.create(SimulatedLocation.class) + .configure("myParentKey", "myParentVal")); + SimulatedLocation loc = (SimulatedLocation) getManagementContext().getLocationManager().createLocation(LocationSpec.create(SimulatedLocation.class) + .parent(parentLoc) + .configure("mykey", "myval") + .configure("password", "mypassword")); + + // "full" means including-inherited, filtered to exclude secrets + URI uriFull = URI.create("/v1/locations/"+loc.getId()+"?full=true"); + LocationSummary summaryFull = client().resource(uriFull).get(LocationSummary.class); + assertEquals(summaryFull.getConfig(), ImmutableMap.of("mykey", "myval", "myParentKey", "myParentVal"), "conf="+summaryFull.getConfig()); + + // Default is local-only, filtered to exclude secrets + URI uriDefault = URI.create("/v1/locations/"+loc.getId()); + LocationSummary summaryDefault = client().resource(uriDefault).get(LocationSummary.class); + assertEquals(summaryDefault.getConfig(), ImmutableMap.of("mykey", "myval"), "conf="+summaryDefault.getConfig()); + } + @Test(dependsOnMethods = { "testAddLegacyLocationDefinition" }) @Deprecated public void testDeleteLocation() {
