use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class HttpBuilder method doBuild.
@Override
protected Http doBuild(AbstractConfigProducer ancestor, Element spec) {
FilterChains filterChains;
List<Binding> bindings = new ArrayList<>();
AccessControl accessControl = null;
Element filteringElem = XML.getChild(spec, "filtering");
if (filteringElem != null) {
filterChains = new FilterChainsBuilder().build(ancestor, filteringElem);
bindings = readFilterBindings(filteringElem);
Element accessControlElem = XML.getChild(filteringElem, "access-control");
if (accessControlElem != null) {
accessControl = buildAccessControl(ancestor, accessControlElem);
bindings.addAll(accessControl.getBindings());
filterChains.add(new Chain<>(FilterChains.emptyChainSpec(ACCESS_CONTROL_CHAIN_ID)));
}
} else {
filterChains = new FilterChainsBuilder().newChainsInstance(ancestor);
}
Http http = new Http(bindings, accessControl);
http.setFilterChains(filterChains);
buildHttpServers(ancestor, http, spec);
return http;
}
use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class AccessControlTest method access_control_filter_chain_is_set_up.
@Test
public void access_control_filter_chain_is_set_up() throws Exception {
Element clusterElem = DomBuilderTest.parse(" <http>", " <filtering>", " <access-control domain='foo' />", " </filtering>", " </http>");
Http http = new HttpBuilder().build(root, clusterElem);
root.freezeModelTopology();
assertTrue(http.getFilterChains().hasChain(AccessControl.ACCESS_CONTROL_CHAIN_ID));
}
use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class AccessControlTest method read_is_disabled_and_write_is_enabled_by_default.
@Test
public void read_is_disabled_and_write_is_enabled_by_default() throws Exception {
Element clusterElem = DomBuilderTest.parse(" <http>", " <filtering>", " <access-control domain='foo' />", " </filtering>", " </http>");
Http http = new HttpBuilder().build(root, clusterElem);
root.freezeModelTopology();
assertFalse("Wrong default value for read.", http.getAccessControl().get().readEnabled);
assertTrue("Wrong default value for write.", http.getAccessControl().get().writeEnabled);
}
use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class AccessControlTest method rest_api_can_be_excluded_by_excluding_one_of_its_bindings.
@Test
public void rest_api_can_be_excluded_by_excluding_one_of_its_bindings() throws Exception {
final String restApiPath = "api/v0";
final String notExcludedBinding = "http://*/" + restApiPath + Jersey2Servlet.BINDING_SUFFIX;
;
final String excludedBinding = "https://*/" + restApiPath + Jersey2Servlet.BINDING_SUFFIX;
;
Element clusterElem = DomBuilderTest.parse("<jdisc version='1.0'>", httpWithExcludedBinding(excludedBinding), " <rest-api jersey2='true' path='" + restApiPath + "' />", "</jdisc>");
Http http = getHttp(clusterElem);
assertFalse("Excluded binding was not removed.", containsBinding(http.getBindings(), excludedBinding));
assertFalse("Not all bindings of an excluded rest-api were removed.", containsBinding(http.getBindings(), notExcludedBinding));
}
use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class AccessControlTest method servlet_can_be_excluded_by_excluding_one_of_its_bindings.
@Test
public void servlet_can_be_excluded_by_excluding_one_of_its_bindings() throws Exception {
final String servletPath = "servlet/path";
final String notExcludedBinding = "https://*/" + servletPath;
final String excludedBinding = "http://*/" + servletPath;
Element clusterElem = DomBuilderTest.parse("<jdisc version='1.0'>", httpWithExcludedBinding(excludedBinding), " <servlet id='foo' class='bar' bundle='baz'>", " <path>" + servletPath + "</path>", " </servlet>", "</jdisc>");
Http http = getHttp(clusterElem);
assertFalse("Excluded binding was not removed.", containsBinding(http.getBindings(), excludedBinding));
assertFalse("Not all bindings of an excluded servlet were removed.", containsBinding(http.getBindings(), notExcludedBinding));
}
Aggregations