HSAdmin Backend Domains, E-Mail, Datenbanken
Purodha Blissenbach
2012-09-21 ac49567fb425299a559daad03373082b492cc192
Badd test basics for domainoptions backupmxforexternalmx, indexes,
inclides, multiviews, not yet doing anything useful, currently disabled.
1 files modified
121 ■■■■■ changed files
hsarback/test/de/hsadmin/remote/DomainTest.java 121 ●●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/DomainTest.java
@@ -220,6 +220,13 @@
        }
    }
//    @Test
    public void testBackupMxForExternamlMx() throws UnknownHostException, IOException {
        testBackupMxForExternamlMxOnOff(true, "zuerst an");
        testBackupMxForExternamlMxOnOff(false, "als zweites aus");
        testBackupMxForExternamlMxOnOff(true, "zuletzt wieder an");
    }
    @Test
    public void testGreylisting() throws UnknownHostException, IOException {
        testGreylistingOnOff(true, "zuerst an");
@@ -232,6 +239,45 @@
        testHtdocsfallbackOnOff(false, "zuerst aus");
        testHtdocsfallbackOnOff(true, "als zweites an");
        testHtdocsfallbackOnOff(false, "zuletzt wieder aus");
    }
//    @Test
    public void testIncludes() throws UnknownHostException, IOException {
        testIncludesOnOff(false, "zuerst aus");
        testIncludesOnOff(true, "als zweites an");
        testIncludesOnOff(false, "zuletzt wieder aus");
    }
//    @Test
    public void testIndexes() throws UnknownHostException, IOException {
        testIndexesOnOff(false, "zuerst aus");
        testIndexesOnOff(true, "als zweites an");
        testIndexesOnOff(false, "zuletzt wieder aus");
    }
//    @Test
    public void testMultiviews() throws UnknownHostException, IOException {
        testMultiviewsOnOff(true, "zuerst an");
        testMultiviewsOnOff(false, "als zweites aus");
        testMultiviewsOnOff(true, "zuletzt wieder an");
    }
    private void testBackupMxForExternamlMxOnOff(boolean onoff, String message)
            throws UnknownHostException, IOException {
        testDomainptionOnOf(onoff, message, new DomainOptionTester() {
            @Override
            public String getOptionName() {
                return "backupmxforexternalmx";
            }
            @Override
            public boolean isOptionConfigured(String domain)
                    throws UnknownHostException, IOException {
                String host = "test-h99.hostsharing.net";
                return host == "";    // noch kein sinnvoller test
            }
        });
    }
    
    private void testGreylistingOnOff(boolean onoff, String message)
@@ -273,7 +319,80 @@
                String host = "test-h99.hostsharing.net";
                String answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
                        + "Host: x.y.z." + domain
                        + "User-Agent: hsAdmin Test\n" + "Connection: close\n");
                    + "User-Agent: hsAdmin Test\n"
                    + "Connection: close\n");
                answer = answer.substring(0, answer.indexOf("\n"));
                return answer.contains("404");
            }
        });
    }
    private void testIncludesOnOff(boolean onoff, String message)
            throws UnknownHostException, IOException {
        testDomainptionOnOf(onoff, message, new DomainOptionTester() {
            @Override
            public String getOptionName() {
                return "includes";
            }
            @Override
            public boolean isOptionConfigured(String domain)
                throws UnknownHostException, IOException {
                String host = "test-h99.hostsharing.net";
                // TODO dieser Test ist Humbug
                String answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
                        + "Host: " + domain
                        + "User-Agent: hsAdmin Test\n"
                        + "Connection: close\n");
                answer = answer.substring(0, answer.indexOf("\n"));
                return answer.contains("404");
            }
        });
    }
    private void testIndexesOnOff(boolean onoff, String message)
            throws UnknownHostException, IOException {
        testDomainptionOnOf(onoff, message, new DomainOptionTester() {
            @Override
            public String getOptionName() {
                return "indexes";
            }
            @Override
            public boolean isOptionConfigured(String domain)
                throws UnknownHostException, IOException {
                String host = "test-h99.hostsharing.net";
                // TODO dieser Test ist Humbug
                String answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
                        + "Host: " + domain
                        + "User-Agent: hsAdmin Test\n"
                        + "Connection: close\n");
                answer = answer.substring(0, answer.indexOf("\n"));
                return answer.contains("404");
            }
        });
    }
    private void testMultiviewsOnOff(boolean onoff, String message)
            throws UnknownHostException, IOException {
        testDomainptionOnOf(onoff, message, new DomainOptionTester() {
            @Override
            public String getOptionName() {
                return "multiviews";
            }
            @Override
            public boolean isOptionConfigured(String domain)
                throws UnknownHostException, IOException {
                String host = "test-h99.hostsharing.net";
                // TODO dieser Test ist Humbug
                String answer = socketQuery(host, 80, "GET / HTTP/1.1\n"
                        + "Host: " + domain
                        + "User-Agent: hsAdmin Test\n"
                        + "Connection: close\n");
                answer = answer.substring(0, answer.indexOf("\n"));
                return answer.contains("404");
            }