@@ -119,6 +119,80 @@ fn unsupported_policy_returns_reason_and_three() {
119119 assert ! ( value[ "reason" ] . is_string( ) ) ;
120120}
121121
122+ #[ test]
123+ fn unsupported_network_surfaces_fail_closed_at_the_cli_boundary ( ) {
124+ let cases = [
125+ (
126+ "l4" ,
127+ " path: /v1\n " ,
128+ "mixes REST controls into L4 authority" ,
129+ ) ,
130+ (
131+ "rest" ,
132+ " protocol: rest\n enforcement: log\n access: full\n " ,
133+ "uses REST without enforced inspection" ,
134+ ) ,
135+ (
136+ "graphql" ,
137+ " protocol: rest\n enforcement: enforce\n access: full\n persisted_queries: allow-list\n " ,
138+ "uses authority outside the initial model" ,
139+ ) ,
140+ (
141+ "json-rpc" ,
142+ " protocol: rest\n enforcement: enforce\n access: full\n json_rpc: {}\n " ,
143+ "uses authority outside the initial model" ,
144+ ) ,
145+ (
146+ "mcp" ,
147+ " protocol: rest\n enforcement: enforce\n access: full\n mcp: {}\n " ,
148+ "uses authority outside the initial model" ,
149+ ) ,
150+ ] ;
151+
152+ for ( surface, endpoint_fields, expected_reason) in cases {
153+ let path = std:: env:: temp_dir ( ) . join ( format ! (
154+ "openshell-prover-unsupported-{surface}-{}.yaml" ,
155+ std:: process:: id( )
156+ ) ) ;
157+ fs:: write (
158+ & path,
159+ format ! (
160+ "version: 1\n network_policies:\n n:\n endpoints:\n - host: api.example.com\n port: 443\n {endpoint_fields} binaries: [{{ path: /usr/bin/curl }}]\n "
161+ ) ,
162+ )
163+ . expect ( "write unsupported surface policy" ) ;
164+
165+ let output = run ( & [
166+ "check" ,
167+ path. to_str ( ) . expect ( "UTF-8 temporary path" ) ,
168+ "--boundary" ,
169+ fixture ( "boundary-empty.yaml" ) . to_str ( ) . unwrap ( ) ,
170+ "--output" ,
171+ "json" ,
172+ ] ) ;
173+ fs:: remove_file ( path) . expect ( "remove unsupported surface policy" ) ;
174+
175+ assert_eq ! (
176+ output. status. code( ) ,
177+ Some ( 3 ) ,
178+ "{surface} stderr: {}" ,
179+ String :: from_utf8_lossy( & output. stderr)
180+ ) ;
181+ let value: Value = serde_json:: from_slice ( & output. stdout ) . expect ( "single JSON object" ) ;
182+ assert_eq ! ( value[ "result" ] , "unsupported" , "{surface}: {value}" ) ;
183+ assert_eq ! (
184+ value[ "reason_code" ] , "unsupported_policy_shape" ,
185+ "{surface}: {value}"
186+ ) ;
187+ assert ! (
188+ value[ "reason" ]
189+ . as_str( )
190+ . is_some_and( |reason| reason. contains( expected_reason) ) ,
191+ "{surface}: {value}"
192+ ) ;
193+ }
194+ }
195+
122196#[ test]
123197fn underscore_host_exceeds_an_empty_boundary ( ) {
124198 let output = check_json ( "candidate-underscore-host.yaml" , "boundary-empty.yaml" ) ;
0 commit comments