tpalfy commented on code in PR #6279:
URL: https://github.com/apache/nifi/pull/6279#discussion_r958796980


##########
nifi-nar-bundles/nifi-smb-bundle/nifi-smb-processors/src/test/java/org/apache/nifi/processors/smb/SambaTestContainers.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.smb;
+
+import static java.util.Arrays.fill;
+import static 
org.apache.nifi.processors.smb.ListSmb.SMB_CLIENT_PROVIDER_SERVICE;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.DOMAIN;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.HOSTNAME;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.PASSWORD;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.PORT;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.SHARE;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.USERNAME;
+
+import org.apache.nifi.services.smb.SmbjClientProviderService;
+import org.apache.nifi.util.TestRunner;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.images.builder.Transferable;
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.MountableFile;
+
+public class SambaTestContainers {
+
+    protected final static Integer DEFAULT_SAMBA_PORT = 445;
+    protected final static Logger logger = 
LoggerFactory.getLogger(SambaTestContainers.class);
+    protected final GenericContainer<?> sambaContainer = new 
GenericContainer<>(DockerImageName.parse("dperson/samba"))
+            .withExposedPorts(DEFAULT_SAMBA_PORT, 139)
+            .waitingFor(Wait.forListeningPort())
+            .withLogConsumer(new Slf4jLogConsumer(logger))
+            .withCommand("-w domain -u username;password -s 
share;/folder;;no;no;username;;; -p");
+
+    @BeforeEach
+    public void beforeEach() {
+        sambaContainer.start();
+    }
+
+    @AfterEach
+    public void afterEach() {
+        sambaContainer.stop();
+    }
+
+    protected SmbjClientProviderService 
configureTestRunnerForSambaDockerContainer(TestRunner testRunner)

Review Comment:
   ```suggestion
       protected SmbjClientProviderService configureSmbClient(TestRunner 
testRunner)
   ```



##########
nifi-nar-bundles/nifi-smb-bundle/nifi-smb-processors/src/test/java/org/apache/nifi/processors/smb/ListSmbIT.java:
##########
@@ -202,11 +161,6 @@ public void shouldWriteFlowFileAttributesProperly() throws 
Exception {
                 .map(MockFlowFile::getAttributes)
                 .collect(toSet());
 
-        final Set<String> identifiers = allAttributes.stream()
-                .map(attributes -> attributes.get("identifier"))
-                .collect(toSet());
-        assertEquals(testFiles, identifiers);
-
         allAttributes.forEach(attribute -> assertEquals(
                 Stream.of(attribute.get("path"), 
attribute.get("filename")).filter(s -> !s.isEmpty()).collect(
                         Collectors.joining("/")),

Review Comment:
   `absolute.path` attribute is no longer available. This test currently fails. 
Should remove this assertion.



##########
nifi-nar-bundles/nifi-smb-bundle/nifi-smb-processors/pom.xml:
##########
@@ -79,6 +79,12 @@
             <version>1.18.0-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
+        <dependency>

Review Comment:
   I think we no longer need this dependency.



##########
nifi-nar-bundles/nifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/FetchSmb.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * 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.smb;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.unmodifiableSet;
+import static 
org.apache.nifi.expression.ExpressionLanguageScope.FLOWFILE_ATTRIBUTES;
+import static 
org.apache.nifi.processor.util.StandardValidators.ATTRIBUTE_EXPRESSION_LANGUAGE_VALIDATOR;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.SeeAlso;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyDescriptor.Builder;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.services.smb.SmbClientProviderService;
+import org.apache.nifi.services.smb.SmbClientService;
+import org.apache.nifi.services.smb.SmbException;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"samba, smb, cifs, files", "fetch"})

Review Comment:
   Not sure if this is an error -  searching based on these tags still work on 
UI:
   ```suggestion
   @Tags({"samba", "smb", "cifs", "files", "fetch"})
   ```



##########
nifi-nar-bundles/nifi-smb-bundle/nifi-smb-processors/src/test/java/org/apache/nifi/processors/smb/SambaTestContainers.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.smb;
+
+import static java.util.Arrays.fill;
+import static 
org.apache.nifi.processors.smb.ListSmb.SMB_CLIENT_PROVIDER_SERVICE;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.DOMAIN;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.HOSTNAME;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.PASSWORD;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.PORT;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.SHARE;
+import static org.apache.nifi.services.smb.SmbjClientProviderService.USERNAME;
+
+import org.apache.nifi.services.smb.SmbjClientProviderService;
+import org.apache.nifi.util.TestRunner;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.images.builder.Transferable;
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.MountableFile;
+
+public class SambaTestContainers {
+
+    protected final static Integer DEFAULT_SAMBA_PORT = 445;
+    protected final static Logger logger = 
LoggerFactory.getLogger(SambaTestContainers.class);
+    protected final GenericContainer<?> sambaContainer = new 
GenericContainer<>(DockerImageName.parse("dperson/samba"))
+            .withExposedPorts(DEFAULT_SAMBA_PORT, 139)
+            .waitingFor(Wait.forListeningPort())
+            .withLogConsumer(new Slf4jLogConsumer(logger))
+            .withCommand("-w domain -u username;password -s 
share;/folder;;no;no;username;;; -p");
+
+    @BeforeEach
+    public void beforeEach() {
+        sambaContainer.start();
+    }
+
+    @AfterEach
+    public void afterEach() {
+        sambaContainer.stop();
+    }
+
+    protected SmbjClientProviderService 
configureTestRunnerForSambaDockerContainer(TestRunner testRunner)
+            throws Exception {
+        SmbjClientProviderService smbjClientProviderService = new 
SmbjClientProviderService();
+        testRunner.addControllerService("client-provider", 
smbjClientProviderService);
+        testRunner.setProperty(SMB_CLIENT_PROVIDER_SERVICE, "client-provider");
+        testRunner.setProperty(smbjClientProviderService, HOSTNAME, 
sambaContainer.getHost());
+        testRunner.setProperty(smbjClientProviderService, PORT,
+                
String.valueOf(sambaContainer.getMappedPort(DEFAULT_SAMBA_PORT)));
+        testRunner.setProperty(smbjClientProviderService, USERNAME, 
"username");
+        testRunner.setProperty(smbjClientProviderService, PASSWORD, 
"password");
+        testRunner.setProperty(smbjClientProviderService, SHARE, "share");
+        testRunner.setProperty(smbjClientProviderService, DOMAIN, "domain");
+        return smbjClientProviderService;

Review Comment:
   I think it would make sense to enable the controller service here instead of 
all individual tests.
   ```suggestion
           testRunner.setProperty(smbjClientProviderService, DOMAIN, "domain");
           
           testRunner.enableControllerService(smbjClientProviderService);
           
           return smbjClientProviderService;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to