@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2012 - 201 5 the original author or authors .
* Copyright 2012 - 201 6 the original author or authors .
*
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -25,11 +25,13 @@ import java.util.UUID;
import org.crsh.auth.AuthenticationPlugin ;
import org.crsh.auth.AuthenticationPlugin ;
import org.crsh.auth.JaasAuthenticationPlugin ;
import org.crsh.auth.JaasAuthenticationPlugin ;
import org.crsh.lang.impl.groovy.GroovyRepl ;
import org.crsh.lang.impl.java.JavaLanguage ;
import org.crsh.lang.spi.Language ;
import org.crsh.plugin.PluginContext ;
import org.crsh.plugin.PluginContext ;
import org.crsh.plugin.PluginLifeCycle ;
import org.crsh.plugin.PluginLifeCycle ;
import org.crsh.plugin.ResourceKind ;
import org.crsh.plugin.ResourceKind ;
import org.crsh.telnet.term.processor.ProcessorIOHandler ;
import org.crsh.telnet.term.processor.ProcessorIOHandler ;
import org.crsh.telnet.term.spi.TermIOHandler ;
import org.crsh.vfs.Resource ;
import org.crsh.vfs.Resource ;
import org.junit.After ;
import org.junit.After ;
import org.junit.Test ;
import org.junit.Test ;
@ -51,10 +53,13 @@ import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.authority.SimpleGrantedAuthority ;
import org.springframework.security.core.authority.SimpleGrantedAuthority ;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext ;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext ;
import static org.hamcrest.CoreMatchers.hasItem ;
import static org.hamcrest.CoreMatchers.isA ;
import static org.hamcrest.CoreMatchers.not ;
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertFalse ;
import static org.junit.Assert.assertFalse ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assertNotNull ;
import static org.junit.Assert.assert Null ;
import static org.junit.Assert.assert That ;
import static org.junit.Assert.assertTrue ;
import static org.junit.Assert.assertTrue ;
/ * *
/ * *
@ -63,6 +68,7 @@ import static org.junit.Assert.assertTrue;
* @author Christian Dupuis
* @author Christian Dupuis
* @author Andreas Ahlenstorf
* @author Andreas Ahlenstorf
* @author Edd ú Mel é ndez
* @author Edd ú Mel é ndez
* @author Matt Benson
* /
* /
@SuppressWarnings ( { "rawtypes" , "unchecked" } )
@SuppressWarnings ( { "rawtypes" , "unchecked" } )
public class CrshAutoConfigurationTests {
public class CrshAutoConfigurationTests {
@ -80,15 +86,18 @@ public class CrshAutoConfigurationTests {
public void testDisabledPlugins ( ) throws Exception {
public void testDisabledPlugins ( ) throws Exception {
MockEnvironment env = new MockEnvironment ( ) ;
MockEnvironment env = new MockEnvironment ( ) ;
env . setProperty ( "shell.disabled_plugins" ,
env . setProperty ( "shell.disabled_plugins" ,
" GroovyREPL, termIOHandler, org.crsh.auth.AuthenticationPlugin") ;
" termIOHandler, org.crsh.auth.AuthenticationPlugin, javaLanguage ") ;
load ( env ) ;
load ( env ) ;
PluginLifeCycle lifeCycle = this . context . getBean ( PluginLifeCycle . class ) ;
PluginLifeCycle lifeCycle = this . context . getBean ( PluginLifeCycle . class ) ;
assertNotNull ( lifeCycle ) ;
assertNotNull ( lifeCycle ) ;
assertNull ( lifeCycle . getContext ( ) . getPlugin ( GroovyRepl . class ) ) ;
assertThat ( lifeCycle . getContext ( ) . getPlugins ( TermIOHandler . class ) ,
assertNull ( lifeCycle . getContext ( ) . getPlugin ( ProcessorIOHandler . class ) ) ;
not ( hasItem ( isA ( ProcessorIOHandler . class ) ) ) ) ;
assertNull ( lifeCycle . getContext ( ) . getPlugin ( JaasAuthenticationPlugin . class ) ) ;
assertThat ( lifeCycle . getContext ( ) . getPlugins ( AuthenticationPlugin . class ) ,
not ( hasItem ( isA ( JaasAuthenticationPlugin . class ) ) ) ) ;
assertThat ( lifeCycle . getContext ( ) . getPlugins ( Language . class ) ,
not ( hasItem ( isA ( JavaLanguage . class ) ) ) ) ;
}
}
@Test
@Test