Search in sources :

Example 1 with Sanitizer

use of org.springframework.boot.actuate.endpoint.Sanitizer in project spring-boot by spring-projects.

the class QuartzEndpointTests method quartzJobWithSensitiveDataMapAndCustomSanitizier.

@Test
void quartzJobWithSensitiveDataMapAndCustomSanitizier() throws SchedulerException {
    JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").usingJobData("test", "value").usingJobData("secret", "value").build();
    mockJobs(job);
    Sanitizer sanitizer = mock(Sanitizer.class);
    given(sanitizer.sanitize("test", "value")).willReturn("value");
    given(sanitizer.sanitize("secret", "value")).willReturn("----");
    QuartzJobDetails jobDetails = new QuartzEndpoint(this.scheduler, sanitizer).quartzJob("samples", "hello");
    assertThat(jobDetails.getData()).containsOnly(entry("test", "value"), entry("secret", "----"));
    then(sanitizer).should().sanitize("test", "value");
    then(sanitizer).should().sanitize("secret", "value");
    then(sanitizer).shouldHaveNoMoreInteractions();
}
Also used : JobDetail(org.quartz.JobDetail) QuartzJobDetails(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails) Sanitizer(org.springframework.boot.actuate.endpoint.Sanitizer) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 JobDetail (org.quartz.JobDetail)1 Sanitizer (org.springframework.boot.actuate.endpoint.Sanitizer)1 QuartzJobDetails (org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails)1