Examples of LdapManager


Examples of org.sonatype.security.ldap.realms.LdapManager

  @Test
  public void testAuthenticate()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);
    LdapServer ldapServer = this.getLdapServer("default");

    Assert.assertNotNull(ldapManager.authenticateUser("brianf", "brianf123"));

    ldapServer.stop();

    try {
      ldapManager.authenticateUser("brianf", "brianf123");
      Assert.fail("Expected AuthenticationException");
    }
    catch (AuthenticationException e) {
      // expected
    }

    ldapServer.start();

    try {
      ldapManager.authenticateUser("brianf", "brianf123");
      Assert.fail("Expected AuthenticationException");
    }
    catch (AuthenticationException e) {
      // expected
    }

    // wait 3 more sec, then we should be good
    Thread.sleep(7 * 1000);
    Assert.assertNotNull(ldapManager.authenticateUser("brianf", "brianf123"));
  }
View Full Code Here

Examples of org.sonatype.security.ldap.realms.LdapManager

  @Test
  public void testGetAllGroups()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);
    LdapServer ldapServer = this.getLdapServer("default");

    SortedSet<String> expectedGroups = new TreeSet<String>();
    // from the default
    expectedGroups.add("public");
    expectedGroups.add("releases");
    expectedGroups.add("snapshots");

    SortedSet<String> actualGroups = ldapManager.getAllGroups();
    Assert.assertEquals(expectedGroups, actualGroups);

    ldapServer.stop();

    Assert.assertEquals(0, ldapManager.getAllGroups().size());

    ldapServer.start();

    Assert.assertEquals(0, ldapManager.getAllGroups().size());

    // wait 3 more sec, then we should be good
    Thread.sleep(7 * 1000);

    actualGroups = ldapManager.getAllGroups();
    Assert.assertEquals(expectedGroups, actualGroups);
  }
View Full Code Here

Examples of org.sonatype.security.ldap.realms.LdapManager

  @Test
  public void testGetAllUsers()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);
    LdapServer ldapServer = this.getLdapServer("default");

    Assert.assertEquals(3, ldapManager.getAllUsers().size());

    ldapServer.stop();
    Assert.assertEquals(0, ldapManager.getAllUsers().size());

    ldapServer.start();
    Assert.assertEquals(0, ldapManager.getAllUsers().size());

    // wait 3 more sec, then we should be good
    Thread.sleep(7 * 1000);
    Assert.assertEquals(3, ldapManager.getAllUsers().size());
  }
View Full Code Here

Examples of org.sonatype.security.ldap.realms.LdapManager

  @Test
  public void testGetGroupName()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);
    LdapServer ldapServer = this.getLdapServer("default");

    Assert.assertEquals("releases", ldapManager.getGroupName("releases"));

    ldapServer.stop();

    try {
      ldapManager.getGroupName("releases");
      Assert.fail("Expected LdapDAOException");
    }
    catch (NoSuchLdapGroupException e) {
      // expected
    }

    ldapServer.start();

    try {
      ldapManager.getGroupName("releases");
      Assert.fail("Expected LdapDAOException");
    }
    catch (NoSuchLdapGroupException e) {
      // expected
    }

    // wait 3 more sec, then we should be good
    Thread.sleep(7 * 1000);
    Assert.assertEquals("releases", ldapManager.getGroupName("releases"));
  }
View Full Code Here

Examples of org.sonatype.security.ldap.realms.LdapManager

  @Test
  public void testGetUser()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);
    LdapServer ldapServer = this.getLdapServer("default");

    LdapUser brianf = ldapManager.getUser("brianf");
    Assert.assertNotNull(brianf);
    Assert.assertEquals("brianf", brianf.getUsername());
    Assert.assertEquals(brianf.getUsername() + "123", brianf.getPassword());
    Assert.assertEquals("Brian Fox", brianf.getRealName());
    Assert.assertEquals(2, brianf.getMembership().size());

    ldapServer.stop();
    try {
      ldapManager.getUser("brianf");
      Assert.fail("Expected NoSuchLdapUserException");
    }
    catch (NoSuchLdapUserException e) {
      // expected
    }

    ldapServer.start();
    try {
      ldapManager.getUser("brianf");
      Assert.fail("Expected NoSuchLdapUserException");
    }
    catch (NoSuchLdapUserException e) {
      // expected
    }


    // wait 3 more sec, then we should be good
    Thread.sleep(7 * 1000);
    Assert.assertNotNull(ldapManager.getUser("brianf"));

  }
