This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit f818dce3ddebe7956c471570a0233739b05026a9 Author: Benoit Tellier <[email protected]> AuthorDate: Wed Oct 30 13:27:55 2019 +0700 JAMES-2943 Deleting auto detected domain has no effect --- .../lib/AbstractDomainListPrivateMethodsTest.java | 35 +++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListPrivateMethodsTest.java b/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListPrivateMethodsTest.java index c711436..e8e8060 100644 --- a/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListPrivateMethodsTest.java +++ b/server/data/data-library/src/test/java/org/apache/james/domainlist/lib/AbstractDomainListPrivateMethodsTest.java @@ -20,6 +20,7 @@ package org.apache.james.domainlist.lib; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyZeroInteractions; @@ -30,7 +31,9 @@ import java.util.List; import org.apache.james.core.Domain; import org.apache.james.dnsservice.api.DNSService; +import org.apache.james.domainlist.api.DomainListException; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import com.google.common.collect.ImmutableList; @@ -68,7 +71,7 @@ public class AbstractDomainListPrivateMethodsTest { } @Override - public void removeDomain(Domain domain) { + public void doRemoveDomain(Domain domain) { domains.remove(domain); } @@ -317,6 +320,36 @@ public class AbstractDomainListPrivateMethodsTest { assertThat(domainList.containsDomain(Domain.of(envDomain))).isTrue(); } + @Ignore("JAMES-2943 Removing an auto-detected domain leads to a noop") + @Test + public void removeDomainShouldThrowWhenRemovingAutoDetectedDomains() throws Exception { + domainList.configure(DomainListConfiguration.builder() + .autoDetect(true) + .autoDetectIp(false)); + + String detected = "detected.tld"; + when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("127.0.0.1")); + when(dnsService.getHostName(any(InetAddress.class))).thenReturn(detected); + + assertThatThrownBy(() -> domainList.removeDomain(Domain.of(detected))) + .isInstanceOf(DomainListException.class); + } + + @Ignore("JAMES-2943 Removing an auto-detected ip leads to a noop") + @Test + public void removeDomainShouldThrowWhenRemovingAutoDetectedIps() throws Exception { + String detected = "detected.tld"; + String detectedIp = "148.25.32.1"; + when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("127.0.0.1")); + when(dnsService.getHostName(any(InetAddress.class))).thenReturn(detected); + InetAddress detectedAddress = mock(InetAddress.class); + when(detectedAddress.getHostAddress()).thenReturn(detectedIp); + when(dnsService.getAllByName(detected)).thenReturn(ImmutableList.of(detectedAddress)); + + assertThatThrownBy(() -> domainList.removeDomain(Domain.of(detectedIp))) + .isInstanceOf(DomainListException.class); + } + @Test public void configuredDomainShouldBeAddedUponConfiguration() throws Exception { Domain domain1 = Domain.of("conf1.tld"); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
