Skip to content

Commit 90fe326

Browse files
trixpanijokarumawak
authored andcommitted
NIFI-4196 - Expose AWS proxy authentication settings
NIFI-4196 - Fix jUnit errors This closes #2016. Signed-off-by: Koji Kawamura <[email protected]>
1 parent cee6025 commit 90fe326

File tree

11 files changed

+50
-9
lines changed

11 files changed

+50
-9
lines changed

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ public abstract class AbstractAWSProcessor<ClientType extends AmazonWebServiceCl
9292
.addValidator(StandardValidators.PORT_VALIDATOR)
9393
.build();
9494

95+
public static final PropertyDescriptor PROXY_USERNAME = new PropertyDescriptor.Builder()
96+
.name("Proxy Username")
97+
.description("Proxy username")
98+
.expressionLanguageSupported(true)
99+
.required(false)
100+
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
101+
.build();
102+
103+
public static final PropertyDescriptor PROXY_PASSWORD = new PropertyDescriptor.Builder()
104+
.name("Proxy Password")
105+
.description("Proxy password")
106+
.expressionLanguageSupported(true)
107+
.required(false)
108+
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
109+
.sensitive(true)
110+
.build();
111+
95112
public static final PropertyDescriptor REGION = new PropertyDescriptor.Builder()
96113
.name("Region")
97114
.required(true)
@@ -199,6 +216,13 @@ protected ClientConfiguration createConfiguration(final ProcessContext context)
199216
config.setProxyPort(proxyPort);
200217
}
201218

219+
if (context.getProperty(PROXY_USERNAME).isSet()) {
220+
String proxyUsername = context.getProperty(PROXY_USERNAME).evaluateAttributeExpressions().getValue();
221+
config.setProxyUsername(proxyUsername);
222+
String proxyPassword = context.getProperty(PROXY_PASSWORD).evaluateAttributeExpressions().getValue();
223+
config.setProxyPassword(proxyPassword);
224+
}
225+
202226
return config;
203227
}
204228

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/cloudwatch/PutCloudWatchMetric.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public ValidationResult validate(String subject, String input, ValidationContext
174174
Collections.unmodifiableList(
175175
Arrays.asList(NAMESPACE, METRIC_NAME, VALUE, MAXIMUM, MINIMUM, SAMPLECOUNT, SUM, TIMESTAMP,
176176
UNIT, REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE,
177-
TIMEOUT, SSL_CONTEXT_SERVICE, ENDPOINT_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT)
177+
TIMEOUT, SSL_CONTEXT_SERVICE, ENDPOINT_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD)
178178
);
179179

180180
private volatile Set<String> dynamicPropertyNames = new HashSet<>();

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/DeleteS3Object.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class DeleteS3Object extends AbstractS3Processor {
5959
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
6060
Arrays.asList(KEY, BUCKET, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, REGION, TIMEOUT, VERSION_ID,
6161
FULL_CONTROL_USER_LIST, READ_USER_LIST, WRITE_USER_LIST, READ_ACL_LIST, WRITE_ACL_LIST, OWNER,
62-
SSL_CONTEXT_SERVICE, ENDPOINT_OVERRIDE, SIGNER_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT));
62+
SSL_CONTEXT_SERVICE, ENDPOINT_OVERRIDE, SIGNER_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD));
6363

6464
@Override
6565
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/FetchS3Object.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class FetchS3Object extends AbstractS3Processor {
7676

7777
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
7878
Arrays.asList(BUCKET, KEY, REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, VERSION_ID,
79-
SSL_CONTEXT_SERVICE, ENDPOINT_OVERRIDE, SIGNER_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT));
79+
SSL_CONTEXT_SERVICE, ENDPOINT_OVERRIDE, SIGNER_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD));
8080

8181
@Override
8282
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/ListS3.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public class ListS3 extends AbstractS3Processor {
137137
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
138138
Arrays.asList(BUCKET, REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE,
139139
AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, SSL_CONTEXT_SERVICE, ENDPOINT_OVERRIDE,
140-
SIGNER_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT, DELIMITER, PREFIX, USE_VERSIONS, LIST_TYPE, MIN_AGE));
140+
SIGNER_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD, DELIMITER, PREFIX, USE_VERSIONS, LIST_TYPE, MIN_AGE));
141141

