// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container.http; import com.yahoo.config.model.builder.xml.test.DomBuilderTest; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.jdisc.http.ServerConfig; import com.yahoo.vespa.model.container.xml.ContainerModelBuilder; import org.junit.jupiter.api.Test; import org.w3c.dom.Element; import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author bjorncs */ public class StrictFilteringTest extends DomBuilderTest { @Test void strict_filtering_enabled_if_specified_in_services() { Element xml = parse( "", " ", " ", " ", " ", " http://*/my-chain-binding", " ", " ", " ", " ", ""); assertStrictFiltering(true, xml); } @Test void strict_filtering_enabled_by_default_if_filter_present() { Element xml = parse( "", " ", " ", " ", " ", " ", " ", " ", " ", ""); assertStrictFiltering(true, xml); } @Test void strict_filtering_disabled_if_no_filter() { Element xml = parse( "", " ", " ", " ", " ", " ", ""); assertStrictFiltering(false, xml); } private void assertStrictFiltering(boolean expected, Element services) { buildContainerCluster(services); ServerConfig config = root.getConfig(ServerConfig.class, "container/http/jdisc-jetty/server1"); assertEquals(expected, config.strictFiltering()); } private void buildContainerCluster(Element containerElem) { new ContainerModelBuilder(true, ContainerModelBuilder.Networking.enable).build(DeployState.createTestState(), null, null, root, containerElem); root.freezeModelTopology(); } }