File tree Expand file tree Collapse file tree
crates/openshell-server/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const ALLOWED_SANDBOX_METHODS: &[&str] = &[
2121 "/openshell.v1.OpenShell/PushSandboxLogs" ,
2222 "/openshell.v1.OpenShell/SubmitPolicyAnalysis" ,
2323 "/openshell.v1.OpenShell/GetDraftPolicy" ,
24+ "/openshell.inference.v1.Inference/GetInferenceBundle" ,
2425] ;
2526
2627pub fn is_sandbox_callable ( path : & str ) -> bool {
@@ -40,6 +41,9 @@ mod tests {
4041 assert ! ( is_sandbox_callable(
4142 "/openshell.v1.OpenShell/GetSandboxConfig"
4243 ) ) ;
44+ assert ! ( is_sandbox_callable(
45+ "/openshell.inference.v1.Inference/GetInferenceBundle"
46+ ) ) ;
4347 }
4448
4549 #[ test]
@@ -56,5 +60,11 @@ mod tests {
5660 assert ! ( !is_sandbox_callable(
5761 "/openshell.v1.OpenShell/ApproveDraftChunk"
5862 ) ) ;
63+ assert ! ( !is_sandbox_callable(
64+ "/openshell.inference.v1.Inference/GetClusterInference"
65+ ) ) ;
66+ assert ! ( !is_sandbox_callable(
67+ "/openshell.inference.v1.Inference/SetClusterInference"
68+ ) ) ;
5969 }
6070}
Original file line number Diff line number Diff line change @@ -1019,13 +1019,36 @@ mod tests {
10191019 ) ) ;
10201020 }
10211021
1022+ #[ tokio:: test]
1023+ async fn sandbox_principal_can_fetch_inference_bundle ( ) {
1024+ let mock = Arc :: new ( MockAuthenticator :: returning ( Ok ( Some ( sandbox_principal ( ) ) ) ) ) ;
1025+ let chain = AuthenticatorChain :: new ( vec ! [ mock] ) ;
1026+ let ( recorder, seen) = PrincipalRecorder :: new ( ) ;
1027+ let mut router = AuthGrpcRouter :: new ( recorder, Some ( chain) , None ) ;
1028+
1029+ let res = router
1030+ . call ( empty_request (
1031+ "/openshell.inference.v1.Inference/GetInferenceBundle" ,
1032+ ) )
1033+ . await
1034+ . unwrap ( ) ;
1035+
1036+ assert_eq ! ( res. status( ) , 200 ) ;
1037+ assert ! ( matches!(
1038+ seen. lock( ) . unwrap( ) . as_ref( ) ,
1039+ Some ( Principal :: Sandbox ( _) )
1040+ ) ) ;
1041+ }
1042+
10221043 #[ tokio:: test]
10231044 async fn sandbox_principal_is_denied_on_user_and_admin_methods ( ) {
10241045 for path in [
10251046 "/openshell.v1.OpenShell/ListSandboxes" ,
10261047 "/openshell.v1.OpenShell/DeleteSandbox" ,
10271048 "/openshell.v1.OpenShell/CreateProvider" ,
10281049 "/openshell.v1.OpenShell/ApproveDraftChunk" ,
1050+ "/openshell.inference.v1.Inference/GetClusterInference" ,
1051+ "/openshell.inference.v1.Inference/SetClusterInference" ,
10291052 ] {
10301053 let mock = Arc :: new ( MockAuthenticator :: returning ( Ok ( Some ( sandbox_principal ( ) ) ) ) ) ;
10311054 let chain = AuthenticatorChain :: new ( vec ! [ mock] ) ;
You can’t perform that action at this time.
0 commit comments