New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hard delete auditing #24172
Hard delete auditing #24172
Conversation
69e108c
to
541ac62
Compare
deleted_after: 4.days.ago, | ||
deleted_before: 2.days.ago | ||
ExpiredDeletedAccountPurger.any_instance.stubs(:upload_activity_log).at_least(0) | ||
PurgedAccountLog.any_instance.stubs(:upload).at_least(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need the at_least(0)
part with stubs
, only with expects
.
From http://gofreerange.com/mocha/docs/#Expectation_matching___invocation_order
Stubs and expectations are basically the same thing. A stub is just an expectation of zero or more invocations. The Expectation#stubs method is syntactic sugar to make the intent of the test more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, awesome! Thank you for citing the docs - I've always had a hard time finding things in mocha docs, and looking for features that aren't there like sinon's callsFake
. I guess I should read this main page in more detail!
@@ -186,6 +204,16 @@ def setup | |||
assert_includes purged, student_b | |||
assert_includes purged, student_c | |||
refute_includes purged, student_d | |||
|
|||
assert_equal <<~LOG, edap.log.string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat! I didn't realize heredocs start their content on the next line. TIL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's this weird shorthand that actually reads pretty nice.
541ac62
to
4cf967d
Compare
Adds two types of log output to the hard-delete cronjob. See the "Auditing" section of the Hard-deleting accounts tech spec.
We're uploading to the
cdo-audit-logs
bucket which is versioned to make it harder to accidentally delete/overwrite anything.Purged account logs
cdo-audit-logs/purged-users/<environment>/YYYY-MM-DD/<user-id>
Goals:
We upload one of these logs for every account we purge. These are created and uploaded even when an engineer calls the
AccountPurger
directly, so we have records of manually-performed account purges too. The logs are a JSON blob, formatted something like this:ExpiredDeletedAccountPurger activity logs
cdo-audit-logs/expired-deleted-account-purger-activity/<environment>/YYYYMMDDTHHMMSS-0700
Goals:
We upload one of these each time the task runs (normally, nightly).
Eventually this should contain more detail generated by
AccountPurger
while it's purging the account.