Skip to content

Commit 9c42800

Browse files
committed
add ability to comment in uncovered endpoints file
1 parent 3c71642 commit 9c42800

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

nexus/tests/integration_tests/audit_log.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ use std::str::FromStr;
3838
type ControlPlaneTestContext =
3939
nexus_test_utils::ControlPlaneTestContext<omicron_nexus::Server>;
4040

41+
/// Strip lines starting with `#` from a snapshot file so that the file
42+
/// can contain human-readable comments explaining why each entry is there.
43+
fn strip_comments(s: &str) -> String {
44+
let mut out: String = s
45+
.lines()
46+
.filter(|line| !line.starts_with('#'))
47+
.collect::<Vec<_>>()
48+
.join("\n");
49+
if s.ends_with('\n') {
50+
out.push('\n');
51+
}
52+
out
53+
}
54+
4155
fn to_q(d: DateTime<Utc>) -> String {
4256
d.to_rfc3339_opts(chrono::SecondsFormat::Micros, true)
4357
}
@@ -711,7 +725,9 @@ async fn test_audit_log_coverage(ctx: &ControlPlaneTestContext) {
711725

712726
// Print a helpful message when there are new uncovered endpoints
713727
let expected_path = "tests/output/uncovered-audit-log-endpoints.txt";
714-
let expected = std::fs::read_to_string(expected_path).unwrap_or_default();
728+
let expected = strip_comments(
729+
&std::fs::read_to_string(expected_path).unwrap_or_default(),
730+
);
715731
let expected_ops: std::collections::HashSet<&str> = expected
716732
.lines()
717733
.skip(1) // skip the header line
@@ -767,8 +783,9 @@ async fn test_audit_log_coverage(ctx: &ControlPlaneTestContext) {
767783
}
768784

769785
let get_expected_path = "tests/output/audited-get-endpoints.txt";
770-
let get_expected =
771-
std::fs::read_to_string(get_expected_path).unwrap_or_default();
786+
let get_expected = strip_comments(
787+
&std::fs::read_to_string(get_expected_path).unwrap_or_default(),
788+
);
772789
let get_expected_ops: std::collections::HashSet<&str> = get_expected
773790
.lines()
774791
.skip(1) // skip the header line

nexus/tests/output/uncovered-audit-log-endpoints.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
Mutating endpoints without audit logging:
2+
# Intermediate steps of the device OAuth flow. The meaningful endpoint is
3+
# device_auth_confirm, which is where authentication and token creation
4+
# happen. device_auth_request has no user identity, and device_access_token
5+
# is just polling (mostly 400s) until the token created by confirm is ready.
26
device_access_token (post "/device/token")
37
device_auth_request (post "/device/auth")
8+
# Called too many times per disk image upload, other related endpoints cover it.
9+
# See https://github.com/oxidecomputer/omicron/pull/10046 for rationale.
410
disk_bulk_write_import (post "/v1/disks/{disk}/bulk-write")
11+
# Needs rework to extract actor identity before we can log it. Low priority
12+
# since sessions expire anyway.
513
logout (post "/v1/logout")
14+
# Read-only queries that happen to use POST for the request body
615
system_timeseries_query (post "/v1/system/timeseries/query")
716
timeseries_query (post "/v1/timeseries/query")
817

0 commit comments

Comments
 (0)