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

Function with_user

crates/openshell-server/src/grpc/policy.rs:3920–3933  ·  view source on GitHub ↗

Wrap a request with a user `Principal` so handler scope guards treat the test caller as a CLI user. Most handler tests exercise user-facing behavior and should not trip sandbox equality checks.

(mut request: Request<T>)

Source from the content-addressed store, hash-verified

3918 /// the test caller as a CLI user. Most handler tests exercise
3919 /// user-facing behavior and should not trip sandbox equality checks.
3920 fn with_user<T>(mut request: Request<T>) -> Request<T> {
3921 request
3922 .extensions_mut()
3923 .insert(Principal::User(UserPrincipal {
3924 identity: Identity {
3925 subject: "test-user".to_string(),
3926 display_name: None,
3927 roles: vec![],
3928 scopes: vec![],
3929 provider: IdentityProvider::Oidc,
3930 },
3931 }));
3932 request
3933 }
3934
3935 /// Wrap a request with a sandbox `Principal` bound to `sandbox_id`.
3936 /// Use for tests that exercise sandbox-caller code paths.

Calls

no outgoing calls

Tested by

no test coverage detected