@@ -1310,27 +1310,35 @@ async fn native_wasm_cache_policy_example_matches_documented_behavior() {
13101310 ( "/static/example.png" , "mobile-body" ) ,
13111311 ( "/static/example.png" , "desktop-body" ) ,
13121312 ( "/static/example.png" , "mobile-refill" ) ,
1313+ ( "/static/example.png" , "mobile-after-tag-purge" ) ,
13131314 ] )
13141315 . await ;
13151316 let mut config = fixture. config_with_attachments (
13161317 upstream,
13171318 vec ! [
13181319 wasm_attachment_phase(
13191320 "cache_lookup" ,
1320- "route " ,
1321+ "vcl-static " ,
13211322 100 ,
13221323 fluxheim_config:: WasmPluginPhase :: CacheLookup ,
13231324 ) ,
13241325 wasm_attachment_phase(
13251326 "cache_store" ,
1326- "route " ,
1327+ "vcl-static " ,
13271328 100 ,
13281329 fluxheim_config:: WasmPluginPhase :: CacheStore ,
13291330 ) ,
13301331 ] ,
13311332 ) ;
13321333 config. vhosts [ 0 ] . routes [ 0 ] . path_exact = None ;
13331334 config. vhosts [ 0 ] . routes [ 0 ] . path_prefix = Some ( "/" . to_owned ( ) ) ;
1335+ config. vhosts [ 0 ] . name = "vcl.test" . to_owned ( ) ;
1336+ config. vhosts [ 0 ] . hosts = vec ! [ "vcl.test" . to_owned( ) ] ;
1337+ config. vhosts [ 0 ] . routes [ 0 ] . name = "vcl-static" . to_owned ( ) ;
1338+ config. server . default_vhost = Some ( "vcl.test" . to_owned ( ) ) ;
1339+ for attachment in & mut config. wasm . attachments {
1340+ attachment. vhost = "vcl.test" . to_owned ( ) ;
1341+ }
13341342 config. vhosts [ 0 ] . routes [ 0 ] . redirect = None ;
13351343 config. vhosts [ 0 ] . routes [ 0 ] . proxy = Some ( fluxheim_config:: ProxyConfig {
13361344 upstreams : vec ! [ upstream. to_string( ) ] ,
@@ -1343,23 +1351,23 @@ async fn native_wasm_cache_policy_example_matches_documented_behavior() {
13431351
13441352 let mobile = downstream_request (
13451353 proxy,
1346- "GET /static/example.png HTTP/1.1\r \n Host: route .test\r \n X-Device-Class: mobile\r \n Connection: close\r \n \r \n " ,
1354+ "GET /static/example.png HTTP/1.1\r \n Host: vcl .test\r \n X-Device-Class: mobile\r \n Connection: close\r \n \r \n " ,
13471355 )
13481356 . await ;
13491357 let desktop = downstream_request (
13501358 proxy,
1351- "GET /static/example.png HTTP/1.1\r \n Host: route .test\r \n X-Device-Class: desktop\r \n Connection: close\r \n \r \n " ,
1359+ "GET /static/example.png HTTP/1.1\r \n Host: vcl .test\r \n X-Device-Class: desktop\r \n Connection: close\r \n \r \n " ,
13521360 )
13531361 . await ;
13541362 let mobile_hit = downstream_request (
13551363 proxy,
1356- "GET /static/example.png HTTP/1.1\r \n Host: route .test\r \n X-Device-Class: mobile\r \n Connection: close\r \n \r \n " ,
1364+ "GET /static/example.png HTTP/1.1\r \n Host: vcl .test\r \n X-Device-Class: mobile\r \n Connection: close\r \n \r \n " ,
13571365 )
13581366 . await ;
13591367 tokio:: time:: sleep ( Duration :: from_millis ( 1200 ) ) . await ;
13601368 let mobile_expired = downstream_request (
13611369 proxy,
1362- "GET /static/example.png HTTP/1.1\r \n Host: route .test\r \n X-Device-Class: mobile\r \n Connection: close\r \n \r \n " ,
1370+ "GET /static/example.png HTTP/1.1\r \n Host: vcl .test\r \n X-Device-Class: mobile\r \n Connection: close\r \n \r \n " ,
13631371 )
13641372 . await ;
13651373
@@ -1407,6 +1415,27 @@ async fn native_wasm_cache_policy_example_matches_documented_behavior() {
14071415 response_header( & mobile_expired, "x-cache-status" ) . as_deref( ) ,
14081416 Some ( "MISS" )
14091417 ) ;
1418+
1419+ let purged = crate :: purge_native_memory_cache_tag (
1420+ "vcl.test" ,
1421+ Some ( "vcl-static" ) ,
1422+ "vcl.test:route:vcl-static" ,
1423+ "wasm-policy" ,
1424+ 16 ,
1425+ false ,
1426+ ) ;
1427+ assert_eq ! ( purged. matched, 2 ) ;
1428+ assert_eq ! ( purged. purged, 2 ) ;
1429+ let after_purge = downstream_request (
1430+ proxy,
1431+ "GET /static/example.png HTTP/1.1\r \n Host: vcl.test\r \n X-Device-Class: mobile\r \n Connection: close\r \n \r \n " ,
1432+ )
1433+ . await ;
1434+ assert ! ( after_purge. ends_with( "mobile-after-tag-purge" ) ) ;
1435+ assert_eq ! (
1436+ response_header( & after_purge, "x-cache-status" ) . as_deref( ) ,
1437+ Some ( "MISS" )
1438+ ) ;
14101439}
14111440
14121441#[ tokio:: test]
0 commit comments