From f31f2a5f2663844874d017c69f941458bedeaf51 Mon Sep 17 00:00:00 2001 From: Andy LoPresto Date: Fri, 26 May 2017 10:27:18 -0700 Subject: [PATCH] NIFI-3836 Added check for root user in test that depends on unreadable file. This closes #1865. Signed-off-by: Andy LoPresto --- .../org/apache/nifi/provenance/CryptoUtilsTest.groovy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nifi-commons/nifi-data-provenance-utils/src/test/groovy/org/apache/nifi/provenance/CryptoUtilsTest.groovy b/nifi-commons/nifi-data-provenance-utils/src/test/groovy/org/apache/nifi/provenance/CryptoUtilsTest.groovy index f4992b68b7..9ba8e97501 100644 --- a/nifi-commons/nifi-data-provenance-utils/src/test/groovy/org/apache/nifi/provenance/CryptoUtilsTest.groovy +++ b/nifi-commons/nifi-data-provenance-utils/src/test/groovy/org/apache/nifi/provenance/CryptoUtilsTest.groovy @@ -88,6 +88,14 @@ class CryptoUtilsTest { 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 void testShouldConcatenateByteArrays() { // Arrange @@ -197,6 +205,7 @@ class CryptoUtilsTest { void testShouldNotValidateUnreadableFileBasedKeyProvider() { // Arrange 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 File fileBasedProviderFile = tempFolder.newFile("filebased.kp")