use of com.yahoo.vespa.model.container.http.Http in project vespa by vespa-engine.
the class AccessControlTest method access_control_filter_chain_has_correct_handler_bindings.
@Test
public void access_control_filter_chain_has_correct_handler_bindings() throws Exception {
Element clusterElem = DomBuilderTest.parse("<jdisc version='1.0'>", " <search/>", " <document-api/>", " <handler id='custom.Handler'>", " <binding>http://*/custom-handler/*</binding>", " </handler>", " <http>", " <filtering>", " <access-control domain='foo' />", " </filtering>", " </http>", "</jdisc>");
Http http = getHttp(clusterElem);
Set<String> foundRequiredBindings = REQUIRED_HANDLER_BINDINGS.stream().filter(requiredBinding -> containsBinding(http.getBindings(), requiredBinding)).collect(Collectors.toSet());
Set<String> missingRequiredBindings = new HashSet<>(REQUIRED_HANDLER_BINDINGS);
missingRequiredBindings.removeAll(foundRequiredBindings);
assertTrue("Access control chain was not bound to: " + CollectionUtil.mkString(missingRequiredBindings, ", "), missingRequiredBindings.isEmpty());
FORBIDDEN_HANDLER_BINDINGS.forEach(forbiddenBinding -> http.getBindings().forEach(binding -> assertFalse("Access control chain was bound to: " + binding.binding, binding.binding.contains(forbiddenBinding))));
}
Aggregations