cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aprat...@apache.org
Subject [1/2] Update unit tests, add filter to list all users, update ssl
Date Mon, 12 Aug 2013 09:25:16 GMT
Updated Branches:
  refs/heads/ldapplugin 25e8e9b85 -> 7f7035d51


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapDeleteConfigurationCmdSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapDeleteConfigurationCmdSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapDeleteConfigurationCmdSpec.groovy
index a8374b0..31d56ef 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapDeleteConfigurationCmdSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapDeleteConfigurationCmdSpec.groovy
@@ -16,48 +16,53 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
+import com.cloud.exception.InvalidParameterValueException
+import org.apache.cloudstack.api.ServerApiException
+import org.apache.cloudstack.api.command.LdapDeleteConfigurationCmd
+import org.apache.cloudstack.api.response.LdapConfigurationResponse
+import org.apache.cloudstack.ldap.LdapManager
 
 class LdapDeleteConfigurationCmdSpec extends spock.lang.Specification {
 
     def "Test failed response from execute"() {
-	given: "We have an LdapManager and LdapDeleteConfigurationCmd"
-	def ldapManager = Mock(LdapManager)
+		given: "We have an LdapManager and LdapDeleteConfigurationCmd"
+		def ldapManager = Mock(LdapManager)
         ldapManager.deleteConfiguration(_) >> { throw new InvalidParameterValueException() }
         def ldapDeleteConfigurationCmd = new LdapDeleteConfigurationCmd(ldapManager)
-	when:"LdapDeleteConfigurationCmd is executed and no configuration exists"
+		when:"LdapDeleteConfigurationCmd is executed and no configuration exists"
         ldapDeleteConfigurationCmd.execute()
-	then: "An exception is thrown"
+		then: "An exception is thrown"
         thrown ServerApiException
     }
 
     def "Test getEntityOwnerId is 1"() {
-	given: "We have an LdapManager and LdapDeleteConfigurationCmd"
+		given: "We have an LdapManager and LdapDeleteConfigurationCmd"
         def ldapManager = Mock(LdapManager)
         def ldapDeleteConfigurationCmd = new LdapDeleteConfigurationCmd(ldapManager)
-	when: "Get entity owner id is called"
+		when: "Get entity owner id is called"
         long ownerId = ldapDeleteConfigurationCmd.getEntityOwnerId()
-	then: "1 is returned"
-	ownerId == 1
+		then: "1 is returned"
+		ownerId == 1
     }
 
     def "Test successful response from execute"() {
-	given: "We have an LdapManager and LdapDeleteConfigurationCmd"
-	def ldapManager = Mock(LdapManager)
-	ldapManager.deleteConfiguration(_) >> new LdapConfigurationResponse("localhost")
-	def ldapDeleteConfigurationCmd = new LdapDeleteConfigurationCmd(ldapManager)
-	when: "LdapDeleteConfigurationCmd is executed"
-	ldapDeleteConfigurationCmd.execute()
-	then: "The given configuration should be deleted and returned"
-	ldapDeleteConfigurationCmd.responseObject.hostname == "localhost"
+		given: "We have an LdapManager and LdapDeleteConfigurationCmd"
+		def ldapManager = Mock(LdapManager)
+		ldapManager.deleteConfiguration(_) >> new LdapConfigurationResponse("localhost")
+		def ldapDeleteConfigurationCmd = new LdapDeleteConfigurationCmd(ldapManager)
+		when: "LdapDeleteConfigurationCmd is executed"
+		ldapDeleteConfigurationCmd.execute()
+		then: "The given configuration should be deleted and returned"
+		ldapDeleteConfigurationCmd.responseObject.hostname == "localhost"
     }
 
     def "Test successful return of getCommandName"() {
-	given: "We have an LdapManager and LdapDeleteConfigurationCmd"
-	def ldapManager = Mock(LdapManager)
+		given: "We have an LdapManager and LdapDeleteConfigurationCmd"
+		def ldapManager = Mock(LdapManager)
         def ldapDeleteConfigurationCmd = new LdapDeleteConfigurationCmd(ldapManager)
-	when: "Get Command name is called"
+		when: "Get Command name is called"
         String commandName = ldapDeleteConfigurationCmd.getCommandName()
-	then: "ldapconfigurationresponse is returned"
+		then: "ldapconfigurationresponse is returned"
         commandName == "ldapconfigurationresponse"
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListAllUsersCmdSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListAllUsersCmdSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListAllUsersCmdSpec.groovy
deleted file mode 100644
index bb6845c..0000000
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListAllUsersCmdSpec.groovy
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package groovy.org.apache.cloudstack.ldap
-
-
-class LdapListAllUsersCmdSpec extends spock.lang.Specification {
-    def "Test getEntityOwnerId is 1"() {
-	given: "We have an LdapManager and LdapListAllUsersCmd"
-	def ldapManager = Mock(LdapManager)
-	def ldapListAllUsersCmd = new LdapListAllUsersCmd(ldapManager)
-	when: "Get entity owner id is called"
-	long ownerId = ldapListAllUsersCmd.getEntityOwnerId()
-	then: "a 1 should be returned"
-	ownerId == 1
-    }
-
-    def "Test successful empty response from execute"() {
-	given: "We have a LdapManager with no users and a LdapListAllUsersCmd"
-        def ldapManager = Mock(LdapManager)
-        ldapManager.getUsers() >> {throw new NoLdapUserMatchingQueryException()}
-        def ldapListAllUsersCmd = new LdapListAllUsersCmd(ldapManager)
-	when: "LdapListAllUsersCmd is executed"
-        ldapListAllUsersCmd.execute()
-	then: "An array of size 0 is returned"
-		ldapListAllUsersCmd.responseObject.getResponses().size() == 0
-    }
-
-    def "Test successful response from execute"() {
-	given: "We have an LdapManager, one user and a LdapListAllUsersCmd"
-	def ldapManager = Mock(LdapManager)
-	List<LdapUser> users = new ArrayList()
-	users.add(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
-	ldapManager.getUsers() >> users
-	LdapUserResponse response = new LdapUserResponse("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org")
-	ldapManager.createLdapUserResponse(_) >> response
-	def ldapListAllUsersCmd = new LdapListAllUsersCmd(ldapManager)
-	when: "LdapListAllUsersCmd is executed"
-	ldapListAllUsersCmd.execute()
-	then: "a list of size not 0 is returned"
-	ldapListAllUsersCmd.responseObject.getResponses().size() != 0
-    }
-
-    def "Test successful return of getCommandName"() {
-	given: "We have an LdapManager and a LdapListAllUsersCmd"
-        def ldapManager = Mock(LdapManager)
-        def ldapListAllUsersCmd = new LdapListAllUsersCmd(ldapManager)
-	when: "Get command name is called"
-        String commandName = ldapListAllUsersCmd.getCommandName()
-	then: "ldapuserresponse is returned"
-        commandName == "ldapuserresponse"
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListConfigurationCmdSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListConfigurationCmdSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListConfigurationCmdSpec.groovy
index 11226d7..cd8b2a3 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListConfigurationCmdSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListConfigurationCmdSpec.groovy
@@ -16,36 +16,43 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
+import org.apache.cloudstack.api.ServerApiException
+import org.apache.cloudstack.api.command.LdapListConfigurationCmd
+import org.apache.cloudstack.api.response.LdapConfigurationResponse
+import org.apache.cloudstack.ldap.LdapConfigurationVO
+import org.apache.cloudstack.ldap.LdapManager
+
+import com.cloud.utils.Pair
 
 class LdapListConfigurationCmdSpec extends spock.lang.Specification {
 
     def "Test failed response from execute"() {
-	given: "We have an LdapManager and a LdapListConfigurationsCmd"
-	def ldapManager = Mock(LdapManager)
-	List<LdapConfigurationVO> ldapConfigurationList = new ArrayList()
-	Pair<List<LdapConfigurationVO>, Integer> ldapConfigurations = new Pair<List<LdapConfigurationVO>, Integer>();
-	ldapConfigurations.set(ldapConfigurationList, ldapConfigurationList.size())
-	ldapManager.listConfigurations(_) >> ldapConfigurations
-	def ldapListConfigurationCmd = new LdapListConfigurationCmd(ldapManager)
-	when: "LdapListConfigurationCmd is executed"
-	ldapListConfigurationCmd.execute()
-	then: "Its response object contains an array that is 0"
-	ldapListConfigurationCmd.getResponseObject().getResponses().size() == 0
+		given: "We have an LdapManager and a LdapListConfigurationsCmd"
+		def ldapManager = Mock(LdapManager)
+		List<LdapConfigurationVO> ldapConfigurationList = new ArrayList()
+		Pair<List<LdapConfigurationVO>, Integer> ldapConfigurations = new Pair<List<LdapConfigurationVO>, Integer>();
+		ldapConfigurations.set(ldapConfigurationList, ldapConfigurationList.size())
+		ldapManager.listConfigurations(_) >> ldapConfigurations
+		def ldapListConfigurationCmd = new LdapListConfigurationCmd(ldapManager)
+		when: "LdapListConfigurationCmd is executed"
+		ldapListConfigurationCmd.execute()
+		then: "Its response object contains an array that is 0"
+		ldapListConfigurationCmd.getResponseObject().getResponses().size() == 0
     }
 
     def "Test getEntityOwnerId is 1"() {
-	given: "We have an LdapManager and ListLdapConfigurationCmd"
-	def ldapManager = Mock(LdapManager)
-	def ldapListConfigurationCmd = new LdapListConfigurationCmd(ldapManager)
-	when: "Get entity owner id is called"
-	long ownerId = ldapListConfigurationCmd.getEntityOwnerId()
-	then: "a 1 is returned"
-	ownerId == 1
+		given: "We have an LdapManager and ListLdapConfigurationCmd"
+		def ldapManager = Mock(LdapManager)
+		def ldapListConfigurationCmd = new LdapListConfigurationCmd(ldapManager)
+		when: "Get entity owner id is called"
+		long ownerId = ldapListConfigurationCmd.getEntityOwnerId()
+		then: "a 1 is returned"
+		ownerId == 1
     }
 
     def "Test successful response from execute"() {
-	given: "We have an LdapManager with a configuration and a LdapListConfigurationsCmd"
-	def ldapManager = Mock(LdapManager)
+		given: "We have an LdapManager with a configuration and a LdapListConfigurationsCmd"
+		def ldapManager = Mock(LdapManager)
         List<LdapConfigurationVO> ldapConfigurationList = new ArrayList()
         ldapConfigurationList.add(new LdapConfigurationVO("localhost", 389))
         Pair<List<LdapConfigurationVO>, Integer> ldapConfigurations = new Pair<List<LdapConfigurationVO>, Integer>();
@@ -53,39 +60,39 @@ class LdapListConfigurationCmdSpec extends spock.lang.Specification {
         ldapManager.listConfigurations(_) >> ldapConfigurations
         ldapManager.createLdapConfigurationResponse(_) >> new LdapConfigurationResponse("localhost", 389)
         def ldapListConfigurationCmd = new LdapListConfigurationCmd(ldapManager)
-	when: "LdapListConfigurationsCmd is executed"
+		when: "LdapListConfigurationsCmd is executed"
         ldapListConfigurationCmd.execute()
-	then: "Its response object contains an array that is not 0 in size"
-	ldapListConfigurationCmd.getResponseObject().getResponses().size() != 0
+		then: "Its response object contains an array that is not 0 in size"
+		ldapListConfigurationCmd.getResponseObject().getResponses().size() != 0
     }
 
     def "Test successful return of getCommandName"() {
-	given: "We have an LdapManager and LdapListConfigurationCmd"
-	def ldapManager = Mock(LdapManager)
-	def ldapListConfigurationCmd = new LdapListConfigurationCmd(ldapManager)
-	when: "Get command name is called"
-	String commandName = ldapListConfigurationCmd.getCommandName()
-	then: "ldapconfigurationresponse is returned"
-	commandName == "ldapconfigurationresponse"
+		given: "We have an LdapManager and LdapListConfigurationCmd"
+		def ldapManager = Mock(LdapManager)
+		def ldapListConfigurationCmd = new LdapListConfigurationCmd(ldapManager)
+		when: "Get command name is called"
+		String commandName = ldapListConfigurationCmd.getCommandName()
+		then: "ldapconfigurationresponse is returned"
+		commandName == "ldapconfigurationresponse"
     }
 
     def "Test successful setting of hostname"() {
-	given: "We have an LdapManager and LdapListConfigurationCmd"
+		given: "We have an LdapManager and LdapListConfigurationCmd"
         def ldapManager = Mock(LdapManager)
         def ldapListConfigurationCmd = new LdapListConfigurationCmd(ldapManager)
-	when: "The hostname is set"
+		when: "The hostname is set"
         ldapListConfigurationCmd.setHostname("localhost")
-	then: "Get hostname returns the set value"
-	ldapListConfigurationCmd.getHostname() == "localhost"
+		then: "Get hostname returns the set value"
+		ldapListConfigurationCmd.getHostname() == "localhost"
     }
 
     def "Test successful setting of Port"() {
-	given: "We have an LdapManager and LdapListConfigurationCmd"
-	def ldapManager = Mock(LdapManager)
+		given: "We have an LdapManager and LdapListConfigurationCmd"
+		def ldapManager = Mock(LdapManager)
         def ldapListConfigurationCmd = new LdapListConfigurationCmd(ldapManager)
-	when: "The port is set"
+		when: "The port is set"
         ldapListConfigurationCmd.setPort(389)
-	then: "Get port returns the set value"
-	ldapListConfigurationCmd.getPort() == 389
+		then: "Get port returns the set value"
+		ldapListConfigurationCmd.getPort() == 389
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListUsersCmdSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListUsersCmdSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListUsersCmdSpec.groovy
new file mode 100644
index 0000000..5039443
--- /dev/null
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapListUsersCmdSpec.groovy
@@ -0,0 +1,123 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package groovy.org.apache.cloudstack.ldap
+
+import org.apache.cloudstack.api.command.LdapListUsersCmd
+import org.apache.cloudstack.api.ServerApiException
+import org.apache.cloudstack.api.command.admin.user.ListUsersCmd
+import org.apache.cloudstack.api.response.LdapUserResponse
+import org.apache.cloudstack.api.response.ListResponse
+import org.apache.cloudstack.api.response.UserResponse
+import org.apache.cloudstack.ldap.LdapManager
+import org.apache.cloudstack.ldap.LdapUser
+import org.apache.cloudstack.ldap.NoLdapUserMatchingQueryException
+import org.apache.cloudstack.query.QueryService
+
+class LdapListUsersCmdSpec extends spock.lang.Specification {
+    def "Test getEntityOwnerId is 1"() {
+		given: "We have an LdapManager, QueryService and LdapListUsersCmd"
+		def ldapManager = Mock(LdapManager)
+		def queryService = Mock(QueryService)
+		def ldapListUsersCmd = new LdapListUsersCmd(ldapManager, queryService)
+		when: "Get entity owner id is called"
+		long ownerId = ldapListUsersCmd.getEntityOwnerId()
+		then: "a 1 should be returned"
+		ownerId == 1
+    }
+
+    def "Test successful empty response from execute"() {
+		given: "We have a LdapManager with no users, QueryService and a LdapListUsersCmd"
+	def ldapManager = Mock(LdapManager)
+	ldapManager.getUsers() >> {throw new NoLdapUserMatchingQueryException()}
+		def queryService = Mock(QueryService)
+	def ldapListUsersCmd = new LdapListUsersCmd(ldapManager, queryService)
+		when: "LdapListUsersCmd is executed"
+	ldapListUsersCmd.execute()
+		then: "An array of size 0 is returned"
+		ldapListUsersCmd.responseObject.getResponses().size() == 0
+    }
+
+    def "Test successful response from execute"() {
+		given: "We have an LdapManager, one user, QueryService and a LdapListUsersCmd"
+		def ldapManager = Mock(LdapManager)
+		List<LdapUser> users = new ArrayList()
+		users.add(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
+		ldapManager.getUsers() >> users
+		LdapUserResponse response = new LdapUserResponse("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org")
+		ldapManager.createLdapUserResponse(_) >> response
+		def queryService = Mock(QueryService)
+		def ldapListUsersCmd = new LdapListUsersCmd(ldapManager, queryService)
+		when: "LdapListUsersCmd is executed"
+		ldapListUsersCmd.execute()
+		then: "a list of size not 0 is returned"
+		ldapListUsersCmd.responseObject.getResponses().size() != 0
+    }
+
+    def "Test successful return of getCommandName"() {
+		given: "We have an LdapManager, QueryService and a LdapListUsersCmd"
+	def ldapManager = Mock(LdapManager)
+		def queryService = Mock(QueryService)
+	def ldapListUsersCmd = new LdapListUsersCmd(ldapManager, queryService)
+		when: "Get command name is called"
+	String commandName = ldapListUsersCmd.getCommandName()
+		then: "ldapuserresponse is returned"
+	commandName == "ldapuserresponse"
+    }
+
+	def "Test successful result from isACloudstackUser"() {
+		given: "We have an LdapManager and a LdapListUsersCmd"
+		def ldapManager = Mock(LdapManager)
+		def queryService = Mock(QueryService)
+
+		UserResponse userResponse = new UserResponse()
+		userResponse.setUsername("rmurphy")
+
+		ArrayList<UserResponse> responses = new ArrayList<UserResponse>()
+		responses.add(userResponse);
+
+		ListResponse<UserResponse> queryServiceResponse = new ListResponse<UserResponse>()
+		queryServiceResponse.setResponses(responses)
+
+		queryService.searchForUsers(_) >> queryServiceResponse
+
+		def ldapUser = new LdapUser("rmurphy", "rmurphy@cloudstack.org", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org")
+		def ldapListUsersCmd = new LdapListUsersCmd(ldapManager,queryService)
+
+		when: "isACloudstackUser is executed"
+		def result = ldapListUsersCmd.isACloudstackUser(ldapUser);
+
+		then: "The result is true"
+		result == true;
+	}
+
+	def "Test failed result from isACloudstackUser"() {
+		given: "We have an LdapManager and a LdapListUsersCmd"
+		def ldapManager = Mock(LdapManager)
+		def queryService = Mock(QueryService)
+
+		queryService.searchForUsers(_) >> new ListResponse<UserResponse>()
+
+		def ldapUser = new LdapUser("rmurphy", "rmurphy@cloudstack.org", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org")
+		def ldapListUsersCmd = new LdapListUsersCmd(ldapManager,queryService)
+
+		when: "isACloudstackUser is executed"
+		def result = ldapListUsersCmd.isACloudstackUser(ldapUser);
+
+		then: "The result is true"
+		result == false;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy
index 7492919..d681eac 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy
@@ -16,300 +16,292 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
+import javax.naming.NamingException
+import javax.naming.ldap.InitialLdapContext
+
+import org.apache.cloudstack.api.command.LdapListConfigurationCmd
+import org.apache.cloudstack.ldap.*
+import org.apache.cloudstack.ldap.dao.LdapConfigurationDaoImpl
+
+import com.cloud.exception.InvalidParameterValueException
+import com.cloud.utils.Pair
 
 class LdapManagerImplSpec extends spock.lang.Specification {
     def "Test failing of getUser due to bind issue"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapContextFactory.createBindContext() >> { throw new NamingException() }
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "We search for a user but there is a bind issue"
-	ldapManager.getUser("rmurphy")
-	then: "an exception is thrown"
-	thrown NamingException
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapContextFactory.createBindContext() >> { throw new NamingException() }
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "We search for a user but there is a bind issue"
+		ldapManager.getUser("rmurphy")
+		then: "an exception is thrown"
+		thrown NamingException
     }
 
     def "Test failing of getUsers due to bind issue"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapContextFactory.createBindContext() >> { throw new NamingException() }
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "We search for a group of users but there is a bind issue"
-	ldapManager.getUsers()
-	then: "An exception is thrown"
-	thrown NoLdapUserMatchingQueryException
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapContextFactory.createBindContext() >> { throw new NamingException() }
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "We search for a group of users but there is a bind issue"
+		ldapManager.getUsers()
+		then: "An exception is thrown"
+		thrown NoLdapUserMatchingQueryException
     }
 
     def "Test failing of searchUsers due to a failure to bind"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapContextFactory.createBindContext() >> { throw new NamingException() }
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "We search for users"
-	ldapManager.searchUsers("rmurphy")
-	then: "An exception is thrown"
-	thrown NoLdapUserMatchingQueryException
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapContextFactory.createBindContext() >> { throw new NamingException() }
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "We search for users"
+		ldapManager.searchUsers("rmurphy")
+		then: "An exception is thrown"
+		thrown NoLdapUserMatchingQueryException
     }
 
     def "Test LdapConfigurationResponse generation"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "A ldap configuration response is generated"
-	def result = ldapManager.createLdapConfigurationResponse(new LdapConfigurationVO("localhost", 389))
-	then: "the result of the response should match the given LdapConfigurationVO"
-	result.hostname == "localhost"
-	result.port == 389
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "A ldap configuration response is generated"
+		def result = ldapManager.createLdapConfigurationResponse(new LdapConfigurationVO("localhost", 389))
+		then: "the result of the response should match the given LdapConfigurationVO"
+		result.hostname == "localhost"
+		result.port == 389
     }
 
     def "Test LdapUserResponse generation"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "A ldap user response is generated"
-	def result = ldapManager.createLdapUserResponse(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
-	then: "TThe result of the response should match the given ldap user"
-	result.username == "rmurphy"
-	result.email == "rmurphy@test.com"
-	result.firstname == "Ryan"
-	result.lastname == "Murphy"
-	result.principal == "cn=rmurphy,dc=cloudstack,dc=org"
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "A ldap user response is generated"
+		def result = ldapManager.createLdapUserResponse(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
+		then: "The result of the response should match the given ldap user"
+		result.username == "rmurphy"
+		result.email == "rmurphy@test.com"
+		result.firstname == "Ryan"
+		result.lastname == "Murphy"
+		result.principal == "cn=rmurphy,dc=cloudstack,dc=org"
     }
 
     def "Test success getUsers"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapContextFactory.createBindContext() >> null
-	List<LdapUser> users = new ArrayList<>();
-	users.add(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
-	ldapUserManager.getUsers(_) >> users;
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "We search for a group of users"
-	def result = ldapManager.getUsers()
-	then: "A list greater than 0 is returned"
-	result.size() > 0;
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapContextFactory.createBindContext() >> null
+		List<LdapUser> users = new ArrayList<>();
+		users.add(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
+		ldapUserManager.getUsers(_) >> users;
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "We search for a group of users"
+		def result = ldapManager.getUsers()
+		then: "A list greater than 0 is returned"
+		result.size() > 0;
     }
 
     def "Test success of getUser"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapContextFactory.createBindContext() >> null
-	ldapUserManager.getUser(_, _) >> new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org")
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "We search for a user"
-	def result = ldapManager.getUser("rmurphy")
-	then: "The user is returned"
-	result.username == "rmurphy"
-	result.email == "rmurphy@test.com"
-	result.firstname == "Ryan"
-	result.lastname == "Murphy"
-	result.principal == "cn=rmurphy,dc=cloudstack,dc=org"
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapContextFactory.createBindContext() >> null
+		ldapUserManager.getUser(_, _) >> new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org")
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "We search for a user"
+		def result = ldapManager.getUser("rmurphy")
+		then: "The user is returned"
+		result.username == "rmurphy"
+		result.email == "rmurphy@test.com"
+		result.firstname == "Ryan"
+		result.lastname == "Murphy"
+		result.principal == "cn=rmurphy,dc=cloudstack,dc=org"
     }
 
     def "Test successful closing of context"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "The context is closed"
-	def context = Mock(InitialLdapContext)
-	ldapManager.closeContext(context)
-	then: "The context is null"
-	context.defaultInitCtx == null
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "The context is closed"
+		def context = Mock(InitialLdapContext)
+		ldapManager.closeContext(context)
+		then: "The context is null"
+		context.defaultInitCtx == null
     }
 
     def "Test successful failed result from canAuthenticate due to bad password"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
         def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
         def ldapContextFactory = Mock(LdapContextFactory)
         ldapContextFactory.createUserContext(_, _) >> { throw new NamingException() }
         def ldapUserManager = Mock(LdapUserManager)
         def ldapManager = Spy(LdapManagerImpl, constructorArgs: [ldapConfigurationDao, ldapContextFactory, ldapUserManager])
         ldapManager.getUser(_) >> { new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org") }
-	when: "The user attempts to authenticate with a bad password"
+		when: "The user attempts to authenticate with a bad password"
         def result = ldapManager.canAuthenticate("rmurphy", "password")
-	then: "The authentication fails"
-	result == false
+		then: "The authentication fails"
+		result == false
     }
 
     def "Test successful failed result from canAuthenticate due to user not found"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	def ldapManager = Spy(LdapManagerImpl, constructorArgs: [ldapConfigurationDao, ldapContextFactory, ldapUserManager])
-	ldapManager.getUser(_) >> { throw new NamingException() }
-	when: "The user attempts to authenticate and the user is not found"
-	def result = ldapManager.canAuthenticate("rmurphy", "password")
-	then: "the authentication fails"
-	result == false
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		def ldapManager = Spy(LdapManagerImpl, constructorArgs: [ldapConfigurationDao, ldapContextFactory, ldapUserManager])
+		ldapManager.getUser(_) >> { throw new NamingException() }
+		when: "The user attempts to authenticate and the user is not found"
+		def result = ldapManager.canAuthenticate("rmurphy", "password")
+		then: "the authentication fails"
+		result == false
     }
 
     def "Test successful failed result from deleteConfiguration due to configuration not existing"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapConfigurationDao.findByHostname(_) >> null
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "A ldap configuration that doesn't exist is deleted"
-	ldapManager.deleteConfiguration("localhost")
-	then: "A exception is thrown"
-	thrown InvalidParameterValueException
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapConfigurationDao.findByHostname(_) >> null
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "A ldap configuration that doesn't exist is deleted"
+		ldapManager.deleteConfiguration("localhost")
+		then: "A exception is thrown"
+		thrown InvalidParameterValueException
     }
 
     def "Test successful failing to close of context"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
         def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
         def ldapContextFactory = Mock(LdapContextFactory)
         def ldapUserManager = Mock(LdapUserManager)
         def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "The context is closed"
+		when: "The context is closed"
         def context = Mock(InitialLdapContext)
         context.close() >> { throw new NamingException() }
         ldapManager.closeContext(context)
-	then: "An exception is thrown"
-	context.defaultInitCtx == null
+		then: "An exception is thrown"
+		context.defaultInitCtx == null
     }
 
     def "Test successful result from canAuthenticate"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	ldapContextFactory.createUserContext(_, _) >> null
-	def ldapUserManager = Mock(LdapUserManager)
-	def ldapManager = Spy(LdapManagerImpl, constructorArgs: [ldapConfigurationDao, ldapContextFactory, ldapUserManager])
-	ldapManager.getUser(_) >> { new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org") }
-	when: "A user authenticates"
-	def result = ldapManager.canAuthenticate("rmurphy", "password")
-	then: "The result is true"
-	result == true
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		ldapContextFactory.createUserContext(_, _) >> null
+		def ldapUserManager = Mock(LdapUserManager)
+		def ldapManager = Spy(LdapManagerImpl, constructorArgs: [ldapConfigurationDao, ldapContextFactory, ldapUserManager])
+		ldapManager.getUser(_) >> { new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org") }
+		when: "A user authenticates"
+		def result = ldapManager.canAuthenticate("rmurphy", "password")
+		then: "The result is true"
+		result == true
     }
 
     def "Test successful result from deleteConfiguration"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapConfigurationDao.findByHostname(_) >> {
-	    def configuration = new LdapConfigurationVO("localhost", 389)
-	    configuration.setId(0);
-	    return configuration;
-	}
-	ldapConfigurationDao.remove(_) >> null
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "A ldap configuration is deleted"
-	def result = ldapManager.deleteConfiguration("localhost")
-	then: "The deleted configuration is returned"
-	result.hostname == "localhost"
-	result.port == 389
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapConfigurationDao.findByHostname(_) >> {
+		    def configuration = new LdapConfigurationVO("localhost", 389)
+		    configuration.setId(0);
+		    return configuration;
+		}
+		ldapConfigurationDao.remove(_) >> null
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "A ldap configuration is deleted"
+		def result = ldapManager.deleteConfiguration("localhost")
+		then: "The deleted configuration is returned"
+		result.hostname == "localhost"
+		result.port == 389
     }
 
     def "Test successful result from searchUsers"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapContextFactory.createBindContext() >> null;
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapContextFactory.createBindContext() >> null;
 
-	List<LdapUser> users = new ArrayList<LdapUser>();
-	users.add(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
-	ldapUserManager.getUsers(_, _) >> users;
+		List<LdapUser> users = new ArrayList<LdapUser>();
+		users.add(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
+		ldapUserManager.getUsers(_, _) >> users;
 
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "We search for users"
-	def result = ldapManager.searchUsers("rmurphy");
-	then: "A list of atleast 1 is returned"
-	result.size() > 0;
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "We search for users"
+		def result = ldapManager.searchUsers("rmurphy");
+		then: "A list of atleast 1 is returned"
+		result.size() > 0;
     }
 
     def "Test successfully addConfiguration"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapContextFactory.createBindContext(_) >> null
-	ldapConfigurationDao.persist(_) >> null
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "A ldap configuration is added"
-	def result = ldapManager.addConfiguration("localhost", 389)
-	then: "the resulting object contain the given hostname and port"
-	result.hostname == "localhost"
-	result.port == 389
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapContextFactory.createBindContext(_) >> null
+		ldapConfigurationDao.persist(_) >> null
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "A ldap configuration is added"
+		def result = ldapManager.addConfiguration("localhost", 389)
+		then: "the resulting object contain the given hostname and port"
+		result.hostname == "localhost"
+		result.port == 389
     }
 
     def "Test that addConfiguration fails when a binding fails"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapContextFactory.createBindContext(_) >> { throw new NamingException() }
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "A configuration is added that can not be binded"
-	ldapManager.addConfiguration("localhost", 389)
-	then: "An exception is thrown"
-	thrown InvalidParameterValueException
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapContextFactory.createBindContext(_) >> { throw new NamingException() }
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "A configuration is added that can not be binded"
+		ldapManager.addConfiguration("localhost", 389)
+		then: "An exception is thrown"
+		thrown InvalidParameterValueException
     }
 
     def "Test that addConfiguration fails when a duplicate configuration exists"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	ldapConfigurationDao.findByHostname(_) >> new LdapConfigurationVO("localhost", 389)
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "a configuration that already exists is added"
-	ldapManager.addConfiguration("localhost", 389)
-	then: "An exception is thrown"
-	thrown InvalidParameterValueException
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		ldapConfigurationDao.findByHostname(_) >> new LdapConfigurationVO("localhost", 389)
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "a configuration that already exists is added"
+		ldapManager.addConfiguration("localhost", 389)
+		then: "An exception is thrown"
+		thrown InvalidParameterValueException
     }
 
     def "Test that getCommands isn't empty"() {
-	given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
-	def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
-	def ldapContextFactory = Mock(LdapContextFactory)
-	def ldapUserManager = Mock(LdapUserManager)
-	def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-	when: "Get commands is called"
-	def result = ldapManager.getCommands()
-	then: "it must have atleast 1 command"
-	result.size() > 0
-    }
-
-    def "Testing of isLdapEnabled"() {
-		given:
+		given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
 		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
 		def ldapContextFactory = Mock(LdapContextFactory)
 		def ldapUserManager = Mock(LdapUserManager)
-		List<LdapConfigurationVO> ldapConfigurationList = new ArrayList()
-		ldapConfigurationList.add(new LdapConfigurationVO("localhost", 389))
-		Pair<List<LdapConfigurationVO>, Integer> configurations = new Pair<List<LdapConfigurationVO>, Integer>();
-		configurations.set(ldapConfigurationList, ldapConfigurationList.size())
-		ldapConfigurationDao.searchConfigurations(_, _) >> configurations
 		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-		when:
-		def result = ldapManager.isLdapEnabled();
-		then:
-		result == true;
-	}
+		when: "Get commands is called"
+		def result = ldapManager.getCommands()
+		then: "it must have atleast 1 command"
+		result.size() > 0
+    }
 
-	def "Testing of listConfigurations"() {
-        given:
+    def "Testing of listConfigurations"() {
+	given:  "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
         def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
         def ldapContextFactory = Mock(LdapContextFactory)
         def ldapUserManager = Mock(LdapUserManager)
@@ -319,9 +311,26 @@ class LdapManagerImplSpec extends spock.lang.Specification {
         configurations.set(ldapConfigurationList, ldapConfigurationList.size())
         ldapConfigurationDao.searchConfigurations(_, _) >> configurations
         def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
-        when:
+	when: "A request for configurations is made"
         def result = ldapManager.listConfigurations(new LdapListConfigurationCmd())
-	then:
-	result.second() > 0
+		then: "Then atleast 1 ldap configuration is returned"
+		result.second() > 0
     }
+
+	def "Testing of isLdapEnabled"() {
+		given:  "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
+		def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
+		def ldapContextFactory = Mock(LdapContextFactory)
+		def ldapUserManager = Mock(LdapUserManager)
+		List<LdapConfigurationVO> ldapConfigurationList = new ArrayList()
+		ldapConfigurationList.add(new LdapConfigurationVO("localhost", 389))
+		Pair<List<LdapConfigurationVO>, Integer> configurations = new Pair<List<LdapConfigurationVO>, Integer>();
+		configurations.set(ldapConfigurationList, ldapConfigurationList.size())
+		ldapConfigurationDao.searchConfigurations(_, _) >> configurations
+		def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
+		when: "A request to find out is ldap enabled"
+		def result = ldapManager.isLdapEnabled();
+		then: "true is returned because a configuration was found"
+		result == true;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapSearchUserCmdSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapSearchUserCmdSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapSearchUserCmdSpec.groovy
index 4bc5ca8..fce299d 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapSearchUserCmdSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapSearchUserCmdSpec.groovy
@@ -16,51 +16,57 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
+import org.apache.cloudstack.api.ServerApiException
+import org.apache.cloudstack.api.command.LdapUserSearchCmd
+import org.apache.cloudstack.api.response.LdapUserResponse
+import org.apache.cloudstack.ldap.LdapManager
+import org.apache.cloudstack.ldap.LdapUser
+import org.apache.cloudstack.ldap.NoLdapUserMatchingQueryException
 
 class LdapSearchUserCmdSpec extends spock.lang.Specification {
     def "Test getEntityOwnerId is 1"() {
-        given:
+	given: "We have an Ldap manager and ldap user search cmd"
         def ldapManager = Mock(LdapManager)
         def ldapUserSearchCmd = new LdapUserSearchCmd(ldapManager)
-        when:
-	long ownerId = ldapUserSearchCmd.getEntityOwnerId()
-        then:
-	ownerId == 1
+	when: "getEntityOwnerId is called"
+		long ownerId = ldapUserSearchCmd.getEntityOwnerId()
+	then: "1 is returned"
+		ownerId == 1
     }
 
     def "Test successful empty response from execute"() {
-        given:
+	given: "We have an Ldap manager and ldap user search cmd"
         def ldapManager = Mock(LdapManager)
         ldapManager.searchUsers(_) >> {throw new NoLdapUserMatchingQueryException()}
         def ldapUserSearchCmd = new LdapUserSearchCmd(ldapManager)
-        when:
+	when: "The command is executed with no users found"
         ldapUserSearchCmd.execute()
-        then:
+	then: "An empty array is returned"
         ldapUserSearchCmd.responseObject.getResponses().size() == 0
     }
 
     def "Test successful response from execute"() {
-        given:
+	given: "We have an Ldap manager and ldap user search cmd"
         def ldapManager = Mock(LdapManager)
-	List<LdapUser> users = new ArrayList()
-	users.add(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
-	ldapManager.searchUsers(_) >> users
-	LdapUserResponse response = new LdapUserResponse("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org")
-	ldapManager.createLdapUserResponse(_) >> response
+		List<LdapUser> users = new ArrayList()
+		users.add(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org"))
+		ldapManager.searchUsers(_) >> users
+		LdapUserResponse response = new LdapUserResponse("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,dc=cloudstack,dc=org")
+		ldapManager.createLdapUserResponse(_) >> response
         def ldapUserSearchCmd = new LdapUserSearchCmd(ldapManager)
-        when:
-	ldapUserSearchCmd.execute()
-        then:
-	ldapUserSearchCmd.responseObject.getResponses().size() != 0
+	when: "The command is executed"
+		ldapUserSearchCmd.execute()
+	then: "A array with length of atleast 1 is returned"
+		ldapUserSearchCmd.responseObject.getResponses().size() > 0
     }
 
     def "Test successful return of getCommandName"() {
-        given:
+	given: "We have an Ldap manager and ldap user search cmd"
         def ldapManager = Mock(LdapManager)
         def ldapUserSearchCmd = new LdapUserSearchCmd(ldapManager)
-        when:
+	when: "When a request for the command name is made"
         String commandName = ldapUserSearchCmd.getCommandName()
-        then:
+	then: "ldapuserresponse is returned"
         commandName == "ldapuserresponse"
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
index d13f0e8..339923e 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserManagerSpec.groovy
@@ -16,10 +16,16 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
-import javax.naming.directory.Attributes;
-import javax.naming.directory.SearchResult;
+import org.apache.cloudstack.ldap.LdapConfiguration
+import org.apache.cloudstack.ldap.LdapUserManager
+import spock.lang.Shared
 
-import spock.lang.Shared;
+import javax.naming.NamingException
+import javax.naming.directory.Attribute
+import javax.naming.directory.Attributes
+import javax.naming.directory.SearchControls
+import javax.naming.directory.SearchResult
+import javax.naming.ldap.LdapContext
 
 class LdapUserManagerSpec extends spock.lang.Specification {
 
@@ -42,52 +48,51 @@ class LdapUserManagerSpec extends spock.lang.Specification {
     private def principal
 
     private def createContext() {
+		Attributes attributes = createUserAttributes(username, email, firstname, lastname)
+		SearchResult searchResults = createSearchResult(attributes)
+		def searchUsersResults = new BasicNamingEnumerationImpl()
+		searchUsersResults.add(searchResults);
 
-	Attributes attributes = createUserAttributes(username, email, firstname, lastname)
-	SearchResult searchResults = createSearchResult(attributes)
-	def searchUsersResults = new BasicNamingEnumerationImpl()
-	searchUsersResults.add(searchResults);
+		def context = Mock(LdapContext)
+		context.search(_, _, _) >> searchUsersResults;
 
-	def context = Mock(LdapContext)
-	context.search(_, _, _) >> searchUsersResults;
-
-	return context
+		return context
     }
 
     private SearchResult createSearchResult(attributes) {
-	def search = Mock(SearchResult)
+		def search = Mock(SearchResult)
 
-	search.getName() >> "cn=" + attributes.getAt("uid").get();
+		search.getName() >> "cn=" + attributes.getAt("uid").get();
 
-	search.getAttributes() >> attributes
+		search.getAttributes() >> attributes
 
-	return search
+		return search
     }
 
     private Attributes createUserAttributes(String username, String email, String firstname, String lastname) {
-	def attributes = Mock(Attributes)
+		def attributes = Mock(Attributes)
 
-	def nameAttribute = Mock(Attribute)
-	nameAttribute.getId() >> "uid"
-	nameAttribute.get() >> username
-	attributes.get("uid") >> nameAttribute
+		def nameAttribute = Mock(Attribute)
+		nameAttribute.getId() >> "uid"
+		nameAttribute.get() >> username
+		attributes.get("uid") >> nameAttribute
 
-	def mailAttribute = Mock(Attribute)
-	mailAttribute.getId() >> "mail"
-	mailAttribute.get() >> email
-	attributes.get("mail") >> mailAttribute
+		def mailAttribute = Mock(Attribute)
+		mailAttribute.getId() >> "mail"
+		mailAttribute.get() >> email
+		attributes.get("mail") >> mailAttribute
 
-	def givennameAttribute = Mock(Attribute)
-	givennameAttribute.getId() >> "givenname"
-	givennameAttribute.get() >> firstname
-	attributes.get("givenname") >> givennameAttribute
+		def givennameAttribute = Mock(Attribute)
+		givennameAttribute.getId() >> "givenname"
+		givennameAttribute.get() >> firstname
+		attributes.get("givenname") >> givennameAttribute
 
-	def snAttribute = Mock(Attribute)
-	snAttribute.getId() >> "sn"
-	snAttribute.get() >> lastname
-	attributes.get("sn") >> snAttribute
+		def snAttribute = Mock(Attribute)
+		snAttribute.getId() >> "sn"
+		snAttribute.get() >> lastname
+		attributes.get("sn") >> snAttribute
 
-	return attributes
+		return attributes
     }
 
     def setupSpec() {
@@ -105,97 +110,97 @@ class LdapUserManagerSpec extends spock.lang.Specification {
         email = "rmurphy@test.com"
         firstname = "Ryan"
         lastname = "Murphy"
-	principal = "cn=" + username + "," + ldapConfiguration.getBaseDn()
+		principal = "cn=" + username + "," + ldapConfiguration.getBaseDn()
     }
 
     def "Test successfully creating an Ldap User from Search result"() {
-	given: "We have attributes, a search and a user manager"
-	def attributes = createUserAttributes(username, email, firstname, lastname)
+		given: "We have attributes, a search and a user manager"
+		def attributes = createUserAttributes(username, email, firstname, lastname)
         def search = createSearchResult(attributes)
         def userManager = new LdapUserManager(ldapConfiguration)
         def result = userManager.createUser(search)
 
-	expect: "The crated user the data supplied from LDAP"
+		expect: "The crated user the data supplied from LDAP"
 
         result.username == username
         result.email == email
         result.firstname == firstname
         result.lastname == lastname
-	result.principal == principal
+		result.principal == principal
     }
 
     def "Test successfully returning a list from get users"() {
-	given: "We have a LdapUserManager"
+		given: "We have a LdapUserManager"
 
         def userManager = new LdapUserManager(ldapConfiguration)
 
-	when: "A request for users is made"
+		when: "A request for users is made"
         def result = userManager.getUsers(username, createContext())
 
-	then: "A list of users is returned"
+		then: "A list of users is returned"
         result.size() == 1
     }
 
     def "Test successfully returning a list from get users when no username is given"() {
-	given: "We have a LdapUserManager"
+		given: "We have a LdapUserManager"
 
         def userManager = new LdapUserManager(ldapConfiguration)
 
-	when: "Get users is called without a username"
+		when: "Get users is called without a username"
         def result = userManager.getUsers(createContext())
 
-	then: "All users are returned"
-	result.size() == 1
+		then: "All users are returned"
+		result.size() == 1
     }
 
     def "Test successfully returning a NamingEnumeration from searchUsers"() {
-	given: "We have a LdapUserManager"
-	def userManager = new LdapUserManager(ldapConfiguration)
+		given: "We have a LdapUserManager"
+		def userManager = new LdapUserManager(ldapConfiguration)
 
-	when: "We search for users"
+		when: "We search for users"
         def result = userManager.searchUsers(createContext())
 
-	then: "A list of users are returned."
+		then: "A list of users are returned."
         result.next().getName() + "," + ldapConfiguration.getBaseDn() == principal
     }
 
     def "Test successfully returning an Ldap user from a get user request"() {
-	given: "We have a LdapUserMaanger"
+		given: "We have a LdapUserMaanger"
 
-	def userManager = new LdapUserManager(ldapConfiguration)
+		def userManager = new LdapUserManager(ldapConfiguration)
 
-	when: "A request for a user is made"
-	def result = userManager.getUser(username, createContext())
+		when: "A request for a user is made"
+		def result = userManager.getUser(username, createContext())
 
-	then: "The user is returned"
-	result.username == username
-	result.email == email
-	result.firstname == firstname
-	result.lastname == lastname
-	result.principal == principal
+		then: "The user is returned"
+		result.username == username
+		result.email == email
+		result.firstname == firstname
+		result.lastname == lastname
+		result.principal == principal
     }
 
     def "Test successfully throwing an exception when no users are found with getUser"() {
-	given: "We have a seachResult of users and a User Manager"
+		given: "We have a seachResult of users and a User Manager"
 
-	def searchUsersResults = new BasicNamingEnumerationImpl()
+		def searchUsersResults = new BasicNamingEnumerationImpl()
 
-	def context = Mock(LdapContext)
-	context.search(_, _, _) >> searchUsersResults;
+		def context = Mock(LdapContext)
+		context.search(_, _, _) >> searchUsersResults;
 
-	def userManager = new LdapUserManager(ldapConfiguration)
+		def userManager = new LdapUserManager(ldapConfiguration)
 
-	when: "a get user request is made and no user is found"
-	def result = userManager.getUser(username, context)
+		when: "a get user request is made and no user is found"
+		def result = userManager.getUser(username, context)
 
-	then: "An exception is thrown."
-	thrown NamingException
+		then: "An exception is thrown."
+		thrown NamingException
     }
 
     def "Test that a newly created Ldap User Manager is not null"() {
-	given: "You have created a new Ldap user manager object"
-	def result = new LdapUserManager();
-	expect: "The result is not null"
-	result != null
+		given: "You have created a new Ldap user manager object"
+		def result = new LdapUserManager();
+		expect: "The result is not null"
+		result != null
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserResponseSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserResponseSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserResponseSpec.groovy
index 2389a9d..f1978fa 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserResponseSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserResponseSpec.groovy
@@ -16,51 +16,52 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
+import org.apache.cloudstack.api.response.LdapUserResponse
 
 
 class LdapUserResponseSpec extends spock.lang.Specification {
     def "Testing succcessful setting of LdapUserResponse email"() {
-	given: "We have an LdapResponse"
+		given: "We have an LdapResponse"
         LdapUserResponse response = new LdapUserResponse();
-	when: "An email address is set"
+		when: "An email address is set"
         response.setEmail("rmurphy@test.com");
-	then: "Get email should return that set email"
-	response.getEmail() == "rmurphy@test.com";
+		then: "Get email should return that set email"
+		response.getEmail() == "rmurphy@test.com";
     }
 
     def "Testing successful setting of LdapUserResponse firstname"() {
-	given: "We have an LdapUserResponse"
-	LdapUserResponse response = new LdapUserResponse()
-	when: "A firstname is set"
+		given: "We have an LdapUserResponse"
+		LdapUserResponse response = new LdapUserResponse()
+		when: "A firstname is set"
         response.setFirstname("Ryan")
-	then: "gGet Firstname returns the set value"
+		then: "gGet Firstname returns the set value"
         response.getFirstname() == "Ryan"
     }
 
     def "Testing successful setting of LdapUserResponse lastname"() {
-	given: "We have an LdapUserResponse"
+		given: "We have an LdapUserResponse"
         LdapUserResponse response = new LdapUserResponse()
-	when: "A lastname is set"
+		when: "A lastname is set"
         response.setLastname("Murphy")
-	then: "Get lastname is returned"
-	response.getLastname() == "Murphy"
+		then: "Get lastname is returned"
+		response.getLastname() == "Murphy"
     }
 
     def "Testing successful setting of LdapUserResponse principal"() {
-	given: "We have an LdapResponse"
-	LdapUserResponse response = new LdapUserResponse()
-	when: "A principal is set"
-	response.setPrincipal("dc=cloudstack,dc=org")
-	then: "Get principled returns the set value"
-	response.getPrincipal() == "dc=cloudstack,dc=org"
+		given: "We have an LdapResponse"
+		LdapUserResponse response = new LdapUserResponse()
+		when: "A principal is set"
+		response.setPrincipal("dc=cloudstack,dc=org")
+		then: "Get principled returns the set value"
+		response.getPrincipal() == "dc=cloudstack,dc=org"
     }
 
     def "Testing successful setting of LdapUserResponse username"() {
-	given: "We have an LdapUserResponse"
-	LdapUserResponse response = new LdapUserResponse()
-	when: "A username is set"
-	response.setUsername("rmurphy")
-	then: "Get username returns the set value."
-	response.getUsername() == "rmurphy"
+		given: "We have an LdapUserResponse"
+		LdapUserResponse response = new LdapUserResponse()
+		when: "A username is set"
+		response.setUsername("rmurphy")
+		then: "Get username returns the set value."
+		response.getUsername() == "rmurphy"
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserSpec.groovy
index 6510352..8fd1ccc 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUserSpec.groovy
@@ -16,41 +16,42 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
+import org.apache.cloudstack.ldap.LdapUser
 
 class LdapUserSpec extends spock.lang.Specification {
 
     def "Testing LdapUsers hashCode generation"() {
-	given:
-	def userA = new LdapUser(usernameA, "", "", "", "")
-	expect:
-	userA.hashCode() == usernameA.hashCode()
-	where:
-	usernameA = "A"
+		given:
+		def userA = new LdapUser(usernameA, "", "", "", "")
+		expect:
+		userA.hashCode() == usernameA.hashCode()
+		where:
+		usernameA = "A"
     }
 
     def "Testing that LdapUser successfully gives the correct result for a compare to"() {
-	given: "You have created two LDAP user objects"
-	def userA = new LdapUser(usernameA, "", "", "", "")
-	def userB = new LdapUser(usernameB, "", "", "", "")
-	expect: "That when compared the result is less than or equal to 0"
-	userA.compareTo(userB) <= 0
-	where: "The following values are used"
-	usernameA | usernameB
-	"A"       | "B"
-	"A"       | "A"
+		given: "You have created two LDAP user objects"
+		def userA = new LdapUser(usernameA, "", "", "", "")
+		def userB = new LdapUser(usernameB, "", "", "", "")
+		expect: "That when compared the result is less than or equal to 0"
+		userA.compareTo(userB) <= 0
+		where: "The following values are used"
+		usernameA | usernameB
+		"A"       | "B"
+		"A"       | "A"
     }
 
     def "Testing that LdapUsers equality"() {
-	given:
-	def userA = new LdapUser(usernameA, "", "", "", "")
-	def userB = new LdapUser(usernameB, "", "", "", "")
-	expect:
-	userA.equals(userA) == true
-	userA.equals(new Object()) == false
-	userA.equals(userB) == false
-	where:
-	usernameA | usernameB
-	"A"       | "B"
+		given:
+		def userA = new LdapUser(usernameA, "", "", "", "")
+		def userB = new LdapUser(usernameB, "", "", "", "")
+		expect:
+		userA.equals(userA) == true
+		userA.equals(new Object()) == false
+		userA.equals(userB) == false
+		where:
+		usernameA | usernameB
+		"A"       | "B"
     }
 
     def "Testing that the username is correctly set with the ldap object"() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUtilsSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUtilsSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUtilsSpec.groovy
index 1825c39..984d2b3 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUtilsSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapUtilsSpec.groovy
@@ -16,18 +16,22 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
+import org.apache.cloudstack.ldap.LdapUtils
+
+import javax.naming.directory.Attribute
+import javax.naming.directory.Attributes
 
 class LdapUtilsSpec extends spock.lang.Specification {
     def "Testing than an attribute is not successfully returned"() {
 	given: "You have an attributes object with some attribute"
-	def attributes = Mock(Attributes)
-	attributes.get("uid") >> null
+		def attributes = Mock(Attributes)
+		attributes.get("uid") >> null
 
-	when: "You get the attribute"
-	String foundValue = LdapUtils.getAttributeValue(attributes, "uid")
+		when: "You get the attribute"
+		String foundValue = LdapUtils.getAttributeValue(attributes, "uid")
 
-	then: "Its value equals uid"
-	foundValue == null
+		then: "Its value equals uid"
+		foundValue == null
     }
 
     def "Testing than an attribute is successfully returned"() {
@@ -51,14 +55,14 @@ class LdapUtilsSpec extends spock.lang.Specification {
     }
 
     def "Testing that a Ldap Search Filter is correctly escaped"() {
-	given: "You have some input from a user"
+		given: "You have some input from a user"
 
-	expect: "That the input is escaped"
-	LdapUtils.escapeLDAPSearchFilter(input) == result
+		expect: "That the input is escaped"
+		LdapUtils.escapeLDAPSearchFilter(input) == result
 
-	where: "The following inputs are given "
-	input                                       | result
-	"Hi This is a test #çà"                     | "Hi This is a test #çà"
-	"Hi (This) = is * a \\ test # ç à ô \u0000" | "Hi \\28This\\29 = is \\2a a \\5c test # ç à ô \\00"
+		where: "The following inputs are given "
+		input                                       | result
+		"Hi This is a test #çà"                     | "Hi This is a test #çà"
+		"Hi (This) = is * a \\ test # ç à ô \u0000" | "Hi \\28This\\29 = is \\2a a \\5c test # ç à ô \\00"
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoLdapUserMatchingQueryExceptionSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoLdapUserMatchingQueryExceptionSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoLdapUserMatchingQueryExceptionSpec.groovy
index a301012..4c0cc4b 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoLdapUserMatchingQueryExceptionSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoLdapUserMatchingQueryExceptionSpec.groovy
@@ -16,6 +16,7 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
+import org.apache.cloudstack.ldap.NoLdapUserMatchingQueryException
 
 class NoLdapUserMatchingQueryExceptionSpec extends spock.lang.Specification {
     def "Test that the query is correctly set within the No LDAP user matching query exception object"() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoSuchLdapUserExceptionSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoSuchLdapUserExceptionSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoSuchLdapUserExceptionSpec.groovy
index 84cc908..dbdf646 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoSuchLdapUserExceptionSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/NoSuchLdapUserExceptionSpec.groovy
@@ -16,6 +16,7 @@
 // under the License.
 package groovy.org.apache.cloudstack.ldap
 
+import org.apache.cloudstack.ldap.NoSuchLdapUserException;
 
 class NoSuchLdapUserExceptionSpec extends spock.lang.Specification {
     def "Test that the username is correctly set within the No such LDAP user exception object"() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7f7035d5/ui/scripts/ui-custom/accountsWizard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/accountsWizard.js b/ui/scripts/ui-custom/accountsWizard.js
index 88cff58..358e29c 100644
--- a/ui/scripts/ui-custom/accountsWizard.js
+++ b/ui/scripts/ui-custom/accountsWizard.js
@@ -93,7 +93,7 @@
                 if (ldapStatus) {
                     var $table = $wizard.find('.ldap-account-choice tbody');
                     $.ajax({
-                        url: createURL("listAllLdapUsers"),
+			url: createURL("listLdapUsers&listtype=new"),
                         dataType: "json",
                         async: false,
                         success: function(json) {


Mime
View raw message