This is an automated email from the ASF dual-hosted git repository.

pvillard pushed a commit to branch NIFI-15258
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/NIFI-15258 by this push:
     new b32bf1fd52 NIFI-15648 - Resolve SECRET property values before 
fetchAllowableValues and verify in working flow context
b32bf1fd52 is described below

commit b32bf1fd52970c943ded63699d15b4a546acc572
Author: Pierre Villard <[email protected]>
AuthorDate: Wed Feb 25 20:50:07 2026 +0100

    NIFI-15648 - Resolve SECRET property values before fetchAllowableValues and 
verify in working flow context
---
 .../connector/StandardConnectorNode.java           |  6 +++
 .../TestStandardConnectorConfigurationContext.java | 43 ++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java
index 3496a66908..d819554f37 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/connector/StandardConnectorNode.java
@@ -674,6 +674,8 @@ public class StandardConnectorNode implements ConnectorNode 
{
                 stepName, propertyName, this));
         }
 
+        workingFlowContext.getConfigurationContext().resolvePropertyValues();
+
         try (NarCloseable ignored = 
NarCloseable.withComponentNarLoader(extensionManager, 
getConnector().getClass(), getIdentifier())) {
             return getConnector().fetchAllowableValues(stepName, propertyName, 
workingFlowContext);
         }
@@ -686,6 +688,8 @@ public class StandardConnectorNode implements ConnectorNode 
{
                 stepName, propertyName, this));
         }
 
+        workingFlowContext.getConfigurationContext().resolvePropertyValues();
+
         try (NarCloseable ignored = 
NarCloseable.withComponentNarLoader(extensionManager, 
getConnector().getClass(), getIdentifier())) {
             return getConnector().fetchAllowableValues(stepName, propertyName, 
workingFlowContext, filter);
         }
@@ -1060,6 +1064,8 @@ public class StandardConnectorNode implements 
ConnectorNode {
             return results;
         }
 
+        workingFlowContext.getConfigurationContext().resolvePropertyValues();
+
         try (NarCloseable ignored = 
NarCloseable.withComponentNarLoader(extensionManager, 
getConnector().getClass(), getIdentifier())) {
             results.addAll(getConnector().verify(workingFlowContext));
         }
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardConnectorConfigurationContext.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardConnectorConfigurationContext.java
index 9c8b6b6e08..6a73137ac7 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardConnectorConfigurationContext.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardConnectorConfigurationContext.java
@@ -18,16 +18,21 @@
 package org.apache.nifi.components.connector;
 
 import org.apache.nifi.asset.AssetManager;
+import org.apache.nifi.components.connector.secrets.SecretProvider;
 import org.apache.nifi.components.connector.secrets.SecretsManager;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 public class TestStandardConnectorConfigurationContext {
     private StandardConnectorConfigurationContext context;
@@ -210,4 +215,42 @@ public class TestStandardConnectorConfigurationContext {
         assertNull(clonedContext.getProperty("step1", 
"nonExistent").getValue());
         assertNull(clonedContext.getProperty("nonExistentStep", 
"key1").getValue());
     }
+
+    @Test
+    public void 
testResolvePropertyValuesResolvesSecretsThatWereInitiallyUnresolvable() {
+        final String providerId = "provider-1";
+        final String providerName = "TestProvider";
+        final String secretName = "mySecret";
+        final String fullyQualifiedName = "TestProvider.mySecret";
+        final String secretValue = "super-secret-value";
+
+        final SecretProvider secretProvider = mock(SecretProvider.class);
+        when(secretProvider.getProviderId()).thenReturn(providerId);
+        when(secretProvider.getProviderName()).thenReturn(providerName);
+
+        final Secret secret = mock(Secret.class);
+        when(secret.getValue()).thenReturn(secretValue);
+        
when(secretProvider.getSecrets(List.of(fullyQualifiedName))).thenReturn(List.of(secret));
+
+        final SecretsManager secretsManager = mock(SecretsManager.class);
+        
when(secretsManager.getSecretProviders()).thenReturn(Collections.emptySet());
+
+        final AssetManager assetManager = mock(AssetManager.class);
+        final StandardConnectorConfigurationContext testContext = new 
StandardConnectorConfigurationContext(assetManager, secretsManager);
+
+        final SecretReference secretRef = new SecretReference(providerId, 
providerName, secretName, fullyQualifiedName);
+        final Map<String, ConnectorValueReference> properties = new 
HashMap<>();
+        properties.put("plainProp", new StringLiteralValue("plainValue"));
+        properties.put("secretProp", secretRef);
+        testContext.setProperties("authStep", new 
StepConfiguration(properties));
+
+        assertEquals("plainValue", testContext.getProperty("authStep", 
"plainProp").getValue());
+        assertNull(testContext.getProperty("authStep", 
"secretProp").getValue());
+
+        
when(secretsManager.getSecretProviders()).thenReturn(Set.of(secretProvider));
+        testContext.resolvePropertyValues();
+
+        assertEquals("plainValue", testContext.getProperty("authStep", 
"plainProp").getValue());
+        assertEquals(secretValue, testContext.getProperty("authStep", 
"secretProp").getValue());
+    }
 }

Reply via email to