From c2da1b8f8e1329921cc4d2398730e473ef127ad6 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@hostsharing.net>
Date: Thu, 05 May 2011 21:04:14 +0200
Subject: [PATCH] Test Hostmaster ad

---
 hsarback/test/de/hsadmin/remote/InitDataTest.java |   50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 hsarback/test/de/hsadmin/remote/CustomerTest.java |    6 +++---
 2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/hsarback/test/de/hsadmin/remote/CustomerTest.java b/hsarback/test/de/hsadmin/remote/CustomerTest.java
index 1b3c9a2..8fa3d45 100644
--- a/hsarback/test/de/hsadmin/remote/CustomerTest.java
+++ b/hsarback/test/de/hsadmin/remote/CustomerTest.java
@@ -95,7 +95,7 @@
 
 	@Test
 	public void testSearchAsPacAdmin() {
-		String user = "peh00";
+		String user = "aaa00";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
 		Object[] params = new Object[] { user, 
@@ -112,7 +112,7 @@
 
 	@Test
 	public void testSearchAsPacUser() {
-		String user = "peh00-phor";
+		String user = "aaa00-test2";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
 		Object[] params = new Object[] { user, 
@@ -129,7 +129,7 @@
 
 	@Test
 	public void testSearchAsMember() {
-		String user = "hsh00-peh";
+		String user = "hsh00-aaa";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
 		Object[] params = new Object[] { user, 
diff --git a/hsarback/test/de/hsadmin/remote/InitDataTest.java b/hsarback/test/de/hsadmin/remote/InitDataTest.java
index 2f31547..5775504 100644
--- a/hsarback/test/de/hsadmin/remote/InitDataTest.java
+++ b/hsarback/test/de/hsadmin/remote/InitDataTest.java
@@ -17,6 +17,7 @@
 
 	private static final String CUST_MODULE = "member";
 	private static final String PAC_MODULE = "pac";
+	private static final String USER_MODULE = "user";
 	
 	private XmlRpcClient client;
 	private RemoteCASHelper cas;
@@ -93,6 +94,35 @@
 	}
 
 	@Test
+	public void testAddUser() {
+		int count = getUsersCount();
+		try {
+			String user = "aaa00";
+			String grantingTicketURL = cas.getGrantingTicketURL(user);
+			Map<String, String> setParams = new HashMap<String, String>();
+			setParams.put("name", "aaa00-test2");
+			setParams.put("password", "test123");
+			setParams.put("quota", "128");
+			setParams.put("quotalimit", "192");
+			Object[] params = new Object[] { user, 
+					cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
+					setParams };
+			Object execute = client.execute(USER_MODULE + ".add", params);
+			if (execute instanceof Map<?, ?>) {
+				Map<?, ?> entry = (Map<?, ?>) execute;
+				assertEquals("aaa00-test2", entry.get("name"));
+				assertEquals("aaa00", entry.get("pac"));
+				assertEquals(null, entry.get("password"));
+			} else {
+				fail("map expected");
+			}
+		} catch (XmlRpcException e) {
+			fail(e.getMessage());
+		}
+		assertEquals(count + 1, getUsersCount());
+	}
+
+//	@Test
 	public void testDelPac() {
 		int count = getPacsCount();
 		String user = "ad";
@@ -110,7 +140,7 @@
 		assertEquals(count - 1, getPacsCount());
 	}
 
-	@Test
+//	@Test
 	public void testDelMember() {
 		int count = getMembersCount();
 		String user = "ad";
@@ -166,4 +196,22 @@
 		return count;
 	}
 
+	private int getUsersCount() {
+		int count = -1;
+		try {
+			String user = "aaa00";
+			String grantingTicketURL = cas.getGrantingTicketURL(user);
+			Map<String, String> whereParams = new HashMap<String, String>();
+			Object[] params = new Object[] { user, 
+					cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
+					whereParams };
+			Object execute = client.execute(USER_MODULE + ".search", params);
+			Object[] result = (Object[]) execute;
+			count = result.length;
+		} catch (XmlRpcException e) {
+			fail(e.getMessage());
+		}
+		return count;
+	}
+
 }

--
Gitblit v1.9.1