@@ -1093,3 +1093,210 @@ func TestAnalyze_nap_app_protect_reconnect_period_seconds(t *testing.T) {
10931093 })
10941094 }
10951095}
1096+
1097+ //nolint:funlen
1098+ func TestAnalyze_http3 (t * testing.T ) {
1099+ t .Parallel ()
1100+ testcases := map [string ]struct {
1101+ stmt * Directive
1102+ ctx blockCtx
1103+ wantErr bool
1104+ }{
1105+ "http3 ok" : {
1106+ & Directive {
1107+ Directive : "http3" ,
1108+ Args : []string {"on" },
1109+ Line : 5 ,
1110+ },
1111+ blockCtx {"http" , "server" },
1112+ false ,
1113+ },
1114+ "http3 not ok" : {
1115+ & Directive {
1116+ Directive : "http3" ,
1117+ Args : []string {"somevalue" },
1118+ Line : 5 ,
1119+ },
1120+ blockCtx {"http" , "server" },
1121+ true ,
1122+ },
1123+ "http3_hq ok" : {
1124+ & Directive {
1125+ Directive : "http3_hq" ,
1126+ Args : []string {"on" },
1127+ Line : 5 ,
1128+ },
1129+ blockCtx {"http" , "server" },
1130+ false ,
1131+ },
1132+ "http3_hq not ok" : {
1133+ & Directive {
1134+ Directive : "http3_hq" ,
1135+ Args : []string {"somevalue" },
1136+ Line : 5 ,
1137+ },
1138+ blockCtx {"http" , "server" },
1139+ true ,
1140+ },
1141+ "http3_max_concurrent_streams ok" : {
1142+ & Directive {
1143+ Directive : "http3_max_concurrent_streams" ,
1144+ Args : []string {"10" },
1145+ Line : 5 ,
1146+ },
1147+ blockCtx {"http" , "server" },
1148+ false ,
1149+ },
1150+ "http3_max_concurrent_streams not ok" : {
1151+ & Directive {
1152+ Directive : "http3_max_concurrent_streams" ,
1153+ Args : []string {"10" },
1154+ Line : 5 ,
1155+ },
1156+ blockCtx {"http" , "location" },
1157+ true ,
1158+ },
1159+ "http3_stream_buffer_size ok" : {
1160+ & Directive {
1161+ Directive : "http3_stream_buffer_size" ,
1162+ Args : []string {"128k" },
1163+ Line : 5 ,
1164+ },
1165+ blockCtx {"http" , "server" },
1166+ false ,
1167+ },
1168+ "http3_stream_buffer_size not ok" : {
1169+ & Directive {
1170+ Directive : "http3_stream_buffer_size" ,
1171+ Args : []string {"128k" },
1172+ Line : 5 ,
1173+ },
1174+ blockCtx {"http" , "location" },
1175+ true ,
1176+ },
1177+ }
1178+
1179+ for name , tc := range testcases {
1180+ tc := tc
1181+ t .Run (name , func (t * testing.T ) {
1182+ t .Parallel ()
1183+ err := analyze ("nginx.conf" , tc .stmt , ";" , tc .ctx , & ParseOptions {})
1184+
1185+ if ! tc .wantErr && err != nil {
1186+ t .Fatal (err )
1187+ }
1188+
1189+ if tc .wantErr && err == nil {
1190+ t .Fatal ("expected error, got nil" )
1191+ }
1192+ })
1193+ }
1194+ }
1195+
1196+ //nolint:funlen
1197+ func TestAnalyze_quic (t * testing.T ) {
1198+ t .Parallel ()
1199+ testcases := map [string ]struct {
1200+ stmt * Directive
1201+ ctx blockCtx
1202+ wantErr bool
1203+ }{
1204+ "quic_active_connection_id_limit ok" : {
1205+ & Directive {
1206+ Directive : "quic_active_connection_id_limit" ,
1207+ Args : []string {"2" },
1208+ Line : 5 ,
1209+ },
1210+ blockCtx {"http" , "server" },
1211+ false ,
1212+ },
1213+ "quic_active_connection_id_limit not ok" : {
1214+ & Directive {
1215+ Directive : "quic_active_connection_id_limit" ,
1216+ Args : []string {"2" },
1217+ Line : 5 ,
1218+ },
1219+ blockCtx {"http" , "location" },
1220+ true ,
1221+ },
1222+ "quic_bpf ok" : {
1223+ & Directive {
1224+ Directive : "quic_bpf" ,
1225+ Args : []string {"on" },
1226+ Line : 5 ,
1227+ },
1228+ blockCtx {"main" },
1229+ false ,
1230+ },
1231+ "quic_bpf not ok" : {
1232+ & Directive {
1233+ Directive : "quic_bpf" ,
1234+ Args : []string {"on" },
1235+ Line : 5 ,
1236+ },
1237+ blockCtx {"http" , "server" },
1238+ true ,
1239+ },
1240+ "quic_gso ok" : {
1241+ & Directive {
1242+ Directive : "quic_gso" ,
1243+ Args : []string {"on" },
1244+ Line : 5 ,
1245+ },
1246+ blockCtx {"http" , "server" },
1247+ false ,
1248+ },
1249+ "quic_gso not ok" : {
1250+ & Directive {
1251+ Directive : "quic_gso" ,
1252+ Args : []string {"somevalue" },
1253+ Line : 5 ,
1254+ },
1255+ blockCtx {"http" , "server" },
1256+ true ,
1257+ },
1258+ "quic_host_key ok" : {
1259+ & Directive {
1260+ Directive : "http3_max_concurrent_streams" ,
1261+ Args : []string {"somefile" },
1262+ Line : 5 ,
1263+ },
1264+ blockCtx {"http" , "server" },
1265+ false ,
1266+ },
1267+ "quic_retry ok" : {
1268+ & Directive {
1269+ Directive : "quic_retry" ,
1270+ Args : []string {"off" },
1271+ Line : 5 ,
1272+ },
1273+ blockCtx {"http" , "server" },
1274+ false ,
1275+ },
1276+ "quic_retry not ok" : {
1277+ & Directive {
1278+ Directive : "quic_retry" ,
1279+ Args : []string {"somevalue" },
1280+ Line : 5 ,
1281+ },
1282+ blockCtx {"http" , "server" },
1283+ true ,
1284+ },
1285+ }
1286+
1287+ for name , tc := range testcases {
1288+ tc := tc
1289+ t .Run (name , func (t * testing.T ) {
1290+ t .Parallel ()
1291+ err := analyze ("nginx.conf" , tc .stmt , ";" , tc .ctx , & ParseOptions {})
1292+
1293+ if ! tc .wantErr && err != nil {
1294+ t .Fatal (err )
1295+ }
1296+
1297+ if tc .wantErr && err == nil {
1298+ t .Fatal ("expected error, got nil" )
1299+ }
1300+ })
1301+ }
1302+ }
0 commit comments