title: Unit Testing Rest API | Need to Disable Authorization| Spring Boot
body: <p>I have developed a REST API using Spring Boot.I need to unit test POST method of REST API developed. Since i have used </p>
  
  <blockquote>
    <p>@EnableSecurity in Application.class
    @@Authorization(authorizedGroups = {"CN=APP-XYG-Group"} in Controller</p>
  </blockquote>
  
  <p>I am not able to test using Junit, since i have Enabled Security and i get 403 error , when actually i would like to test for 200 OK http status code.</p>
  
  <p>I would like to disable the security checking while doing testing, Is it possible. Please find the code snippet below:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  public class ParseInput {
  
      @Autowired
      TestRestTemplate restTemplate;
  
      @Test
      public void testRate() throws Exception {
  
          //setting up input for test case
          QReq qReq= new QReq();
          ObjectMapper objectMapper = new ObjectMapper();
  
          try {
              qReq = objectMapper.readValue(new File("src/main/resources/input.json"), QReq.class);
          }catch (Exception e){
              System.out.println("Error message here is " + e.getMessage());
          }
  
          //Executing the test case
  
          ResponseEntity&lt;QResp&gt; subject = restTemplate.postForEntity("/tax_rates/v1/quotations", qReq, QResp.class);
          Assert.assertEquals(HttpStatus.OK, subject.getStatusCode());
      }
  
  }
  </code></pre>
  
  <p>Any help appreciated</p>