@@ -0,0 +1,2752 @@
+package com.example.bootweb.actuator.security;%0D%0A%0D%0Aimport static org.assertj.core.api.Assertions.assertThat;%0D%0A%0D%0Aimport java.util.Map;%0D%0A%0D%0Aimport org.junit.Test;%0D%0Aimport org.junit.runner.RunWith;%0D%0Aimport org.springframework.beans.factory.annotation.Autowired;%0D%0Aimport org.springframework.boot.test.context.SpringBootTest;%0D%0Aimport org.springframework.boot.test.web.client.TestRestTemplate;%0D%0Aimport org.springframework.http.HttpStatus;%0D%0Aimport org.springframework.http.ResponseEntity;%0D%0Aimport org.springframework.test.annotation.DirtiesContext;%0D%0Aimport org.springframework.test.context.junit4.SpringRunner;%0D%0A%0D%0Aimport com.example.springboot.actuator.security.Application;%0D%0A%0D%0A@RunWith(SpringRunner.class)%0D%0A@SpringBootTest(classes = Application.class, //%0D%0A    webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)%0D%0A@DirtiesContext%0D%0Apublic class SampleActuatorCustomSecurityApplicationTests %7B%0D%0A%0D%0A  @Autowired%0D%0A  private TestRestTemplate restTemplate;%0D%0A%0D%0A  @Test%0D%0A  @SuppressWarnings(value = %7B%0D%0A      %22rawtypes%22, %22unchecked%22 %7D)%0D%0A  public void homeIsSecure() throws Exception %7B%0D%0A    ResponseEntity%3CMap%3E entity = this.restTemplate.getForEntity(%22/%22, Map.class);%0D%0A    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);%0D%0A    Map%3CString, Object%3E body = entity.getBody();%0D%0A    assertThat(body.get(%22error%22)).isEqualTo(%22Unauthorized%22);%0D%0A    assertThat(entity.getHeaders()).doesNotContainKey(%22Set-Cookie%22);%0D%0A  %7D%0D%0A%0D%0A  @Test%0D%0A  @SuppressWarnings(value = %7B%0D%0A      %22rawtypes%22, %22unchecked%22 %7D)%0D%0A  public void testInsecureApplicationPath() throws Exception %7B%0D%0A    ResponseEntity%3CMap%3E entity = this.restTemplate.getForEntity(%22/foo%22, Map.class);%0D%0A    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);%0D%0A    Map%3CString, Object%3E body = entity.getBody();%0D%0A    assertThat((String) body.get(%22message%22)).contains(%22Expected exception in controller%22);%0D%0A  %7D%0D%0A%0D%0A  @Test%0D%0A  public void testInsecureStaticResources() throws Exception %7B%0D%0A    ResponseEntity%3CString%3E entity = this.restTemplate.getForEntity(%22/css/bootstrap.min.css%22,%0D%0A        String.class);%0D%0A    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);%0D%0A    assertThat(entity.getBody()).contains(%22body%22);%0D%0A  %7D%0D%0A%0D%0A  @Test%0D%0A  public void insecureActuator() throws Exception %7B%0D%0A    ResponseEntity%3CString%3E entity = this.restTemplate.getForEntity(%22/status%22, String.class);%0D%0A    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);%0D%0A    assertThat(entity.getBody()).contains(%22%5C%22status%5C%22:%5C%22UP%5C%22%22);%0D%0A  %7D%0D%0A%0D%0A  @Test%0D%0A  @SuppressWarnings(%22rawtypes%22)%0D%0A  public void secureActuator() throws Exception %7B%0D%0A    ResponseEntity%3CMap%3E entity = this.restTemplate.getForEntity(%22/env%22, Map.class);%0D%0A    assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);%0D%0A  %7D%0D%0A%0D%0A%7D%0D%0A

add unit tes.