142142
public static final Set<Relationship> relationships = Collections.unmodifiableSet(
143143
new HashSet<>(Collections.singletonList(REL_SUCCESS)));

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/PutS3Object.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public class PutS3Object extends AbstractS3Processor {
209209
Arrays.asList(KEY, BUCKET, CONTENT_TYPE, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, STORAGE_CLASS, REGION, TIMEOUT, EXPIRATION_RULE_ID,
210210
FULL_CONTROL_USER_LIST, READ_USER_LIST, WRITE_USER_LIST, READ_ACL_LIST, WRITE_ACL_LIST, OWNER, CANNED_ACL, SSL_CONTEXT_SERVICE,
211211
ENDPOINT_OVERRIDE, SIGNER_OVERRIDE, MULTIPART_THRESHOLD, MULTIPART_PART_SIZE, MULTIPART_S3_AGEOFF_INTERVAL, MULTIPART_S3_MAX_AGE,
212-
SERVER_SIDE_ENCRYPTION, PROXY_HOST, PROXY_HOST_PORT));
212+
SERVER_SIDE_ENCRYPTION, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD));
213213

214214
final static String S3_BUCKET_KEY = "s3.bucket";
215215
final static String S3_OBJECT_KEY = "s3.key";

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sns/PutSNS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public class PutSNS extends AbstractSNSProcessor {
7777

7878
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
7979
Arrays.asList(ARN, ARN_TYPE, SUBJECT, REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT,
80-
USE_JSON_STRUCTURE, CHARACTER_ENCODING, PROXY_HOST, PROXY_HOST_PORT));
80+
USE_JSON_STRUCTURE, CHARACTER_ENCODING, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD));
8181

8282
public static final int MAX_SIZE = 256 * 1024;
8383

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void testDeleteVersionFromExpressions() {
141141
public void testGetPropertyDescriptors() throws Exception {
142142
DeleteS3Object processor = new DeleteS3Object();
143143
List<PropertyDescriptor> pd = processor.getSupportedPropertyDescriptors();
144-
assertEquals("size should be eq", 20, pd.size());
144+
assertEquals("size should be eq", 22, pd.size());
145145
assertTrue(pd.contains(processor.ACCESS_KEY));
146146
assertTrue(pd.contains(processor.AWS_CREDENTIALS_PROVIDER_SERVICE));
147147
assertTrue(pd.contains(processor.BUCKET));
@@ -160,5 +160,9 @@ public void testGetPropertyDescriptors() throws Exception {
160160
assertTrue(pd.contains(processor.VERSION_ID));
161161
assertTrue(pd.contains(processor.WRITE_ACL_LIST));
162162
assertTrue(pd.contains(processor.WRITE_USER_LIST));
163+
assertTrue(pd.contains(processor.PROXY_HOST));
164+
assertTrue(pd.contains(processor.PROXY_HOST_PORT));
165+
assertTrue(pd.contains(processor.PROXY_USERNAME));
166+
assertTrue(pd.contains(processor.PROXY_PASSWORD));
163167
}
164168
}

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void testGetObjectExceptionGoesToFailure() throws IOException {
178178
public void testGetPropertyDescriptors() throws Exception {
179179
FetchS3Object processor = new FetchS3Object();
180180
List<PropertyDescriptor> pd = processor.getSupportedPropertyDescriptors();
181-
assertEquals("size should be eq", 14, pd.size());
181+
assertEquals("size should be eq", 16, pd.size());
182182
assertTrue(pd.contains(FetchS3Object.ACCESS_KEY));
183183
assertTrue(pd.contains(FetchS3Object.AWS_CREDENTIALS_PROVIDER_SERVICE));
184184
assertTrue(pd.contains(FetchS3Object.BUCKET));
@@ -191,5 +191,10 @@ public void testGetPropertyDescriptors() throws Exception {
191191
assertTrue(pd.contains(FetchS3Object.SSL_CONTEXT_SERVICE));
192192
assertTrue(pd.contains(FetchS3Object.TIMEOUT));
193193
assertTrue(pd.contains(FetchS3Object.VERSION_ID));
194+
assertTrue(pd.contains(FetchS3Object.PROXY_HOST));
195+
assertTrue(pd.contains(FetchS3Object.PROXY_HOST_PORT));
196+
assertTrue(pd.contains(FetchS3Object.PROXY_USERNAME));
197+
assertTrue(pd.contains(FetchS3Object.PROXY_PASSWORD));
198+
194199
}
195200
}

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestListS3.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,5 +311,9 @@ public void testGetPropertyDescriptors() throws Exception {
311311
assertTrue(pd.contains(ListS3.PREFIX));
312312
assertTrue(pd.contains(ListS3.USE_VERSIONS));
313313
assertTrue(pd.contains(ListS3.MIN_AGE));
314+
assertTrue(pd.contains(ListS3.PROXY_HOST));
315+
assertTrue(pd.contains(ListS3.PROXY_HOST_PORT));
316+
assertTrue(pd.contains(ListS3.PROXY_USERNAME));
317+
assertTrue(pd.contains(ListS3.PROXY_PASSWORD));
314318
}
315319
}

0 commit comments

Comments
 (0)