mirror of https://github.com/apache/nifi.git
NIFI-11519 Fixed DBCPConnectionPool Sensitive Dynamic Properties
- Added handling for property names marked as sensitive but not having the SENSITIVE prefix for backward compatibility This closes #7646 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
a5ca73b2da
commit
af365414e9
|
@ -272,7 +272,12 @@ public class DBCPConnectionPool extends AbstractDBCPConnectionPool implements DB
|
|||
.map(descriptor -> {
|
||||
final PropertyValue propertyValue = context.getProperty(descriptor);
|
||||
if (descriptor.isSensitive()) {
|
||||
final String propertyName = StringUtils.substringAfter(descriptor.getName(), SENSITIVE_PROPERTY_PREFIX);
|
||||
final String propertyName;
|
||||
if (StringUtils.startsWith(descriptor.getName(), SENSITIVE_PROPERTY_PREFIX)) {
|
||||
propertyName = StringUtils.substringAfter(descriptor.getName(), SENSITIVE_PROPERTY_PREFIX);
|
||||
} else {
|
||||
propertyName = descriptor.getName();
|
||||
}
|
||||
return new AbstractMap.SimpleEntry<>(propertyName, propertyValue.getValue());
|
||||
} else {
|
||||
return new AbstractMap.SimpleEntry<>(descriptor.getName(), propertyValue.evaluateAttributeExpressions().getValue());
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.opentest4j.AssertionFailedError;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -162,6 +163,15 @@ public class DBCPServiceTest {
|
|||
assertConnectionNotNullDynamicProperty("SENSITIVE.create", "true");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConnectionSensitiveDynamicPropertyWithoutPrefixAndWithPrefixShouldThrowException() {
|
||||
runner.setProperty(service, "SENSITIVE.create", "true");
|
||||
runner.setProperty(service, "create", "true");
|
||||
|
||||
final AssertionFailedError e = assertThrows(AssertionFailedError.class, () -> runner.enableControllerService(service));
|
||||
assertTrue(e.getMessage().contains("Duplicate"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConnectionExecuteStatements() throws SQLException {
|
||||
runner.enableControllerService(service);
|
||||
|
|
Loading…
Reference in New Issue