org.apache.nifi.components.AllowableValue Java Examples

The following examples show how to use org.apache.nifi.components.AllowableValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestPutS3Object.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testSignerOverrideOptions() {
    final AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
    final ClientConfiguration config = new ClientConfiguration();
    final PutS3Object processor = new PutS3Object();
    final TestRunner runner = TestRunners.newTestRunner(processor);

    final List<AllowableValue> allowableSignerValues = PutS3Object.SIGNER_OVERRIDE.getAllowableValues();
    final String defaultSignerValue = PutS3Object.SIGNER_OVERRIDE.getDefaultValue();

    for (AllowableValue allowableSignerValue : allowableSignerValues) {
        String signerType = allowableSignerValue.getValue();
        if (!signerType.equals(defaultSignerValue)) {
            runner.setProperty(PutS3Object.SIGNER_OVERRIDE, signerType);
            ProcessContext context = runner.getProcessContext();
            try {
                processor.createClient(context, credentialsProvider, config);
            } catch (IllegalArgumentException argEx) {
                Assert.fail(argEx.getMessage());
            }
        }
    }
}
 
Example #2
Source File: JsonInferenceSchemaRegistryService.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    final List<PropertyDescriptor> properties = new ArrayList<>(2);

    final AllowableValue[] strategies = new AllowableValue[] {
        SCHEMA_NAME_PROPERTY, SCHEMA_TEXT_PROPERTY, INFER_SCHEMA
    };

    properties.add(buildStrategyProperty(strategies));

    properties.add(SCHEMA_REGISTRY);
    properties.add(SCHEMA_NAME);
    properties.add(SCHEMA_VERSION);
    properties.add(SCHEMA_BRANCH_NAME);
    properties.add(SCHEMA_TEXT);

    return properties;
}
 
Example #3
Source File: TestGetHDFSFileInfo.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void testBatchSize(String batchSize, AllowableValue destination, AllowableValue grouping, int expectedNrTransferredToSuccess) {
    setFileSystemBasicTree(proc.fileSystem);

    runner.setIncomingConnection(false);
    runner.setProperty(GetHDFSFileInfo.FULL_PATH, "/some/home/mydir");
    runner.setProperty(GetHDFSFileInfo.RECURSE_SUBDIRS, "true");
    runner.setProperty(GetHDFSFileInfo.IGNORE_DOTTED_DIRS, "true");
    runner.setProperty(GetHDFSFileInfo.IGNORE_DOTTED_FILES, "true");
    runner.setProperty(GetHDFSFileInfo.DESTINATION, destination);
    runner.setProperty(GetHDFSFileInfo.GROUPING, grouping);
    if (batchSize != null) {
        runner.setProperty(GetHDFSFileInfo.BATCH_SIZE, batchSize);
    }

    runner.run();

    runner.assertTransferCount(GetHDFSFileInfo.REL_ORIGINAL, 0);
    runner.assertTransferCount(GetHDFSFileInfo.REL_SUCCESS, expectedNrTransferredToSuccess);
    runner.assertTransferCount(GetHDFSFileInfo.REL_FAILURE, 0);
    runner.assertTransferCount(GetHDFSFileInfo.REL_NOT_FOUND, 0);
}
 
Example #4
Source File: MongoDBLookupService.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    AllowableValue[] strategies = new AllowableValue[] {
        SCHEMA_NAME_PROPERTY, SCHEMA_TEXT_PROPERTY, INFER_SCHEMA
    };
    List<PropertyDescriptor> _temp = new ArrayList<>();
    _temp.add(new PropertyDescriptor.Builder()
            .fromPropertyDescriptor(SCHEMA_ACCESS_STRATEGY)
            .allowableValues(strategies)
            .defaultValue(getDefaultSchemaAccessStrategy().getValue())
            .build());

    _temp.add(SCHEMA_REGISTRY);
    _temp.add(SCHEMA_NAME);
    _temp.add(SCHEMA_VERSION);
    _temp.add(SCHEMA_BRANCH_NAME);
    _temp.add(SCHEMA_TEXT);
    _temp.add(CONTROLLER_SERVICE);
    _temp.add(DATABASE_NAME);
    _temp.add(COLLECTION_NAME);
    _temp.add(LOOKUP_VALUE_FIELD);
    _temp.add(PROJECTION);

    return Collections.unmodifiableList(_temp);
}
 
