Commit 1b6f39b3 authored by Ananas Orange's avatar Ananas Orange
Browse files

Minor

parent 851a612a
......@@ -25,6 +25,7 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.TestPropertySource;
......@@ -110,6 +111,19 @@ class CleaControllerAuthEnabledTest {
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
@DisplayName("unsecured apis should return 200 when called with an invalid auth token")
void testUnsecuredApiWithInvalidToken() {
HttpHeaders headers = CleaControllerTest.newJsonHeader();
headers.setBearerAuth(RandomStringUtils.randomAlphanumeric(20));
ResponseEntity<String> response = restTemplate.exchange("/actuator", HttpMethod.GET, new HttpEntity<>(headers), String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
response = restTemplate.exchange("/swagger-ui/", HttpMethod.GET, new HttpEntity<>(headers), String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
@DisplayName("secured apis should return 200 when called with a valid auth token")
void validRequestWithAuthEnabledAndValidToken() throws NoSuchAlgorithmException, InvalidKeySpecException {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment