You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/04/27 08:33:32 UTC

[GitHub] [nifi] karthik-kadajji commented on a change in pull request #4231: NIFI-7037 Split off username and password fields for GetMongo processor

karthik-kadajji commented on a change in pull request #4231:
URL: https://github.com/apache/nifi/pull/4231#discussion_r415618114



##########
File path: nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/test/java/org/apache/nifi/processors/mongodb/GetMongoIT.java
##########
@@ -668,4 +671,53 @@ public void testSendEmpty() throws Exception {
         MockFlowFile flowFile = flowFiles.get(0);
         Assert.assertEquals(0, flowFile.getSize());
     }
+
+
+    @Test
+    public void testReadUserPaswd() throws Exception {
+        final String username = "myuser";
+        final String password = "password";
+        mongoClient = new MongoClient(new MongoClientURI(MONGO_URI));
+        final MongoDatabase db = mongoClient.getDatabase(DB_NAME);
+        final BasicDBObject createUserCommand = new BasicDBObject("createUser", username).append("pwd", password).append("roles",
+                java.util.Collections.singletonList(new BasicDBObject("role", "dbOwner").append("db", DB_NAME)));
+
+        BasicDBObject getUsersInfoCommand = new BasicDBObject("usersInfo", new BasicDBObject("user", username).append("db", DB_NAME));
+        Document result = db.runCommand(getUsersInfoCommand);
+        BasicDBObject dropUserCommand = new BasicDBObject("dropUser", username);
+
+        ArrayList users = (ArrayList) result.get("users");
+        if (!users.isEmpty()) {
+            db.runCommand(dropUserCommand);
+            System.out.println("dropping user");
+        }
+        db.runCommand(createUserCommand);
+
+        //setting new property
+        runner.removeProperty(AbstractMongoProcessor.URI);
+        runner.setVariable("uri", "mongodb://localhost:27017/?authSource="+DB_NAME);
+        runner.setProperty(AbstractMongoProcessor.URI, "${uri}");
+        runner.setProperty(GetMongo.PASSWORD,password);

Review comment:
       I added the spacing . Thank you 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org