/**
* Copyright (c) 2008-2011 Sonatype, Inc.
* All rights reserved. Includes the third-party code listed at http://www.sonatype.com/products/nexus/attributions.
*
* This program is free software: you can redistribute it and/or modify it only under the terms of the GNU Affero General
* Public License Version 3 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License Version 3
* for more details.
*
* You should have received a copy of the GNU Affero General Public License Version 3 along with this program. If not, see
* http://www.gnu.org/licenses.
*
* Sonatype Nexus (TM) Open Source Version is available from Sonatype, Inc. Sonatype and Sonatype Nexus are trademarks of
* Sonatype, Inc. Apache Maven is a trademark of the Apache Foundation. M2Eclipse is a trademark of the Eclipse Foundation.
* All other trademarks are the property of their respective owners.
*/
package org.sonatype.security.ldap.usermanagement;
import java.io.File;
import java.io.FileOutputStream;
import junit.framework.Assert;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.sonatype.ldaptestsuite.AbstractLdapTestEnvironment;
import org.sonatype.security.usermanagement.UserManager;
public class LdapUserManagerNotConfiguredTest
extends AbstractLdapTestEnvironment
{
public static final String SECURITY_CONFIG_KEY = "security-xml-file";
public static final String LDAP_CONFIGURATION_KEY = "application-conf";
protected static final File PLEXUS_HOME = new File( getBasedir(), "target/plexus-home" );
protected static final File CONF_HOME = new File( PLEXUS_HOME, "conf" );
@Override
protected void customizeContext( Context ctx )
{
ctx.put( SECURITY_CONFIG_KEY, new File( CONF_HOME, "security.xml" ).getAbsolutePath() );
ctx.put( LDAP_CONFIGURATION_KEY, CONF_HOME.getAbsolutePath() );
}
@Override
public void setUp()
throws Exception
{
FileUtils.deleteDirectory( CONF_HOME );
CONF_HOME.mkdirs();
IOUtil.copy(
getClass().getResourceAsStream( "/test-conf/conf/security-configuration-no-ldap.xml" ),
new FileOutputStream( new File( CONF_HOME, "security.xml" ) ) );
IOUtil.copy(
getClass().getResourceAsStream( "/test-conf/conf/security-configuration.xml" ),
new FileOutputStream( new File( CONF_HOME, "security-configuration.xml" ) ) );
// IOUtil.copy(
// getClass().getResourceAsStream( "/test-conf/conf/ldap.xml" ),
// new FileOutputStream( new File( CONF_HOME, "ldap.xml" ) ) );
super.setUp();
}
public void testNotConfigured()
throws Exception
{
UserManager userManager = this.lookup( UserManager.class, "LDAP" );
Assert.assertNull( userManager.getUser( "cstamas" ) );
}
}