use of org.tbk.tor.hs.HiddenServiceDefinition in project bitcoin-spring-boot-starter by theborakompanioni.
the class OnionLocationHeaderFilterTest method create.
@Test
void create() throws Exception {
HiddenServiceDefinition build = HiddenServiceDefinition.builder().directory(hostnameFile.getParentFile()).virtualPort(80).port(80).host(InetAddress.getLoopbackAddress().getHostName()).build();
OnionLocationHeaderFilter sut = OnionLocationHeaderFilter.create(build);
sut.setAllowOnLocalhostWithHttp(true);
sut.doFilter(request, response, filterChain);
assertThat(response.getHeaderNames(), hasItem("Onion-Location"));
assertThat(response.getHeaderValue("Onion-Location"), is("http://test.onion/"));
}
use of org.tbk.tor.hs.HiddenServiceDefinition in project bitcoin-spring-boot-starter by theborakompanioni.
the class TorAutoConfigurationTest method torBeansCreatedInWebContext.
@Test
public void torBeansCreatedInWebContext() {
this.webContextRunner.withUserConfiguration(autoConfigClasses).withBean(ServerProperties.class, () -> {
// fake a running webserver for the hidden service to bind to
ServerProperties serverProperties = new ServerProperties();
serverProperties.setPort(13337);
return serverProperties;
}).run(context -> {
autoPublishEnabledAndWebAppBeanNames.forEach(name -> {
boolean beanWithNameIsAvailable = context.containsBean(name);
assertThat(name + " is available as bean", beanWithNameIsAvailable, is(true));
});
autoPublishDisabledOrNonWebAppBeanNames.forEach(name -> {
boolean beanWithNameIsAvailable = context.containsBean(name);
assertThat(name + " is NOT available as bean", beanWithNameIsAvailable, is(false));
});
Map<String, HiddenServiceDefinition> hiddenServiceBeans = context.getBeansOfType(HiddenServiceDefinition.class);
assertThat(hiddenServiceBeans.values(), hasSize(1));
});
}
Aggregations