Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,6 @@ protected Collection<ValidationResult> customValidate(final ValidationContext va
.explanation("Cannot set Parse Messages to 'true' if Batch Size is greater than 1").build());
}

final String protocol = validationContext.getProperty(PROTOCOL).getValue();
final SSLContextService sslContextService = validationContext.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);

if (UDP_VALUE.getValue().equals(protocol) && sslContextService != null) {
results.add(new ValidationResult.Builder()
.explanation("SSL can not be used with UDP")
.valid(false).subject("SSL Context").build());
}

return results;
}

Expand Down Expand Up @@ -305,7 +296,7 @@ public void onScheduled(final ProcessContext context) throws IOException {
factory.setSocketKeepAlive(socketKeepAlive);

final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
if (sslContextService != null) {
if (protocol == TransportProtocol.TCP && sslContextService != null) {
final SSLContext sslContext = sslContextService.createContext();
ClientAuth clientAuth = ClientAuth.REQUIRED;
final PropertyValue clientAuthProperty = context.getProperty(CLIENT_AUTH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.apache.nifi.provenance.ProvenanceEventRecord;
import org.apache.nifi.provenance.ProvenanceEventType;
import org.apache.nifi.remote.io.socket.NetworkUtils;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.ssl.RestrictedSSLContextService;
import org.apache.nifi.syslog.attributes.SyslogAttributes;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
Expand All @@ -42,8 +40,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class TestListenSyslog {
private static final String PRIORITY = "34";
Expand Down Expand Up @@ -77,17 +73,9 @@ public void closeEventSender() {
}

@Test
public void testUdpSslContextServiceInvalid() throws InitializationException {
runner.setProperty(ListenSyslog.PROTOCOL, TransportProtocol.UDP.toString());
final int port = NetworkUtils.getAvailableUdpPort();
runner.setProperty(ListenSyslog.PORT, Integer.toString(port));

final RestrictedSSLContextService sslContextService = mock(RestrictedSSLContextService.class);
final String identifier = RestrictedSSLContextService.class.getName();
when(sslContextService.getIdentifier()).thenReturn(identifier);
runner.addControllerService(identifier, sslContextService);
runner.enableControllerService(sslContextService);
runner.setProperty(ListenSyslog.SSL_CONTEXT_SERVICE, identifier);
public void testInvalidListenSyslog() {
runner.setProperty(ListenSyslog.MAX_BATCH_SIZE, "2");
runner.setProperty(ListenSyslog.PARSE_MESSAGES, "true");

runner.assertNotValid();
}
Expand Down