AmatyaAvadhanula commented on code in PR #16182:
URL: https://github.com/apache/druid/pull/16182#discussion_r1536571617


##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/TaskStorageQueryAdapter.java:
##########
@@ -114,7 +114,7 @@ public Optional<Task> getTask(final String taskid)
           return activeTask;
         }
       }
-      catch (JsonProcessingException e) {
+      catch (DruidException e) {

Review Comment:
   Done



##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/TaskQueueTest.java:
##########
@@ -519,6 +550,95 @@ public void testGetTaskStatus()
     Assert.assertEquals(TaskStatus.failure(failedTask, failedTask), 
taskQueue.getTaskStatus(failedTask).get());
   }
 
+  @Test
+  public void testGetActiveTaskRedactsPassword() throws JsonProcessingException
+  {
+    final String password = "AbCd_1234";
+    final ObjectMapper mapper = getObjectMapper();
+
+    final HttpInputSourceConfig httpInputSourceConfig = new 
HttpInputSourceConfig(Collections.singleton("http"));
+    mapper.setInjectableValues(new InjectableValues.Std()
+                                   .addValue(HttpInputSourceConfig.class, 
httpInputSourceConfig)
+                                   .addValue(ObjectMapper.class, new 
DefaultObjectMapper())
+    );
+
+    final SQLMetadataConnector derbyConnector = 
derbyConnectorRule.getConnector();
+    final TaskStorage taskStorage = new MetadataTaskStorage(
+        derbyConnector,
+        new TaskStorageConfig(null),
+        new DerbyMetadataStorageActionHandlerFactory(
+            derbyConnector,
+            derbyConnectorRule.metadataTablesConfigSupplier().get(),
+            mapper
+        )
+    );
+
+    final TaskQueue taskQueue = new TaskQueue(
+        new TaskLockConfig(),
+        new TaskQueueConfig(null, null, null, null, null),
+        new DefaultTaskConfig(),
+        taskStorage,
+        EasyMock.createMock(HttpRemoteTaskRunner.class),
+        createActionClientFactory(),
+        new TaskLockbox(taskStorage, new 
TestIndexerMetadataStorageCoordinator()),
+        new StubServiceEmitter("druid/overlord", "testHost"),
+        mapper
+    );
+
+    final DataSchema dataSchema = new DataSchema(
+        "DS",
+        new TimestampSpec(null, null, null),
+        new DimensionsSpec(null),
+        null,
+        new UniformGranularitySpec(Granularities.YEAR, Granularities.DAY, 
null),
+        null
+    );
+    final ParallelIndexIOConfig ioConfig = new ParallelIndexIOConfig(
+        null,
+        new 
HttpInputSource(Collections.singletonList(URI.create("http://host.org";)),
+                            "user",
+                            new DefaultPasswordProvider(password),
+                            null,
+                            httpInputSourceConfig),
+        new NoopInputFormat(),
+        null,
+        null
+    );
+    final ParallelIndexSupervisorTask taskWithPassword = new 
ParallelIndexSupervisorTask(
+        "taskWithPassword",
+        "taskWithPassword",
+        null,
+        new ParallelIndexIngestionSpec(
+            dataSchema,
+            ioConfig,
+            null
+        ),
+        null,
+        null,
+        false
+    );
+    
Assert.assertTrue(mapper.writeValueAsString(taskWithPassword).contains(password));
+
+    taskQueue.start();
+    taskQueue.add(taskWithPassword);
+
+    final Optional<Task> taskFromTaskStorage = 
taskStorage.getTask(taskWithPassword.getId());
+    Assert.assertTrue(taskFromTaskStorage.isPresent());
+    Assert.assertNotNull(taskFromTaskStorage.get());
+    
Assert.assertFalse(mapper.writeValueAsString(taskFromTaskStorage.get()).contains(password));
+
+
+    final Optional<Task> taskFromTaskQueue = 
taskQueue.getActiveTask(taskWithPassword.getId());
+    Assert.assertTrue(taskFromTaskQueue.isPresent());
+    Assert.assertNotNull(taskFromTaskQueue.get());

Review Comment:
   Done



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to