NIFI-3836 Added check for root user in test that depends on unreadable file.

This closes #1865.

Signed-off-by: Andy LoPresto <alopresto@apache.org>
This commit is contained in:
Andy LoPresto 2017-05-26 10:27:18 -07:00
parent 082b99640e
commit f31f2a5f26
No known key found for this signature in database
GPG Key ID: 6EC293152D90B61D
1 changed files with 9 additions and 0 deletions

View File

@ -88,6 +88,14 @@ class CryptoUtilsTest {
Cipher.getMaxAllowedKeyLength("AES") > 128 Cipher.getMaxAllowedKeyLength("AES") > 128
} }
private static boolean isRootUser() {
ProcessBuilder pb = new ProcessBuilder(["id", "-u"])
Process process = pb.start()
InputStream responseStream = process.getInputStream()
BufferedReader responseReader = new BufferedReader(new InputStreamReader(responseStream))
responseReader.text.trim() == "0"
}
@Test @Test
void testShouldConcatenateByteArrays() { void testShouldConcatenateByteArrays() {
// Arrange // Arrange
@ -197,6 +205,7 @@ class CryptoUtilsTest {
void testShouldNotValidateUnreadableFileBasedKeyProvider() { void testShouldNotValidateUnreadableFileBasedKeyProvider() {
// Arrange // Arrange
Assume.assumeFalse("This test does not run on Windows", SystemUtils.IS_OS_WINDOWS) Assume.assumeFalse("This test does not run on Windows", SystemUtils.IS_OS_WINDOWS)
Assume.assumeFalse("This test does not run for root users", isRootUser())
String fileBasedProvider = FileBasedKeyProvider.class.name String fileBasedProvider = FileBasedKeyProvider.class.name
File fileBasedProviderFile = tempFolder.newFile("filebased.kp") File fileBasedProviderFile = tempFolder.newFile("filebased.kp")