Example #5
Source File: SSLContextServiceTest.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testSSLAlgorithms() throws NoSuchAlgorithmException {
    final AllowableValue[] allowableValues = SSLContextService.buildAlgorithmAllowableValues();

    // we expect TLS, SSL, and all available configured JVM protocols
    final Set<String> expected = new HashSet<>();
    expected.add("SSL");
    expected.add("TLS");
    final String[] supportedProtocols = SSLContext.getDefault().createSSLEngine().getSupportedProtocols();
    expected.addAll(Arrays.asList(supportedProtocols));

    assertThat(allowableValues, notNullValue());
    assertThat(allowableValues.length, equalTo(expected.size()));
    for(final AllowableValue value : allowableValues) {
        assertTrue(expected.contains(value.getValue()));
    }
}
 
Example #6
Source File: TestPutS3Object.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testSignerOverrideOptions() {
    final AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
    final ClientConfiguration config = new ClientConfiguration();
    final PutS3Object processor = new PutS3Object();
    final TestRunner runner = TestRunners.newTestRunner(processor);

    final List<AllowableValue> allowableSignerValues = PutS3Object.SIGNER_OVERRIDE.getAllowableValues();
    final String defaultSignerValue = PutS3Object.SIGNER_OVERRIDE.getDefaultValue();

    for (AllowableValue allowableSignerValue : allowableSignerValues) {
        String signerType = allowableSignerValue.getValue();
        if (!signerType.equals(defaultSignerValue)) {
            runner.setProperty(PutS3Object.SIGNER_OVERRIDE, signerType);
            ProcessContext context = runner.getProcessContext();
            try {
                AmazonS3Client s3Client = processor.createClient(context, credentialsProvider, config);
            } catch (IllegalArgumentException argEx) {
                Assert.fail(argEx.getMessage());
            }
        }
    }
}
 
Example #7
Source File: EncryptContent.java    From nifi with Apache License 2.0 6 votes vote down vote up
private static AllowableValue[] buildPGPSymmetricCipherAllowableValues() {
    // Allowed values are inferred from SymmetricKeyAlgorithmTags. Note that NULL and SAFER cipher are not supported and therefore not listed
    return new AllowableValue[] {
            new AllowableValue("1", "IDEA"),
            new AllowableValue("2", "TRIPLE_DES"),
            new AllowableValue("3", "CAST5"),
            new AllowableValue("4", "BLOWFISH"),
            new AllowableValue("6", "DES"),
            new AllowableValue("7", "AES_128"),
            new AllowableValue("8", "AES_192"),
            new AllowableValue("9", "AES_256"),
            new AllowableValue("10", "TWOFISH"),
            new AllowableValue("11", "CAMELLIA_128"),
            new AllowableValue("12", "CAMELLIA_192"),
            new AllowableValue("13", "CAMELLIA_256") };
}
 
Example #8
Source File: SchemaRegistryRecordSetWriter.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    final List<PropertyDescriptor> properties = new ArrayList<>();

    final AllowableValue[] strategies = getSchemaWriteStrategyValues().toArray(new AllowableValue[0]);
    properties.add(new Builder()
        .fromPropertyDescriptor(SCHEMA_WRITE_STRATEGY)
        .defaultValue(getDefaultSchemaWriteStrategy().getValue())
        .allowableValues(strategies)
        .build());
    properties.add(SCHEMA_CACHE);
    properties.add(SCHEMA_PROTOCOL_VERSION);
    properties.addAll(super.getSupportedPropertyDescriptors());

    return properties;
}
 
