Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kfaraz committed Dec 8, 2023
1 parent 5e5a2fc commit 71ae175
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public Response createUser(
authValidator.validateAuthenticatorName(authenticatorName);

final Response response = handler.createUser(authenticatorName, userName);
performAudit(authenticatorName, "basicAuth.createUser", userName, req, response);
performAuditIfSuccess(authenticatorName, "basicAuth.createUser", userName, req, response);

return response;
}
Expand All @@ -186,7 +186,7 @@ public Response deleteUser(
{
authValidator.validateAuthenticatorName(authenticatorName);
final Response response = handler.deleteUser(authenticatorName, userName);
performAudit(authenticatorName, "basicAuth.deleteUser", userName, req, response);
performAuditIfSuccess(authenticatorName, "basicAuth.deleteUser", userName, req, response);

return response;
}
Expand All @@ -213,7 +213,7 @@ public Response updateUserCredentials(
{
authValidator.validateAuthenticatorName(authenticatorName);
final Response response = handler.updateUserCredentials(authenticatorName, userName, update);
performAudit(authenticatorName, "basicAuth.updateUserCreds", userName, req, response);
performAuditIfSuccess(authenticatorName, "basicAuth.updateUserCreds", userName, req, response);

return response;
}
Expand Down Expand Up @@ -265,7 +265,7 @@ private boolean isSuccess(Response response)
return responseCode >= 200 && responseCode < 300;
}

private void performAudit(
private void performAuditIfSuccess(
String authenticatorName,
String action,
String updatedUser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ public static AuditInfo buildAuditInfo(HttpServletRequest request)
);
}

/**
* Builds a RequestInfo object that can be used for auditing purposes.
*/
public static RequestInfo buildRequestInfo(String service, HttpServletRequest request)
{
return new RequestInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public void setUp()
tablesConfig = derbyConnectorRule.metadataTablesConfigSupplier().get();
connector.createAuditTable();
auditManager = new SQLAuditManager(
new SQLAuditManagerConfig(), null, connector,
new SQLAuditManagerConfig(),
null,
connector,
Suppliers.ofInstance(tablesConfig),
new NoopServiceEmitter(),
mapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ public void testSetCompactionTaskLimitWithExistingConfig()

double compactionTaskSlotRatio = 0.5;
int maxCompactionTaskSlots = 9;
String author = "maytas";
String comment = "hello";
Response result = coordinatorCompactionConfigsResource.setCompactionTaskLimit(
compactionTaskSlotRatio,
maxCompactionTaskSlots,
Expand Down Expand Up @@ -193,8 +191,6 @@ public void testAddOrUpdateCompactionConfigWithExistingConfig()
null,
ImmutableMap.of("key", "val")
);
String author = "maytas";
String comment = "hello";
Response result = coordinatorCompactionConfigsResource.addOrUpdateCompactionConfig(
newConfig,
mockHttpServletRequest
Expand Down Expand Up @@ -244,8 +240,6 @@ public void testDeleteCompactionConfigWithExistingConfig()
)
).thenReturn(originalConfig);

String author = "maytas";
String comment = "hello";
Response result = coordinatorCompactionConfigsResource.deleteCompactionConfig(
datasourceName,
mockHttpServletRequest
Expand Down Expand Up @@ -341,8 +335,6 @@ public void testSetCompactionTaskLimitWithoutExistingConfig()

double compactionTaskSlotRatio = 0.5;
int maxCompactionTaskSlots = 9;
String author = "maytas";
String comment = "hello";
Response result = coordinatorCompactionConfigsResource.setCompactionTaskLimit(
compactionTaskSlotRatio,
maxCompactionTaskSlots,
Expand Down Expand Up @@ -427,8 +419,6 @@ public void testDeleteCompactionConfigWithoutExistingConfigShouldFailAsDatasourc
ArgumentMatchers.eq(CoordinatorCompactionConfig.empty())
)
).thenReturn(CoordinatorCompactionConfig.empty());
String author = "maytas";
String comment = "hello";
Response result = coordinatorCompactionConfigsResource.deleteCompactionConfig(
DATASOURCE_NOT_EXISTS,
mockHttpServletRequest
Expand Down
2 changes: 1 addition & 1 deletion web-console/src/dialogs/history-dialog/history-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const HistoryDialog = React.memo(function HistoryDialog(props: HistoryDia

let content: JSX.Element;
if (historyRecords.length === 0) {
content = <div className="no-record">No history records available. Try setting &apos;druid.audit.destiation=sql&apos; to record config changes in metadata store.</div>;
content = <div className="no-record">No history records available</div>;
} else {
content = (
<Tabs animate renderActiveTabPanelOnly vertical defaultSelectedTabId={0}>
Expand Down

0 comments on commit 71ae175

Please sign in to comment.