From ac49567fb425299a559daad03373082b492cc192 Mon Sep 17 00:00:00 2001
From: Purodha Blissenbach <purodha.blissenbach@hostsharing.net>
Date: Fri, 21 Sep 2012 11:29:18 +0200
Subject: [PATCH] Badd test basics for domainoptions backupmxforexternalmx, indexes, inclides, multiviews, not yet doing anything useful, currently disabled.

---
 hsarback/test/de/hsadmin/remote/DomainTest.java |  141 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 130 insertions(+), 11 deletions(-)

diff --git a/hsarback/test/de/hsadmin/remote/DomainTest.java b/hsarback/test/de/hsadmin/remote/DomainTest.java
index e0e7972..fbd57cb 100644
--- a/hsarback/test/de/hsadmin/remote/DomainTest.java
+++ b/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");
@@ -233,31 +240,70 @@
 		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 testGreylistingOnOff(boolean onoff, String message)
+	private void testBackupMxForExternamlMxOnOff(boolean onoff, String message)
 			throws UnknownHostException, IOException {
 		testDomainptionOnOf(onoff, message, new DomainOptionTester() {
 
 			@Override
 			public String getOptionName() {
-				return "greylisting";
+				return "backupmxforexternalmx";
 			}
 
 			@Override
 			public boolean isOptionConfigured(String domain)
 					throws UnknownHostException, IOException {
 				String host = "test-h99.hostsharing.net";
-				String answer = socketQuery( host, 25,
-						"HELO " + domain + "\n" +
-						"MAIl FROM: hsadmin-testing@" + domain + "\n" + 
-						"RCPT TO: postmaster@" + domain + "\n" +
-						"DATA\n" + 
-						".\n") ;
+				return host == "";	// noch kein sinnvoller test
+			}
+		});
+	}
+
+private void testGreylistingOnOff(boolean onoff, String message)
+		throws UnknownHostException, IOException {
+	testDomainptionOnOf(onoff, message, new DomainOptionTester() {
+
+		@Override
+		public String getOptionName() {
+			return "greylisting";
+		}
+
+		@Override
+		public boolean isOptionConfigured(String domain)
+				throws UnknownHostException, IOException {
+			String host = "test-h99.hostsharing.net";
+			String answer = socketQuery( host, 25,
+					"HELO " + domain + "\n" +
+					"MAIl FROM: hsadmin-testing@" + domain + "\n" + 
+					"RCPT TO: postmaster@" + domain + "\n" +
+					"DATA\n" + 
+					".\n") ;
 				return answer.contains("450") && answer.contains("reylisting");
 			}
 		});
 	}
-	
+		
 	private void testHtdocsfallbackOnOff(boolean onoff, String message)
 			throws UnknownHostException, IOException {
 		testDomainptionOnOf(onoff, message, new DomainOptionTester() {
@@ -272,8 +318,81 @@
 					throws UnknownHostException, IOException {
 				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");
+					+ "Host: x.y.z." + domain
+					+ "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");
 			}

--
Gitblit v1.9.0-SNAPSHOT