Example #9
Source File: CSVReader.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected List<AllowableValue> getSchemaAccessStrategyValues() {
    final List<AllowableValue> allowableValues = new ArrayList<>(super.getSchemaAccessStrategyValues());
    allowableValues.add(HEADER_DERIVED);
    allowableValues.add(SchemaInferenceUtil.INFER_SCHEMA);
    return allowableValues;
}
 
Example #10
Source File: SchemaRegistryService.java    From nifi with Apache License 2.0 5 votes vote down vote up
protected PropertyDescriptor buildStrategyProperty(AllowableValue[] values) {
    return new PropertyDescriptor.Builder()
        .fromPropertyDescriptor(SCHEMA_ACCESS_STRATEGY)
        .allowableValues(values)
        .defaultValue(getDefaultSchemaAccessStrategy().getValue())
        .build();
}
 
Example #11
Source File: AbstractPutHDFSRecord.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected final void init(final ProcessorInitializationContext context) {
    super.init(context);

    final Set<Relationship> rels = new HashSet<>();
    rels.add(REL_SUCCESS);
    rels.add(REL_RETRY);
    rels.add(REL_FAILURE);
    this.putHdfsRecordRelationships = Collections.unmodifiableSet(rels);

    final List<PropertyDescriptor> props = new ArrayList<>(properties);
    props.add(RECORD_READER);

    props.add(new PropertyDescriptor.Builder()
            .fromPropertyDescriptor(DIRECTORY)
            .description("The parent directory to which files should be written. Will be created if it doesn't exist.")
            .build());

    final AllowableValue[] compressionTypes = getCompressionTypes(context).toArray(new AllowableValue[0]);

    props.add(new PropertyDescriptor.Builder()
            .fromPropertyDescriptor(COMPRESSION_TYPE)
            .allowableValues(compressionTypes)
            .defaultValue(getDefaultCompressionType(context))
            .build());

    props.add(OVERWRITE);
    props.add(UMASK);
    props.add(REMOTE_GROUP);
    props.add(REMOTE_OWNER);
    props.addAll(getAdditionalProperties());
    this.putHdfsRecordProperties = Collections.unmodifiableList(props);
}
 
Example #12
Source File: RestrictedSSLContextService.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Build a restricted set of allowable TLS protocol algorithms.
 *
 * @return the computed set of allowable values
 */
static AllowableValue[] buildAlgorithmAllowableValues() {
    final Set<String> supportedProtocols = new HashSet<>();

    /*
     * Prepopulate protocols with generic instance types commonly used
     * see: http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SSLContext
     */
    supportedProtocols.add("TLS");

    /*
     * Add specifically supported TLS versions
     */
    supportedProtocols.addAll(Arrays.asList(CertificateUtils.getCurrentSupportedTlsProtocolVersions()));

    final int numProtocols = supportedProtocols.size();

    // Sort for consistent presentation in configuration views
    final List<String> supportedProtocolList = new ArrayList<>(supportedProtocols);
    Collections.sort(supportedProtocolList);

    final List<AllowableValue> protocolAllowableValues = new ArrayList<>();
    for (final String protocol : supportedProtocolList) {
        protocolAllowableValues.add(new AllowableValue(protocol));
    }
    return protocolAllowableValues.toArray(new AllowableValue[numProtocols]);
}
 
Example #13
Source File: SSLContextService.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Build a set of allowable TLS/SSL protocol algorithms based on JVM configuration.
 *
 * @return the computed set of allowable values
 */
static AllowableValue[] buildAlgorithmAllowableValues() {
    final Set<String> supportedProtocols = new HashSet<>();

    /*
     * Prepopulate protocols with generic instance types commonly used
     * see: http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SSLContext
     */
    supportedProtocols.add("TLS");

    // This is still available for outgoing connections to legacy services, but can be disabled with jdk.tls.disabledAlgorithms
    supportedProtocols.add("SSL");

    // Determine those provided by the JVM on the system
    try {
        supportedProtocols.addAll(Arrays.asList(SSLContext.getDefault().createSSLEngine().getSupportedProtocols()));
    } catch (NoSuchAlgorithmException e) {
        // ignored as default is used
    }

    final int numProtocols = supportedProtocols.size();

    // Sort for consistent presentation in configuration views
    final List<String> supportedProtocolList = new ArrayList<>(supportedProtocols);
    Collections.sort(supportedProtocolList);

    final List<AllowableValue> protocolAllowableValues = new ArrayList<>();
    for (final String protocol : supportedProtocolList) {
        protocolAllowableValues.add(new AllowableValue(protocol));
    }
    return protocolAllowableValues.toArray(new AllowableValue[numProtocols]);
}
 
Example #14
Source File: SchemaAccessUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
public static Collection<ValidationResult> validateSchemaAccessStrategy(final ValidationContext validationContext, final String schemaAccessStrategyValue,
                                                                        final List<AllowableValue> schemaAccessStrategyValues) {

    final Collection<ValidationResult> validationResults = new ArrayList<>();

    if (isSchemaRegistryRequired(schemaAccessStrategyValue)) {
        final boolean registrySet = validationContext.getProperty(SCHEMA_REGISTRY).isSet();
        if (!registrySet) {
            final String schemaAccessStrategyName = getSchemaAccessStrategyName(schemaAccessStrategyValue, schemaAccessStrategyValues);

            validationResults.add(new ValidationResult.Builder()
                    .subject("Schema Registry")
                    .explanation("The '" + schemaAccessStrategyName + "' Schema Access Strategy requires that the Schema Registry property be set.")
                    .valid(false)
                    .build());
        }
    }

    // ensure that only branch or version is specified, but not both
    if (SCHEMA_NAME_PROPERTY.getValue().equalsIgnoreCase(schemaAccessStrategyValue)) {
        final boolean branchNameSet = validationContext.getProperty(SCHEMA_BRANCH_NAME).isSet();
        final boolean versionSet = validationContext.getProperty(SCHEMA_VERSION).isSet();

        if (branchNameSet && versionSet) {
            validationResults.add(new ValidationResult.Builder()
                    .subject(SCHEMA_BRANCH_NAME.getDisplayName())
                    .explanation(SCHEMA_BRANCH_NAME.getDisplayName() + " and " + SCHEMA_VERSION.getDisplayName() + " cannot be specified together")
                    .valid(false)
                    .build());
        }
    }

    return validationResults;
}
 
Example #15
Source File: GrokReader.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected List<AllowableValue> getSchemaAccessStrategyValues() {
    final List<AllowableValue> allowableValues = new ArrayList<>();
    allowableValues.add(STRING_FIELDS_FROM_GROK_EXPRESSION);
    allowableValues.addAll(super.getSchemaAccessStrategyValues());
    return allowableValues;
}
 
Example #16
Source File: AvroRecordSetWriter.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected List<AllowableValue> getSchemaWriteStrategyValues() {
    final List<AllowableValue> allowableValues = new ArrayList<>();
    allowableValues.add(AVRO_EMBEDDED);
    allowableValues.addAll(super.getSchemaWriteStrategyValues());
    return allowableValues;
}
 
Example #17
Source File: EncryptContent.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private static AllowableValue[] buildWeakCryptoAllowableValues() {
    List<AllowableValue> allowableValues = new ArrayList<>();
    allowableValues.add(new AllowableValue(WEAK_CRYPTO_ALLOWED_NAME, "Allowed", "Operation will not be blocked and no alerts will be presented " +
            "when unsafe combinations of encryption algorithms and passwords are provided"));
    allowableValues.add(buildDefaultWeakCryptoAllowableValue());
    return allowableValues.toArray(new AllowableValue[0]);
}
 
Example #18
Source File: HtmlDocumentationWriter.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Interrogates a PropertyDescriptor to get a list of AllowableValues, if
 * there are none, nothing is written to the stream.
 *
 * @param xmlStreamWriter the stream writer to use
 * @param property the property to describe
 * @throws XMLStreamException thrown if there was a problem writing to the
 * XML Stream
 */
protected void writeValidValues(XMLStreamWriter xmlStreamWriter, PropertyDescriptor property)
        throws XMLStreamException {
    if (property.getAllowableValues() != null && property.getAllowableValues().size() > 0) {
        xmlStreamWriter.writeStartElement("ul");
        for (AllowableValue value : property.getAllowableValues()) {
            xmlStreamWriter.writeStartElement("li");
            xmlStreamWriter.writeCharacters(value.getDisplayName());

            if (value.getDescription() != null) {
                writeValidValueDescription(xmlStreamWriter, value.getDescription());
            }
            xmlStreamWriter.writeEndElement();

        }
        xmlStreamWriter.writeEndElement();
    } else if (property.getControllerServiceDefinition() != null) {
        Class<? extends ControllerService> controllerServiceClass = property.getControllerServiceDefinition();

        writeSimpleElement(xmlStreamWriter, "strong", "Controller Service API: ");
        xmlStreamWriter.writeEmptyElement("br");
        xmlStreamWriter.writeCharacters(controllerServiceClass.getSimpleName());

        final List<Class<? extends ControllerService>> implementations = lookupControllerServiceImpls(controllerServiceClass);
        xmlStreamWriter.writeEmptyElement("br");
        if (implementations.size() > 0) {
            final String title = implementations.size() > 1 ? "Implementations: " : "Implementation:";
            writeSimpleElement(xmlStreamWriter, "strong", title);
            for (int i = 0; i < implementations.size(); i++) {
                xmlStreamWriter.writeEmptyElement("br");
                writeLinkForComponent(xmlStreamWriter, implementations.get(i));
            }
        } else {
            xmlStreamWriter.writeCharacters("No implementations found.");
        }
    }
}
 
Example #19
Source File: SchemaRegistryService.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    final List<PropertyDescriptor> properties = new ArrayList<>(2);

    final AllowableValue[] strategies = getSchemaAccessStrategyValues().toArray(new AllowableValue[0]);
    properties.add(buildStrategyProperty(strategies));

    properties.add(SCHEMA_REGISTRY);
    properties.add(SCHEMA_NAME);
    properties.add(SCHEMA_VERSION);
    properties.add(SCHEMA_BRANCH_NAME);
    properties.add(SCHEMA_TEXT);

    return properties;
}
 
Example #20
Source File: HtmlDocumentationWriter.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Interrogates a PropertyDescriptor to get a list of AllowableValues, if
 * there are none, nothing is written to the stream.
 *
 * @param xmlStreamWriter the stream writer to use
 * @param property the property to describe
 * @throws XMLStreamException thrown if there was a problem writing to the
 * XML Stream
 */
