1 package com.atlassian.user.impl.ldap;
2
3 import com.atlassian.user.GroupManager;
4 import com.atlassian.user.generic.AbstractSpringTest;
5 import com.atlassian.user.impl.ldap.repository.LdapConnectionFailedException;
6
7
8
9
10 public class TestLdapGroupManagerConnectionFailures extends AbstractSpringTest
11 {
12 private GroupManager ldapGroupManager;
13
14 protected String[] getConfigLocations()
15 {
16 return new String[]{
17 "classpath:com/atlassian/user/impl/ldap/ldapTestContext.xml",
18 "classpath:com/atlassian/user/impl/ldap/ldapTestServerContext.xml",
19 "classpath:com/atlassian/user/impl/ldap/ldapTestFailureContext.xml",
20 };
21 }
22
23 public void setLdapGroupManager(GroupManager ldapGroupManager)
24 {
25 this.ldapGroupManager = ldapGroupManager;
26 }
27
28 public void testGetGroups() throws Exception
29 {
30 try
31 {
32 ldapGroupManager.getGroups();
33 fail("Expected connection failure");
34 }
35 catch (LdapConnectionFailedException expected)
36 {
37 }
38 }
39
40 public void testGetGroup() throws Exception
41 {
42 try
43 {
44 ldapGroupManager.getGroup("group");
45 fail("Expected connection failure");
46 }
47 catch (LdapConnectionFailedException expected)
48 {
49 }
50 }
51
52 public void testGetGroupsForUser() throws Exception
53 {
54 try
55 {
56 ldapGroupManager.getGroups(new DefaultLDAPUser("foo", "dn=bar"));
57 fail("Expected connection failure");
58 }
59 catch (LdapConnectionFailedException expected)
60 {
61 }
62 }
63 }