@Test
    @ConfiguredWithCode("SSHCredentialsTest.yml")
    @Issue("SECURITY-1279")
    void shouldNotExportOrLogCredentials(JenkinsConfiguredWithCodeRule j) throws Exception {
        StandardUsernamePasswordCredentials creds = getCredentials(StandardUsernamePasswordCredentials.class);
        assertEquals(CREDENTIALS_PASSWORD, creds.getPassword().getPlainText());
        assertNotInLog(logging, CREDENTIALS_PASSWORD);

        BasicSSHUserPrivateKey certKey = getCredentials(BasicSSHUserPrivateKey.class);
        // JENKINS-50181 made getPrivateKey always append a trailing newline.
        assertEquals(PRIVATE_KEY + "\n", certKey.getPrivateKey());
        assertNotInLog(logging, PRIVATE_KEY);

        // Verify that the password does not get exported
        String exportedConfig = j.exportToString(false);
        assertThat(
                "There should be no password in the exported YAML",
                exportedConfig,
                not(containsString(CREDENTIALS_PASSWORD)));
        assertThat(
                "There should be no private key in the exported YAML",
                exportedConfig,
                not(containsString(PRIVATE_KEY)));
    }
Integration tests for the SSH Credentials Plugin.
integrations/src/test/java/io/jenkins/plugins/casc/SSHCredentialsTest.java