MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / test_http_activity_builder

Function test_http_activity_builder

crates/openshell-ocsf/src/builders/http.rs:123–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121
122 #[test]
123 fn test_http_activity_builder() {
124 let ctx = test_sandbox_context();
125 let event = HttpActivityBuilder::new(&ctx)
126 .activity(ActivityId::Reset) // Get = 3
127 .action(ActionId::Allowed)
128 .disposition(DispositionId::Allowed)
129 .severity(SeverityId::Informational)
130 .http_request(HttpRequest::new(
131 "GET",
132 Url::new("https", "api.example.com", "/v1/data", 443),
133 ))
134 .actor_process(Process::new("curl", 88))
135 .firewall_rule("default-egress", "mechanistic")
136 .build();
137
138 let json = event.to_json().unwrap();
139 assert_eq!(json["class_uid"], 4002);
140 assert_eq!(json["activity_name"], "Get");
141 assert_eq!(json["http_request"]["http_method"], "GET");
142 assert_eq!(json["actor"]["process"]["name"], "curl");
143 }
144
145 #[test]
146 fn test_http_activity_builder_with_status_detail() {

Callers

nothing calls this directly

Calls 4

test_sandbox_contextFunction · 0.85
http_requestMethod · 0.80
to_jsonMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected