'How to avoid jwt token or ignore authentication when testing HTTP API request?

mvc.perform(MockMvcRequestBuilders.get("/PensionerDetailByAadhaar?aadhaarNumber=123").header("Authorization","Bearer "+token)).andExpect(status().isOk());

Here I need to test GET API Request. But when I run this it's throwing 400 error because of authentication(Implemented in controller) . I need to test this GET request without Header (without generating JWT Token).How can I ingore Header in testing? I couldn't generate token in test method and pass to it

Could you please anyone help me?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source