-
Notifications
You must be signed in to change notification settings - Fork 109
pup: remove stale OAuth-excluded endpoints for fleet, cost/billing, and CCM #762
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
base: main
Are you sure you want to change the base?
Changes from all commits
f8a237e
6456dc4
a3df23e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,12 @@ fn find_endpoint_requirement(method: &str, path: &str) -> Option<&'static Endpoi | |
| /// Endpoints that don't support OAuth. | ||
| /// Trailing "/" means prefix match for ID-parameterized paths. | ||
| static OAUTH_EXCLUDED_ENDPOINTS: &[EndpointRequirement] = &[ | ||
| // Test fixture (1) — not a real API; exists only so tests that need a | ||
| // "still excluded" example don't churn when real endpoints gain OAuth. | ||
| EndpointRequirement { | ||
| path: "/api/v2/test-oauth-excluded/", | ||
| method: "GET", | ||
| }, | ||
| // DDSQL editor tools (3) | ||
| EndpointRequirement { | ||
| path: "/api/unstable/ddsql-editor/tools/ddsql-docs", | ||
|
|
@@ -133,162 +139,6 @@ static OAUTH_EXCLUDED_ENDPOINTS: &[EndpointRequirement] = &[ | |
| path: "/api/unstable/ddsql-editor/tools/table-data", | ||
| method: "POST", | ||
| }, | ||
| // Fleet Automation (15) | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/agents", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/agents/", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/agents/versions", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/deployments", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/deployments/", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/deployments/configure", | ||
| method: "POST", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/deployments/upgrade", | ||
| method: "POST", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/deployments/", | ||
| method: "POST", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/deployments/", | ||
| method: "DELETE", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/schedules", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/schedules/", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/schedules", | ||
| method: "POST", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/schedules/", | ||
| method: "PATCH", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/schedules/", | ||
| method: "DELETE", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/fleet/schedules/", | ||
| method: "POST", | ||
| }, | ||
| // Observability Pipelines (6) — API key only, no OAuth support | ||
| EndpointRequirement { | ||
| path: "/api/v2/obs-pipelines/pipelines", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/obs-pipelines/pipelines", | ||
| method: "POST", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/obs-pipelines/pipelines/", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/obs-pipelines/pipelines/", | ||
| method: "PUT", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/obs-pipelines/pipelines/", | ||
| method: "DELETE", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/obs-pipelines/pipelines/validate", | ||
| method: "POST", | ||
| }, | ||
| // Cost / Billing (11) — API key only, no OAuth support | ||
| EndpointRequirement { | ||
| path: "/api/v2/usage/projected_cost", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/usage/cost_by_org", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost_by_tag/monthly_cost_attribution", | ||
| method: "GET", | ||
| }, | ||
| // Cloud Cost Management config (12) | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/aws_cur_config", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/aws_cur_config", | ||
| method: "POST", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/aws_cur_config/", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/aws_cur_config/", | ||
| method: "DELETE", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/azure_uc_config", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/azure_uc_config", | ||
| method: "POST", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/azure_uc_config/", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/azure_uc_config/", | ||
| method: "DELETE", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/gcp_uc_config", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/gcp_uc_config", | ||
| method: "POST", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/gcp_uc_config/", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/gcp_uc_config/", | ||
| method: "DELETE", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/oci_config", | ||
| method: "GET", | ||
| }, | ||
| EndpointRequirement { | ||
| path: "/api/v2/cost/anomalies", | ||
| method: "GET", | ||
| }, | ||
| // Profiling (4) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The commit removes the Cost/Billing and Cloud Cost Management entries, but the only new no-fallback assertions exercise Fleet; a repo-wide search finds no test proving that representative AGENTS.md reference: AGENTS.md:L21-L22 Useful? React with 👍 / 👎. |
||
| // No OAuth scope is declared for Continuous Profiler endpoints; force API-key auth. | ||
| EndpointRequirement { | ||
|
|
@@ -818,10 +668,11 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_prefix_matching_with_id() { | ||
| // Trailing "/" in the pattern should match paths with IDs | ||
| // Trailing "/" in the pattern should match paths with IDs. | ||
| // Uses the test fixture entry (permanently excluded) as the example. | ||
| assert!(requires_api_key_fallback( | ||
| "GET", | ||
| "/api/v2/fleet/agents/agent-123" | ||
| "/api/v2/test-oauth-excluded/some-id" | ||
| )); | ||
| } | ||
|
|
||
|
|
@@ -834,11 +685,6 @@ mod tests { | |
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_oauth_excluded_count() { | ||
| assert_eq!(OAUTH_EXCLUDED_ENDPOINTS.len(), 46); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_no_fallback_for_notebooks() { | ||
| assert!(!requires_api_key_fallback("GET", "/api/v1/notebooks")); | ||
|
|
@@ -847,12 +693,27 @@ mod tests { | |
| } | ||
|
|
||
| #[test] | ||
| fn test_requires_api_key_fallback_fleet() { | ||
| assert!(requires_api_key_fallback("GET", "/api/v2/fleet/agents")); | ||
| assert!(requires_api_key_fallback( | ||
| fn test_no_fallback_for_fleet() { | ||
| // Fleet Automation v2 routes already accept OAuth server-side; | ||
| // the raw/generic `pup api` passthrough should use the OAuth bearer | ||
| // like the typed fleet commands do. | ||
| assert!(!requires_api_key_fallback("GET", "/api/v2/fleet/agents")); | ||
| assert!(!requires_api_key_fallback( | ||
| "GET", | ||
| "/api/v2/fleet/agents/agent-123" | ||
| )); | ||
| assert!(!requires_api_key_fallback( | ||
| "GET", | ||
| "/api/v2/fleet/deployments" | ||
| )); | ||
| assert!(!requires_api_key_fallback( | ||
| "POST", | ||
| "/api/v2/fleet/deployments/configure" | ||
| )); | ||
| assert!(!requires_api_key_fallback( | ||
| "POST", | ||
| "/api/v2/fleet/schedules/sched-123/trigger" | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -1016,16 +877,15 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_other_oauth_excluded_endpoints_still_require_both_keys() { | ||
| // Uses Fleet Automation as a currently-still-excluded example. This is | ||
| // just today's state of OAUTH_EXCLUDED_ENDPOINTS, not a claim that Fleet | ||
| // (or anything else in the table) is meant to stay that way -- update | ||
| // this example if/when its entries get OAuth support and are removed. | ||
| // Uses the test fixture entry (permanently excluded) so this test | ||
| // doesn't churn when real endpoints gain OAuth support. | ||
| let mut cfg = test_cfg(); | ||
| cfg.app_key = None; | ||
| let req = reqwest::Client::new().get("https://api.datadoghq.com/api/v2/fleet/agents"); | ||
| let req = reqwest::Client::new() | ||
| .get("https://api.datadoghq.com/api/v2/test-oauth-excluded/some-id"); | ||
|
|
||
| let err = match apply_auth(req, &cfg, "GET", "/api/v2/fleet/agents") { | ||
| Ok(_) => panic!("Fleet Automation should require both keys"), | ||
| let err = match apply_auth(req, &cfg, "GET", "/api/v2/test-oauth-excluded/some-id") { | ||
| Ok(_) => panic!("test fixture should require both keys"), | ||
| Err(err) => err, | ||
| }; | ||
| assert!(err.to_string().contains("DD_API_KEY and DD_APP_KEY")); | ||
|
|
||
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.
When an OAuth-authenticated user with API/application keys runs
pup obs-pipelines diff,src/commands/obs_pipelines.rscallsraw_getfor/api/v2/obs-pipelines/pipelines/{id}; removing this endpoint group makesapply_authsend the bearer token instead of the required keys, causing the request to be rejected. The documented rollout covers Fleet, Cost/Billing, and CCM—not Observability Pipelines, whose six entries were explicitly marked API-key-only—so restore those exclusions and their behavioral coverage. This unrelated deletion also exceeds the stated scope of the change.AGENTS.md reference: AGENTS.md:L21-L27
Useful? React with 👍 / 👎.