Search in sources :

Example 1 with HiddenServiceDefinition

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/"));
}
Also used : HiddenServiceDefinition(org.tbk.tor.hs.HiddenServiceDefinition) Test(org.junit.jupiter.api.Test)

Example 2 with HiddenServiceDefinition

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));
    });
}
Also used : ServerProperties(org.springframework.boot.autoconfigure.web.ServerProperties) HiddenServiceDefinition(org.tbk.tor.hs.HiddenServiceDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 HiddenServiceDefinition (org.tbk.tor.hs.HiddenServiceDefinition)2 ServerProperties (org.springframework.boot.autoconfigure.web.ServerProperties)1