From 75c902f9163ca8f00838578ac382f2bfead71e9a Mon Sep 17 00:00:00 2001 From: gjoranv Date: Mon, 16 Mar 2020 01:53:29 +0100 Subject: Verify that reserved bindings cannot be stolen. --- .../model/container/xml/ContainerModelBuilderTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'config-model') diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java index 926846f29a3..17dff46bed4 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java @@ -66,6 +66,7 @@ import static com.yahoo.config.model.test.TestUtil.joinLines; import static com.yahoo.test.LinePatternMatcher.containsLineWithPattern; import static com.yahoo.vespa.defaults.Defaults.getDefaults; import static com.yahoo.vespa.model.container.ContainerCluster.ROOT_HANDLER_BINDING; +import static com.yahoo.vespa.model.container.ContainerCluster.STATE_HANDLER_BINDING_1; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.notNullValue; @@ -254,6 +255,23 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase { assertThat(discBindingsConfig.handlers(BindingsOverviewHandler.class.getName()), is(nullValue())); } + @Test + public void reserved_binding_cannot_be_stolen_by_user_configured_handler() { + Element clusterElem = DomBuilderTest.parse( + "" + + " " + + " " + STATE_HANDLER_BINDING_1 + "" + + " " + + ""); + try { + createModel(root, clusterElem); + fail("Expected exception when stealing a reserved binding."); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), is("Binding 'http://*/state/v1' is a reserved Vespa binding " + + "and cannot be used by handler: userHandler")); + } + } + @Test public void handler_bindings_are_included_in_discBindings_config() { createClusterWithJDiscHandler(); -- cgit v1.2.3