use of com.cloudbees.jenkins.support.filter.ContentFilter in project support-core-plugin by jenkinsci.
the class FileDescriptorLimitTest method addContentsFiltered.
@Test
public void addContentsFiltered() throws Exception {
Assume.assumeTrue(!Functions.isWindows());
Assume.assumeTrue(SystemPlatform.LINUX == SystemPlatform.current());
ContentFilters.get().setEnabled(true);
ContentMapping mapping = ContentMapping.of(SENSITIVE_WORD, FILTERED_SENSITIVE_WORD);
ContentMappings.get().getMappingOrCreate(mapping.getOriginal(), original -> mapping);
ContentFilter filter = SupportPlugin.getContentFilter().orElseThrow(AssertionFailedError::new);
FreeStyleProject p = j.createFreeStyleProject(SENSITIVE_JOB_NAME);
String output;
// Hold an open File Descriptor
try (FileInputStream ignored = new FileInputStream(p.getConfigFile().getFile())) {
output = SupportTestUtils.invokeComponentToString(new FileDescriptorLimit(), filter);
}
MatcherAssert.assertThat(output, containsString("core file size"));
MatcherAssert.assertThat(output, containsString("Open File Descriptor Count:"));
MatcherAssert.assertThat(output, containsString("All open files\n=============="));
MatcherAssert.assertThat(output, not(containsString(SENSITIVE_JOB_NAME)));
MatcherAssert.assertThat(output, containsString(FILTERED_JOB_NAME));
}
Aggregations