View Full Code Here

Examples of org.sonatype.security.ldap.realms.LdapManager

  @Test
  public void testGetUserRoles()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);
    LdapServer ldapServer = this.getLdapServer("default");

    Assert.assertEquals(2, ldapManager.getUserRoles("brianf").size());

    ldapServer.stop();
    try {
      ldapManager.getUserRoles("brianf");
      Assert.fail("Expected LdapDAOException");
    }
    catch (NoLdapUserRolesFoundException e) {
      // expected
    }

    ldapServer.start();
    try {
      ldapManager.getUserRoles("brianf");
      Assert.fail("Expected LdapDAOException");
    }
    catch (NoLdapUserRolesFoundException e) {
      // expected
    }

    // wait 3 more sec, then we should be good
    Thread.sleep(7 * 1000);
    Assert.assertEquals(2, ldapManager.getUserRoles("brianf").size());
  }
View Full Code Here

Examples of org.sonatype.security.ldap.realms.LdapManager

  @Test
  public void testGetUsers()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);
    LdapServer ldapServer = this.getLdapServer("default");

    // exact number
    Assert.assertEquals(1, ldapManager.getUsers(1).size());


    ldapServer.stop();
    Assert.assertEquals(0, ldapManager.getUsers(1).size());

    ldapServer.start();
    Assert.assertEquals(0, ldapManager.getUsers(1).size());

    // wait 3 more sec, then we should be good
    Thread.sleep(7 * 1000);
    Assert.assertEquals(1, ldapManager.getUsers(1).size());

  }
View Full Code Here

Examples of org.sonatype.security.ldap.realms.LdapManager

  @Test
  public void testSearchUsers()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);
    LdapServer ldapServer = this.getLdapServer("default");

    Assert.assertEquals(3, ldapManager.searchUsers("", null).size());

    ldapServer.stop();
    Assert.assertEquals(0, ldapManager.searchUsers("", null).size());

    ldapServer.start();
    Assert.assertEquals(0, ldapManager.searchUsers("", null).size());

    // wait 3 more sec, then we should be good
    Thread.sleep(7 * 1000);
    Assert.assertEquals(3, ldapManager.searchUsers("", null).size());
  }
View Full Code Here

Examples of org.sonatype.security.ldap.realms.LdapManager

  @Test
  public void testLdapManager()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);

    SortedSet<String> groupIds = new TreeSet<String>();
    groupIds.add("alpha");
    groupIds.add("beta");
    groupIds.add("gamma");

    LdapUser jmeis = ldapManager.getUser("jmeis");
    Assert.assertEquals(groupIds, jmeis.getMembership());

    LdapUser rwalker = ldapManager.getUser("rwalker");
    Assert.assertEquals(groupIds, rwalker.getMembership());
  }
View Full Code Here

Examples of org.sonatype.security.ldap.realms.LdapManager

    SortedSet<String> groupIds = new TreeSet<String>();
    groupIds.add("alpha");
    groupIds.add("beta");
    groupIds.add("gamma");

    LdapManager ldapManager = this.lookup(LdapManager.class);
    LdapUser jmeis = ldapManager.authenticateUser("jmeis", "jmeis123");
    Assert.assertEquals(groupIds, jmeis.getMembership());

    LdapUser rwalker = ldapManager.authenticateUser("rwalker", "rwalker123");
    Assert.assertEquals(groupIds, rwalker.getMembership());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.