title: Writing Unit Tests for Oauth in spring boot framework
body: <p>I aim to write unit test for oauth - check if user name and token was correct.</p>
  
  <p>The search led me to this artical <a href="http://engineering.pivotal.io/post/faking_oauth_sso/" rel="nofollow noreferrer">Faking OAuth SSO</a></p>
  
  <p>For now, I am following strategy #1.</p>
  
  <p>Following is the piece of code for which I need to figure out dependencies they haven't mentioned directly.</p>
  
  <pre><code>@Test
  public void testGetAuthenticationInfo() throws Exception {
      MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
              .apply(springSecurity())
              .build();
  
      mockMvc.perform(MockMvcRequestBuilders.get("/api/token")
              .with(authentication(getOauthTestAuthentication()))
              .sessionAttr("scopedTarget.oauth2ClientContext", getOauth2ClientContext()))
              .andExpect(status().isOk())
              .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
              .andExpect(jsonPath("$.username").value("bwatkins"))
              .andExpect(jsonPath("$.token").value("my-fun-token"));
  }
  </code></pre>
  
  <p>I managed to arrange for webApplicationContext as below -</p>
  
  <pre><code>@Autowired
  private WebApplicationContext webApplicationContext;
  </code></pre>
  
  <p>For springSecurity() method, I am unable to get the dependency right. Whatever I searched for led me to believe that importing org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.* will get me the method but I am unable to get the pom dependency right.</p>
  
  <p>Question 1: Can anybody help me with getting the dependency right?
  Question 2: for such a standard thing as OAuth, isn't there a standard spring boot test package that should just require configuration to test if oauth is working fine or not</p>