title: Not found custom security config in controller test
body: <p>I write test for get method of my controller and create custom config for authentication but when run test , generated default password and present this error :</p>
  
  <pre><code>MockHttpServletRequest:
    HTTP Method = GET
    Request URI = /android-guard-infos/1
     Parameters = {}
        Headers = {}
           Body = &lt;no character encoding set&gt;
  Session Attrs = {SPRING_SECURITY_SAVED_REQUEST=DefaultSavedRequest[http://localhost/android-guard-infos/1]}
  
  Handler:
           Type = null
  
  Async:
  Async started = false
   Async result = null
  
  Resolved Exception:
           Type = null
  
  ModelAndView:
      View name = null
           View = null
          Model = null
  
  FlashMap:
     Attributes = null
  
  MockHttpServletResponse:
         Status = 401
  Error message = Unauthorized
        Headers = {WWW-Authenticate=[Basic realm="Realm"], X-Content-    Type-Options=[nosniff], X-XSS-Protection=[1; mode=block], Cache-Control=[no-cache, no-store, max-age=0, must-revalidate], Pragma=[no-cache], Expires=[0], X-Frame-Options=[DENY]}
   Content type = null
           Body = 
  Forwarded URL = null
    Redirected URL = null
        Cookies = []
  
   java.lang.AssertionError: Status 
   Expected :200   
   Actual   :401
  
  at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:55)
  at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:82)
  at org.springframework.test.web.servlet.result.StatusResultMatchers.lambda$matcher$9(StatusResultMatchers.java:619)
  at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:178)
  at ir.fidar.seclab.controllersTest.AndroidGuardInfoControllerTest.getOneTest(AndroidGuardInfoControllerTest.java:39)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73)
  at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83)
  at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
  at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
  at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
  at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
  at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  </code></pre>
  
  <p>my dependency for test and security is :</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
    &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>and my security config class :</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class AppSecurityConfig extends WebSecurityConfigurerAdapter {
  
  @Autowired
  private AppUserDetailsService appUserDetailsService;
  
  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      auth.authenticationProvider(getProvider());
  
  }
  
  @Override
  protected void configure(HttpSecurity http) throws Exception {
  
  
          http.httpBasic().and().authorizeRequests()
              .antMatchers("/users/**","/roles/**","/privileges/**").hasAuthority("manager")
              .antMatchers("/android-guard-infos/**","process-queues/**",
                      "/risk-android-infos/**","/summery-infos/**",
                      "/virus-total-infos/**","/vt-process-queues/**").permitAll();
  }
  
  
  @Bean
  public AppAuthenticationProvider getProvider(){
      AppAuthenticationProvider provider = new AppAuthenticationProvider(appUserDetailsService);
      return provider;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>my test class:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @WebMvcTest(AndroidGuardInfoController.class)
  //@Import(AppSecurityConfig.class)
  public class AndroidGuardInfoControllerTest  {
  
  
  @Autowired
  private MockMvc mvc;
  
  @MockBean
  private AndroidGuardInfoService controller;
  
  @Test
  public void getOneTest() throws Exception {
      AndroidGuardInfo data = new AndroidGuardInfo();
  
  
      Mockito.when(controller.getOne(1L)).thenReturn(data);
      mvc.perform(MockMvcRequestBuilders.get("/android-guard-infos/1")).andExpect(status().isOk());
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I trying resolve this error by add  @Import(AppSecurityConfig.class) but 
  change error to <code>java.lang.IllegalStateException: Failed to load ApplicationContext</code> Caused by <code>Error creating bean</code> .</p>
  
  <p>can you guide me?</p>