use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class AccessControlTest method properties_are_set_from_xml.
@Test
public void properties_are_set_from_xml() throws Exception {
Element clusterElem = DomBuilderTest.parse(" <http>", " <filtering>", " <access-control domain='my-domain'>", " <application>my-app</application>", " <vespa-domain>custom-vespa-domain</vespa-domain>", " </access-control>", " </filtering>", " </http>");
Http http = new HttpBuilder().build(root, clusterElem);
root.freezeModelTopology();
AccessControl accessControl = http.getAccessControl().get();
assertEquals("Wrong domain.", "my-domain", accessControl.domain);
assertEquals("Wrong application.", "my-app", accessControl.applicationId);
assertEquals("Wrong vespa-domain.", "custom-vespa-domain", accessControl.vespaDomain.get());
}
use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class AccessControlTest method access_control_filter_chain_has_all_servlet_bindings.
@Test
public void access_control_filter_chain_has_all_servlet_bindings() throws Exception {
final String servletPath = "servlet/path";
final String restApiPath = "api/v0";
final Set<String> requiredBindings = ImmutableSet.of(servletPath, restApiPath);
Element clusterElem = DomBuilderTest.parse("<jdisc version='1.0'>", " <servlet id='foo' class='bar' bundle='baz'>", " <path>" + servletPath + "</path>", " </servlet>", " <rest-api jersey2='true' path='" + restApiPath + "' />", " <http>", " <filtering>", " <access-control domain='foo' />", " </filtering>", " </http>", "</jdisc>");
Http http = getHttp(clusterElem);
Set<String> missingRequiredBindings = requiredBindings.stream().filter(requiredBinding -> !containsBinding(http.getBindings(), requiredBinding)).collect(Collectors.toSet());
assertTrue("Access control chain was not bound to: " + CollectionUtil.mkString(missingRequiredBindings, ", "), missingRequiredBindings.isEmpty());
}
use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class AccessControlTest method handler_can_be_excluded_by_excluding_one_of_its_bindings.
@Test
public void handler_can_be_excluded_by_excluding_one_of_its_bindings() throws Exception {
final String notExcludedBinding = "http://*/custom-handler/*";
final String excludedBinding = "http://*/excluded/*";
Element clusterElem = DomBuilderTest.parse("<jdisc version='1.0'>", httpWithExcludedBinding(excludedBinding), " <handler id='custom.Handler'>", " <binding>" + notExcludedBinding + "</binding>", " <binding>" + excludedBinding + "</binding>", " </handler>", "</jdisc>");
Http http = getHttp(clusterElem);
assertFalse("Excluded binding was not removed.", containsBinding(http.getBindings(), excludedBinding));
assertFalse("Not all bindings of an excluded handler 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 read_and_write_can_be_overridden.
@Test
public void read_and_write_can_be_overridden() throws Exception {
Element clusterElem = DomBuilderTest.parse(" <http>", " <filtering>", " <access-control domain='foo' read='true' write='false'/>", " </filtering>", " </http>");
Http http = new HttpBuilder().build(root, clusterElem);
root.freezeModelTopology();
assertTrue("Given read value not honoured.", http.getAccessControl().get().readEnabled);
assertFalse("Given write value not honoured.", http.getAccessControl().get().writeEnabled);
}
use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class AccessControlTest method getHttp.
private Http getHttp(Element clusterElem) throws SAXException, IOException {
createModel(root, clusterElem);
ContainerCluster cluster = (ContainerCluster) root.getChildren().get("jdisc");
Http http = cluster.getHttp();
assertNotNull(http);
return http;
}
Aggregations