@Test
    void testGetAuthenticationInfoNonSimpleToken() throws NamingException {
        realm.setUserDnTemplate("uid={0},ou=users,dc=mycompany,dc=com");
        LdapContextFactory factory = createMock(LdapContextFactory.class);
        realm.setContextFactory(factory);

        final UUID userId = UUID.randomUUID();

        //ensure the userId is passed as-is:
        expect(factory.getLdapContext(eq(userId), isA(Object.class))).andReturn(createNiceMock(LdapContext.class));
        replay(factory);

        realm.getAuthenticationInfo(new AuthenticationToken() {
            public Object getPrincipal() {
                return userId;
            }

            public Object getCredentials() {
                return "secret";
            }
        });
        verify(factory);
    }
This test simulates that if a non-String principal (i.e. not a username) is passed as the LDAP principal, that
it is not altered into a User DN and is passed as-is.  This will allow principals to be things like X.509
certificates as well instead of only strings.

@throws NamingException not thrown
core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java