protected void writeValidValues(XMLStreamWriter xmlStreamWriter, PropertyDescriptor property)
        throws XMLStreamException {
    if (property.getAllowableValues() != null && property.getAllowableValues().size() > 0) {
        xmlStreamWriter.writeStartElement("ul");
        for (AllowableValue value : property.getAllowableValues()) {
            xmlStreamWriter.writeStartElement("li");
            xmlStreamWriter.writeCharacters(value.getDisplayName());

            if (value.getDescription() != null) {
                writeValidValueDescription(xmlStreamWriter, value.getDescription());
            }
            xmlStreamWriter.writeEndElement();

        }
        xmlStreamWriter.writeEndElement();
    } else if (property.getControllerServiceDefinition() != null) {
        Class<? extends ControllerService> controllerServiceClass = property.getControllerServiceDefinition();

        writeSimpleElement(xmlStreamWriter, "strong", "Controller Service API: ");
        xmlStreamWriter.writeEmptyElement("br");
        xmlStreamWriter.writeCharacters(controllerServiceClass.getSimpleName());

        final List<Class<? extends ControllerService>> implementationList = lookupControllerServiceImpls(controllerServiceClass);

        // Convert it into an array before proceeding
        Class<? extends ControllerService>[] implementations = implementationList.stream().toArray(Class[]::new);

        xmlStreamWriter.writeEmptyElement("br");
        if (implementations.length > 0) {
            final String title = implementations.length > 1 ? "Implementations: " : "Implementation: ";
            writeSimpleElement(xmlStreamWriter, "strong", title);
            iterateAndLinkComponents(xmlStreamWriter, implementations, null, "<br>", controllerServiceClass.getSimpleName());
        } else {
            xmlStreamWriter.writeCharacters("No implementations found.");
        }
    }
}
 
Example #21
Source File: SchemaAccessUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
private static String getSchemaAccessStrategyName(final String schemaAccessValue, final List<AllowableValue> schemaAccessStrategyValues) {
    for (final AllowableValue allowableValue : schemaAccessStrategyValues) {
        if (allowableValue.getValue().equalsIgnoreCase(schemaAccessValue)) {
            return allowableValue.getDisplayName();
        }
    }

    return null;
}
 
Example #22
Source File: ParquetUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
private static List<AllowableValue> getCompressionTypes() {
    final List<AllowableValue> compressionTypes = new ArrayList<>();
    for (CompressionCodecName compressionCodecName : CompressionCodecName.values()) {
        final String name = compressionCodecName.name();
        compressionTypes.add(new AllowableValue(name, name));
    }
    return  Collections.unmodifiableList(compressionTypes);
}
 
Example #23
Source File: EncryptContent.java    From nifi with Apache License 2.0 5 votes vote down vote up
private static AllowableValue[] buildKeyDerivationFunctionAllowableValues() {
    final KeyDerivationFunction[] keyDerivationFunctions = KeyDerivationFunction.values();
    List<AllowableValue> allowableValues = new ArrayList<>(keyDerivationFunctions.length);
    for (KeyDerivationFunction kdf : keyDerivationFunctions) {
        allowableValues.add(new AllowableValue(kdf.name(), kdf.getName(), kdf.getDescription()));
    }

    return allowableValues.toArray(new AllowableValue[0]);
}
 
Example #24
Source File: EncryptContent.java    From nifi with Apache License 2.0 5 votes vote down vote up
private static AllowableValue[] buildEncryptionMethodAllowableValues() {
    final EncryptionMethod[] encryptionMethods = EncryptionMethod.values();
    List<AllowableValue> allowableValues = new ArrayList<>(encryptionMethods.length);
    for (EncryptionMethod em : encryptionMethods) {
        allowableValues.add(new AllowableValue(em.name(), em.name(), em.toString()));
    }

    return allowableValues.toArray(new AllowableValue[0]);
}
 
Example #25
Source File: AbstractAWSProcessor.java    From nifi with Apache License 2.0 5 votes vote down vote up
public static AllowableValue[] getAvailableRegions() {
    final List<AllowableValue> values = new ArrayList<>();
    for (final Regions region : Regions.values()) {
        values.add(createAllowableValue(region));
    }
    return values.toArray(new AllowableValue[values.size()]);
}
 
Example #26
Source File: TestEncryptContent.java    From nifi with Apache License 2.0 5 votes vote down vote up
private static AllowableValue[] getPGPCipherList() {
    try{
        Method method = EncryptContent.class.getDeclaredMethod("buildPGPSymmetricCipherAllowableValues");
        method.setAccessible(true);
        return ((AllowableValue[]) method.invoke(null));
    } catch (Exception e){
        logger.error("Cannot access buildPGPSymmetricCipherAllowableValues", e);
        fail("Cannot access buildPGPSymmetricCipherAllowableValues");
    }
    return null;
}
 
