Skip to content

Commit a61d550

Browse files
adrwsvc-squareup-copybara
authored andcommitted
Fix Fake audit client, automated change no caller
GitOrigin-RevId: dd074e836e8e487bb4b2441c9570f686e466c2e6
1 parent 80b2694 commit a61d550

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: misk-audit-client/src/test/kotlin/misk/audit/FakeAuditClientTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class FakeAuditClientTest {
3939
eventTarget = "the-database-001",
4040
timestampSent = 2147483647,
4141
applicationName = "test-app",
42-
approverLDAP = "default-user",
42+
approverLDAP = null,
4343
automatedChange = false,
4444
description = "description",
4545
richDescription = null,
@@ -60,7 +60,7 @@ class FakeAuditClientTest {
6060
target = "the-database-001",
6161
)
6262
assertThat(logCollector.takeMessage(FakeAuditClient::class))
63-
.isEqualTo("Audit Event Logged [event=FakeAuditEvent(eventSource=test-app, eventTarget=the-database-001, timestampSent=2147483647, applicationName=test-app, approverLDAP=default-user, automatedChange=false, description=description, richDescription=null, environment=testing, detailURL=null, region=us-west-2, requestorLDAP=default-user)]")
63+
.isEqualTo("Audit Event Logged [event=FakeAuditEvent(eventSource=test-app, eventTarget=the-database-001, timestampSent=2147483647, applicationName=test-app, approverLDAP=null, automatedChange=false, description=description, richDescription=null, environment=testing, detailURL=null, region=us-west-2, requestorLDAP=default-user)]")
6464
}
6565

6666
class TestModule : KAbstractModule() {

Diff for: misk-audit-client/src/testFixtures/kotlin/misk/audit/FakeAuditClient.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ class FakeAuditClient @Inject constructor(
5454
eventTarget = target,
5555
timestampSent = clock.instant().toEpochMilli().nanoseconds.toInt(DurationUnit.NANOSECONDS),
5656
applicationName = applicationName ?: appName,
57-
approverLDAP = approverLDAP ?: callerProvider.get()?.principal,
57+
approverLDAP = approverLDAP,
5858
automatedChange = automatedChange,
5959
description = description,
6060
richDescription = richDescription,
6161
environment = deployment.mapToEnvironmentName(),
6262
detailURL = detailURL,
6363
region = region,
64-
requestorLDAP = requestorLDAP ?: callerProvider.get()?.principal,
64+
requestorLDAP = requestorLDAP ?: if (automatedChange) null else callerProvider.get()?.principal,
6565
)
6666

6767
sentEvents.add(event)

0 commit comments

Comments
 (0)