mirror of https://github.com/apache/nifi.git
NIFI-4154 Fixing line endings in .java,.html files
Signed-off-by: James Wing <jvwing@gmail.com> This closes #1982.
This commit is contained in:
parent
affc88e599
commit
2dc45a4dd7
|
@ -1,30 +1,30 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.util;
|
||||
|
||||
import org.apache.nifi.flowfile.FlowFile;
|
||||
|
||||
public interface FlowFileValidator {
|
||||
|
||||
/**
|
||||
* Define a verification method to validate the given FlowFile
|
||||
*
|
||||
* @param f Flow file
|
||||
*/
|
||||
void assertFlowFile(FlowFile f);
|
||||
|
||||
}
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.util;
|
||||
|
||||
import org.apache.nifi.flowfile.FlowFile;
|
||||
|
||||
public interface FlowFileValidator {
|
||||
|
||||
/**
|
||||
* Define a verification method to validate the given FlowFile
|
||||
*
|
||||
* @param f Flow file
|
||||
*/
|
||||
void assertFlowFile(FlowFile f);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,89 +1,89 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.amqp.processors;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.apache.nifi.authentication.exception.ProviderCreationException;
|
||||
import org.apache.nifi.processor.ProcessContext;
|
||||
import org.apache.nifi.processor.ProcessSession;
|
||||
import org.apache.nifi.processor.exception.ProcessException;
|
||||
import org.apache.nifi.ssl.SSLContextService;
|
||||
import org.apache.nifi.util.TestRunner;
|
||||
import org.apache.nifi.util.TestRunners;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Unit tests for the AbstractAMQPProcessor class
|
||||
*/
|
||||
public class AbstractAMQPProcessorTest {
|
||||
|
||||
MockAbstractAMQPProcessor processor;
|
||||
private TestRunner testRunner;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
processor = new MockAbstractAMQPProcessor();
|
||||
testRunner = TestRunners.newTestRunner(processor);
|
||||
}
|
||||
|
||||
@Test(expected = ProviderCreationException.class)
|
||||
public void testConnectToCassandraWithSSLBadClientAuth() throws Exception {
|
||||
SSLContextService sslService = mock(SSLContextService.class);
|
||||
when(sslService.getIdentifier()).thenReturn("ssl-context");
|
||||
testRunner.addControllerService("ssl-context", sslService);
|
||||
testRunner.enableControllerService(sslService);
|
||||
testRunner.setProperty(AbstractAMQPProcessor.SSL_CONTEXT_SERVICE, "ssl-context");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.USE_CERT_AUTHENTICATION, "false");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.HOST, "test");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.PORT, "9999");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.USER, "test");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.PASSWORD, "test");
|
||||
testRunner.assertValid(sslService);
|
||||
testRunner.setProperty(AbstractAMQPProcessor.CLIENT_AUTH, "BAD");
|
||||
processor.onTrigger(testRunner.getProcessContext(), testRunner.getProcessSessionFactory());
|
||||
}
|
||||
|
||||
@Test(expected = ProviderCreationException.class)
|
||||
public void testInvalidSSLConfiguration() throws Exception {
|
||||
// it's invalid to have use_cert_auth enabled and not have the SSL Context Service configured
|
||||
testRunner.setProperty(AbstractAMQPProcessor.USE_CERT_AUTHENTICATION, "true");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.HOST, "test");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.PORT, "9999");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.USER, "test");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.PASSWORD, "test");
|
||||
processor.onTrigger(testRunner.getProcessContext(), testRunner.getProcessSessionFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a stubbed processor instance for testing
|
||||
*/
|
||||
public static class MockAbstractAMQPProcessor extends AbstractAMQPProcessor<AMQPConsumer> {
|
||||
@Override
|
||||
protected void rendezvousWithAmqp(ProcessContext context, ProcessSession session) throws ProcessException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AMQPConsumer finishBuildingTargetResource(ProcessContext context) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.amqp.processors;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.apache.nifi.authentication.exception.ProviderCreationException;
|
||||
import org.apache.nifi.processor.ProcessContext;
|
||||
import org.apache.nifi.processor.ProcessSession;
|
||||
import org.apache.nifi.processor.exception.ProcessException;
|
||||
import org.apache.nifi.ssl.SSLContextService;
|
||||
import org.apache.nifi.util.TestRunner;
|
||||
import org.apache.nifi.util.TestRunners;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Unit tests for the AbstractAMQPProcessor class
|
||||
*/
|
||||
public class AbstractAMQPProcessorTest {
|
||||
|
||||
MockAbstractAMQPProcessor processor;
|
||||
private TestRunner testRunner;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
processor = new MockAbstractAMQPProcessor();
|
||||
testRunner = TestRunners.newTestRunner(processor);
|
||||
}
|
||||
|
||||
@Test(expected = ProviderCreationException.class)
|
||||
public void testConnectToCassandraWithSSLBadClientAuth() throws Exception {
|
||||
SSLContextService sslService = mock(SSLContextService.class);
|
||||
when(sslService.getIdentifier()).thenReturn("ssl-context");
|
||||
testRunner.addControllerService("ssl-context", sslService);
|
||||
testRunner.enableControllerService(sslService);
|
||||
testRunner.setProperty(AbstractAMQPProcessor.SSL_CONTEXT_SERVICE, "ssl-context");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.USE_CERT_AUTHENTICATION, "false");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.HOST, "test");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.PORT, "9999");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.USER, "test");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.PASSWORD, "test");
|
||||
testRunner.assertValid(sslService);
|
||||
testRunner.setProperty(AbstractAMQPProcessor.CLIENT_AUTH, "BAD");
|
||||
processor.onTrigger(testRunner.getProcessContext(), testRunner.getProcessSessionFactory());
|
||||
}
|
||||
|
||||
@Test(expected = ProviderCreationException.class)
|
||||
public void testInvalidSSLConfiguration() throws Exception {
|
||||
// it's invalid to have use_cert_auth enabled and not have the SSL Context Service configured
|
||||
testRunner.setProperty(AbstractAMQPProcessor.USE_CERT_AUTHENTICATION, "true");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.HOST, "test");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.PORT, "9999");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.USER, "test");
|
||||
testRunner.setProperty(AbstractAMQPProcessor.PASSWORD, "test");
|
||||
processor.onTrigger(testRunner.getProcessContext(), testRunner.getProcessSessionFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a stubbed processor instance for testing
|
||||
*/
|
||||
public static class MockAbstractAMQPProcessor extends AbstractAMQPProcessor<AMQPConsumer> {
|
||||
@Override
|
||||
protected void rendezvousWithAmqp(ProcessContext context, ProcessSession session) throws ProcessException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AMQPConsumer finishBuildingTargetResource(ProcessContext context) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
* ErrorHandler implementation for Logging XML schema validation errors
|
||||
*/
|
||||
public class LoggingXmlParserErrorHandler extends DefaultHandler {
|
||||
|
||||
private final Logger logger;
|
||||
private final String xmlDocTitle;
|
||||
private static final String MESSAGE_FORMAT = "Schema validation %s parsing %s at line %d, col %d: %s";
|
||||
|
||||
public LoggingXmlParserErrorHandler(String xmlDocTitle, Logger logger) {
|
||||
this.logger = logger;
|
||||
this.xmlDocTitle = xmlDocTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(final SAXParseException err) throws SAXParseException {
|
||||
String message = String.format(MESSAGE_FORMAT, "error", xmlDocTitle, err.getLineNumber(),
|
||||
err.getColumnNumber(), err.getMessage());
|
||||
logger.warn(message);
|
||||
}
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
* ErrorHandler implementation for Logging XML schema validation errors
|
||||
*/
|
||||
public class LoggingXmlParserErrorHandler extends DefaultHandler {
|
||||
|
||||
private final Logger logger;
|
||||
private final String xmlDocTitle;
|
||||
private static final String MESSAGE_FORMAT = "Schema validation %s parsing %s at line %d, col %d: %s";
|
||||
|
||||
public LoggingXmlParserErrorHandler(String xmlDocTitle, Logger logger) {
|
||||
this.logger = logger;
|
||||
this.xmlDocTitle = xmlDocTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(final SAXParseException err) throws SAXParseException {
|
||||
String message = String.format(MESSAGE_FORMAT, "error", xmlDocTitle, err.getLineNumber(),
|
||||
err.getColumnNumber(), err.getMessage());
|
||||
logger.warn(message);
|
||||
}
|
||||
}
|
|
@ -1,104 +1,104 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.processors.mongodb;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.any;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.apache.nifi.authentication.exception.ProviderCreationException;
|
||||
import org.apache.nifi.processor.ProcessContext;
|
||||
import org.apache.nifi.processor.ProcessSession;
|
||||
import org.apache.nifi.processor.exception.ProcessException;
|
||||
import org.apache.nifi.ssl.SSLContextService;
|
||||
import org.apache.nifi.ssl.SSLContextService.ClientAuth;
|
||||
import org.apache.nifi.util.TestRunner;
|
||||
import org.apache.nifi.util.TestRunners;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mongodb.MongoClientOptions;
|
||||
import com.mongodb.MongoClientOptions.Builder;
|
||||
|
||||
public class AbstractMongoProcessorTest {
|
||||
|
||||
MockAbstractMongoProcessor processor;
|
||||
private TestRunner testRunner;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
processor = new MockAbstractMongoProcessor();
|
||||
testRunner = TestRunners.newTestRunner(processor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testcreateClientWithSSL() throws Exception {
|
||||
SSLContextService sslService = mock(SSLContextService.class);
|
||||
SSLContext sslContext = mock(SSLContext.class);
|
||||
when(sslService.getIdentifier()).thenReturn("ssl-context");
|
||||
when(sslService.createSSLContext(any(ClientAuth.class))).thenReturn(sslContext);
|
||||
testRunner.addControllerService("ssl-context", sslService);
|
||||
testRunner.enableControllerService(sslService);
|
||||
testRunner.setProperty(AbstractMongoProcessor.URI, "mongodb://localhost:27017");
|
||||
testRunner.setProperty(AbstractMongoProcessor.SSL_CONTEXT_SERVICE, "ssl-context");
|
||||
testRunner.assertValid(sslService);
|
||||
processor.createClient(testRunner.getProcessContext());
|
||||
assertNotNull(processor.mongoClient);
|
||||
processor.mongoClient = null;
|
||||
testRunner.setProperty(AbstractMongoProcessor.CLIENT_AUTH, "WANT");
|
||||
processor.createClient(testRunner.getProcessContext());
|
||||
assertNotNull(processor.mongoClient);
|
||||
}
|
||||
|
||||
@Test(expected = ProviderCreationException.class)
|
||||
public void testcreateClientWithSSLBadClientAuth() throws Exception {
|
||||
SSLContextService sslService = mock(SSLContextService.class);
|
||||
SSLContext sslContext = mock(SSLContext.class);
|
||||
when(sslService.getIdentifier()).thenReturn("ssl-context");
|
||||
when(sslService.createSSLContext(any(ClientAuth.class))).thenReturn(sslContext);
|
||||
testRunner.addControllerService("ssl-context", sslService);
|
||||
testRunner.enableControllerService(sslService);
|
||||
testRunner.setProperty(AbstractMongoProcessor.URI, "mongodb://localhost:27017");
|
||||
testRunner.setProperty(AbstractMongoProcessor.SSL_CONTEXT_SERVICE, "ssl-context");
|
||||
testRunner.assertValid(sslService);
|
||||
processor.createClient(testRunner.getProcessContext());
|
||||
assertNotNull(processor.mongoClient);
|
||||
processor.mongoClient = null;
|
||||
testRunner.setProperty(AbstractMongoProcessor.CLIENT_AUTH, "BAD");
|
||||
processor.createClient(testRunner.getProcessContext());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides a stubbed processor instance for testing
|
||||
*/
|
||||
public static class MockAbstractMongoProcessor extends AbstractMongoProcessor {
|
||||
@Override
|
||||
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder getClientOptions(SSLContext sslContext) {
|
||||
return MongoClientOptions.builder();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.processors.mongodb;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.any;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.apache.nifi.authentication.exception.ProviderCreationException;
|
||||
import org.apache.nifi.processor.ProcessContext;
|
||||
import org.apache.nifi.processor.ProcessSession;
|
||||
import org.apache.nifi.processor.exception.ProcessException;
|
||||
import org.apache.nifi.ssl.SSLContextService;
|
||||
import org.apache.nifi.ssl.SSLContextService.ClientAuth;
|
||||
import org.apache.nifi.util.TestRunner;
|
||||
import org.apache.nifi.util.TestRunners;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mongodb.MongoClientOptions;
|
||||
import com.mongodb.MongoClientOptions.Builder;
|
||||
|
||||
public class AbstractMongoProcessorTest {
|
||||
|
||||
MockAbstractMongoProcessor processor;
|
||||
private TestRunner testRunner;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
processor = new MockAbstractMongoProcessor();
|
||||
testRunner = TestRunners.newTestRunner(processor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testcreateClientWithSSL() throws Exception {
|
||||
SSLContextService sslService = mock(SSLContextService.class);
|
||||
SSLContext sslContext = mock(SSLContext.class);
|
||||
when(sslService.getIdentifier()).thenReturn("ssl-context");
|
||||
when(sslService.createSSLContext(any(ClientAuth.class))).thenReturn(sslContext);
|
||||
testRunner.addControllerService("ssl-context", sslService);
|
||||
testRunner.enableControllerService(sslService);
|
||||
testRunner.setProperty(AbstractMongoProcessor.URI, "mongodb://localhost:27017");
|
||||
testRunner.setProperty(AbstractMongoProcessor.SSL_CONTEXT_SERVICE, "ssl-context");
|
||||
testRunner.assertValid(sslService);
|
||||
processor.createClient(testRunner.getProcessContext());
|
||||
assertNotNull(processor.mongoClient);
|
||||
processor.mongoClient = null;
|
||||
testRunner.setProperty(AbstractMongoProcessor.CLIENT_AUTH, "WANT");
|
||||
processor.createClient(testRunner.getProcessContext());
|
||||
assertNotNull(processor.mongoClient);
|
||||
}
|
||||
|
||||
@Test(expected = ProviderCreationException.class)
|
||||
public void testcreateClientWithSSLBadClientAuth() throws Exception {
|
||||
SSLContextService sslService = mock(SSLContextService.class);
|
||||
SSLContext sslContext = mock(SSLContext.class);
|
||||
when(sslService.getIdentifier()).thenReturn("ssl-context");
|
||||
when(sslService.createSSLContext(any(ClientAuth.class))).thenReturn(sslContext);
|
||||
testRunner.addControllerService("ssl-context", sslService);
|
||||
testRunner.enableControllerService(sslService);
|
||||
testRunner.setProperty(AbstractMongoProcessor.URI, "mongodb://localhost:27017");
|
||||
testRunner.setProperty(AbstractMongoProcessor.SSL_CONTEXT_SERVICE, "ssl-context");
|
||||
testRunner.assertValid(sslService);
|
||||
processor.createClient(testRunner.getProcessContext());
|
||||
assertNotNull(processor.mongoClient);
|
||||
processor.mongoClient = null;
|
||||
testRunner.setProperty(AbstractMongoProcessor.CLIENT_AUTH, "BAD");
|
||||
processor.createClient(testRunner.getProcessContext());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides a stubbed processor instance for testing
|
||||
*/
|
||||
public static class MockAbstractMongoProcessor extends AbstractMongoProcessor {
|
||||
@Override
|
||||
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder getClientOptions(SSLContext sslContext) {
|
||||
return MongoClientOptions.builder();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.processors.standard.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Proxy;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.burgstaller.okhttp.DispatchingAuthenticator;
|
||||
import com.squareup.okhttp.Authenticator;
|
||||
import com.squareup.okhttp.Credentials;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
public class MultiAuthenticator extends DispatchingAuthenticator {
|
||||
|
||||
public MultiAuthenticator(Map<String, Authenticator> registry) {
|
||||
super(registry);
|
||||
}
|
||||
|
||||
private String proxyUsername;
|
||||
private String proxyPassword;
|
||||
|
||||
@Override
|
||||
public Request authenticateProxy(Proxy proxy, Response response) throws IOException {
|
||||
String credential = Credentials.basic(proxyUsername, proxyPassword);
|
||||
return response.request()
|
||||
.newBuilder()
|
||||
.header("Proxy-Authorization", credential)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void setProxyUsername(String proxyUsername) {
|
||||
this.proxyUsername = proxyUsername;
|
||||
}
|
||||
|
||||
public void setProxyPassword(String proxyPassword) {
|
||||
this.proxyPassword = proxyPassword;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
Map<String, Authenticator> registry = new HashMap<>();
|
||||
|
||||
public Builder with(String scheme, Authenticator authenticator) {
|
||||
registry.put(scheme, authenticator);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MultiAuthenticator build() {
|
||||
return new MultiAuthenticator(registry);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.processors.standard.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Proxy;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.burgstaller.okhttp.DispatchingAuthenticator;
|
||||
import com.squareup.okhttp.Authenticator;
|
||||
import com.squareup.okhttp.Credentials;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
public class MultiAuthenticator extends DispatchingAuthenticator {
|
||||
|
||||
public MultiAuthenticator(Map<String, Authenticator> registry) {
|
||||
super(registry);
|
||||
}
|
||||
|
||||
private String proxyUsername;
|
||||
private String proxyPassword;
|
||||
|
||||
@Override
|
||||
public Request authenticateProxy(Proxy proxy, Response response) throws IOException {
|
||||
String credential = Credentials.basic(proxyUsername, proxyPassword);
|
||||
return response.request()
|
||||
.newBuilder()
|
||||
.header("Proxy-Authorization", credential)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void setProxyUsername(String proxyUsername) {
|
||||
this.proxyUsername = proxyUsername;
|
||||
}
|
||||
|
||||
public void setProxyPassword(String proxyPassword) {
|
||||
this.proxyPassword = proxyPassword;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
Map<String, Authenticator> registry = new HashMap<>();
|
||||
|
||||
public Builder with(String scheme, Authenticator authenticator) {
|
||||
registry.put(scheme, authenticator);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MultiAuthenticator build() {
|
||||
return new MultiAuthenticator(registry);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>DebugFlow</title>
|
||||
<link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Processor Documentation ================================================== -->
|
||||
<p>
|
||||
When triggered, the processor loops through the appropriate response list (based on whether or not it
|
||||
received a FlowFile). A response is produced the configured number of times for each pass through its
|
||||
response list, as long as the processor is running.
|
||||
</p><p>
|
||||
Triggered by a FlowFile, the processor can produce the following responses.
|
||||
<ol>
|
||||
<li>transfer FlowFile to success relationship.</li>
|
||||
<li>transfer FlowFile to failure relationship.</li>
|
||||
<li>rollback the FlowFile without penalty.</li>
|
||||
<li>rollback the FlowFile and yield the context.</li>
|
||||
<li>rollback the FlowFile with penalty.</li>
|
||||
<li>throw an exception.</li>
|
||||
</ol>
|
||||
</p><p>
|
||||
Triggered without a FlowFile, the processor can produce the following responses.
|
||||
<ol>
|
||||
<li>do nothing and return.</li>
|
||||
<li>throw an exception.</li>
|
||||
<li>yield the context.</li>
|
||||
</ol>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>DebugFlow</title>
|
||||
<link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Processor Documentation ================================================== -->
|
||||
<p>
|
||||
When triggered, the processor loops through the appropriate response list (based on whether or not it
|
||||
received a FlowFile). A response is produced the configured number of times for each pass through its
|
||||
response list, as long as the processor is running.
|
||||
</p><p>
|
||||
Triggered by a FlowFile, the processor can produce the following responses.
|
||||
<ol>
|
||||
<li>transfer FlowFile to success relationship.</li>
|
||||
<li>transfer FlowFile to failure relationship.</li>
|
||||
<li>rollback the FlowFile without penalty.</li>
|
||||
<li>rollback the FlowFile and yield the context.</li>
|
||||
<li>rollback the FlowFile with penalty.</li>
|
||||
<li>throw an exception.</li>
|
||||
</ol>
|
||||
</p><p>
|
||||
Triggered without a FlowFile, the processor can produce the following responses.
|
||||
<ol>
|
||||
<li>do nothing and return.</li>
|
||||
<li>throw an exception.</li>
|
||||
<li>yield the context.</li>
|
||||
</ol>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>EncryptContent</title>
|
||||
<link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Processor Documentation ================================================== -->
|
||||
<p>
|
||||
<strong>Note:</strong> This processor supports OpenPGP algorithms that are compatible with third party programs.
|
||||
However, it currently cannot add a digital signature to an encrypted FlowFile.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>EncryptContent</title>
|
||||
<link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Processor Documentation ================================================== -->
|
||||
<p>
|
||||
<strong>Note:</strong> This processor supports OpenPGP algorithms that are compatible with third party programs.
|
||||
However, it currently cannot add a digital signature to an encrypted FlowFile.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue