kfaraz commented on code in PR #16182:
URL: https://github.com/apache/druid/pull/16182#discussion_r1535497863
##########
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());
Review Comment:
This check is not needed since `Optional.get() = true` implies that the
object is non null. Static checks also seem to be complaining about the same
thing.
--
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]