Example #27
Source File: TestEncryptContent.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testPGPCiphersRoundTrip() {
    final TestRunner testRunner = TestRunners.newTestRunner(new EncryptContent());
    testRunner.setProperty(EncryptContent.PASSWORD, "passwordpassword"); // a >=16 characters password
    testRunner.setProperty(EncryptContent.KEY_DERIVATION_FUNCTION, KeyDerivationFunction.NONE.name());

    List<String> pgpAlgorithms = new ArrayList<>();
    pgpAlgorithms.add("PGP");
    pgpAlgorithms.add("PGP_ASCII_ARMOR");

    for (String algorithm : pgpAlgorithms) {
        testRunner.setProperty(EncryptContent.ENCRYPTION_ALGORITHM, algorithm);
        for (AllowableValue cipher : Objects.requireNonNull(getPGPCipherList())) {
            testRunner.setProperty(EncryptContent.PGP_SYMMETRIC_ENCRYPTION_CIPHER, cipher.getValue());
            testRunner.setProperty(EncryptContent.MODE, EncryptContent.ENCRYPT_MODE);

            testRunner.enqueue("A cool plaintext!");
            testRunner.clearTransferState();
            testRunner.run();

            testRunner.assertAllFlowFilesTransferred(EncryptContent.REL_SUCCESS, 1);

            MockFlowFile flowFile = testRunner.getFlowFilesForRelationship(EncryptContent.REL_SUCCESS).get(0);
            testRunner.assertQueueEmpty();

            testRunner.setProperty(EncryptContent.MODE, EncryptContent.DECRYPT_MODE);
            // Encryption cipher is inferred from ciphertext, this property deliberately set a fixed cipher to prove
            // the output will still be correct
            testRunner.setProperty(EncryptContent.PGP_SYMMETRIC_ENCRYPTION_CIPHER, "1");

            testRunner.enqueue(flowFile);
            testRunner.clearTransferState();
            testRunner.run();
            testRunner.assertAllFlowFilesTransferred(EncryptContent.REL_SUCCESS, 1);

            flowFile = testRunner.getFlowFilesForRelationship(EncryptContent.REL_SUCCESS).get(0);
            flowFile.assertContentEquals("A cool plaintext!");
        }
    }
}
 
Example #28
Source File: TestCreateHadoopSequenceFile.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void validateAllowableValuesForCompressionType() {
    PropertyDescriptor pd = CreateHadoopSequenceFile.COMPRESSION_TYPE;
    List<AllowableValue> allowableValues = pd.getAllowableValues();
    assertEquals("NONE", allowableValues.get(0).getValue());
    assertEquals("RECORD", allowableValues.get(1).getValue());
    assertEquals("BLOCK", allowableValues.get(2).getValue());
}
 
Example #29
Source File: PutGridFSIT.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void testHashUniqueness(AllowableValue value) {
    String hashAttr = "hash.value";
    String fileName = "test_duplicates.txt";
    String content  = "Hello, world";
    String hash     = DigestUtils.md5Hex(content);
    Map<String, String> attrs = new HashMap<>();
    attrs.put(CoreAttributes.FILENAME.key(), fileName);
    attrs.put(hashAttr, hash);
    testUniqueness(attrs, content, value);
}
 
Example #30
Source File: PutGridFSIT.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void testUniqueness(Map<String, String> attrs, String content, AllowableValue param) {
    runner.setProperty(PutGridFS.ENFORCE_UNIQUENESS, param);
    for (int x = 0; x < 5; x++) {
        runner.enqueue(content, attrs);
        runner.run();
    }

    runner.assertTransferCount(PutGridFS.REL_FAILURE, 0);
    runner.assertTransferCount(PutGridFS.REL_DUPLICATE, 4);
    runner.assertTransferCount(PutGridFS.REL_SUCCESS, 1);
}