@@ -1093,3 +1093,183 @@ func TestAnalyze_nap_app_protect_reconnect_period_seconds(t *testing.T) {
1093
1093
})
1094
1094
}
1095
1095
}
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" ,
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" ,
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_stream_buffer_size ok" : {
1151
+ & Directive {
1152
+ Directive : "http3_stream_buffer_size" ,
1153
+ Args : []string {"128k" },
1154
+ Line : 5 ,
1155
+ },
1156
+ blockCtx {"http" , "server" },
1157
+ false ,
1158
+ },
1159
+ }
1160
+
1161
+ for name , tc := range testcases {
1162
+ tc := tc
1163
+ t .Run (name , func (t * testing.T ) {
1164
+ t .Parallel ()
1165
+ err := analyze ("nginx.conf" , tc .stmt , ";" , tc .ctx , & ParseOptions {})
1166
+
1167
+ if ! tc .wantErr && err != nil {
1168
+ t .Fatal (err )
1169
+ }
1170
+
1171
+ if tc .wantErr && err == nil {
1172
+ t .Fatal ("expected error, got nil" )
1173
+ }
1174
+ })
1175
+ }
1176
+ }
1177
+
1178
+ //nolint:funlen
1179
+ func TestAnalyze_quic (t * testing.T ) {
1180
+ t .Parallel ()
1181
+ testcases := map [string ]struct {
1182
+ stmt * Directive
1183
+ ctx blockCtx
1184
+ wantErr bool
1185
+ }{
1186
+ "quic_active_connection_id_limit ok" : {
1187
+ & Directive {
1188
+ Directive : "quic_active_connection_id_limit" ,
1189
+ Args : []string {"2" },
1190
+ Line : 5 ,
1191
+ },
1192
+ blockCtx {"http" , "server" },
1193
+ false ,
1194
+ },
1195
+ "quic_bpf ok" : {
1196
+ & Directive {
1197
+ Directive : "quic_bpf" ,
1198
+ Args : []string {"on" },
1199
+ Line : 5 ,
1200
+ },
1201
+ blockCtx {"main" },
1202
+ false ,
1203
+ },
1204
+ "quic_bpf not ok" : {
1205
+ & Directive {
1206
+ Directive : "quic_bpf" ,
1207
+ Args : []string {"on" },
1208
+ Line : 5 ,
1209
+ },
1210
+ blockCtx {"http" , "server" },
1211
+ true ,
1212
+ },
1213
+ "quic_gso ok" : {
1214
+ & Directive {
1215
+ Directive : "quic_gso" ,
1216
+ Args : []string {"on" },
1217
+ Line : 5 ,
1218
+ },
1219
+ blockCtx {"http" , "server" },
1220
+ false ,
1221
+ },
1222
+ "quic_gso not ok" : {
1223
+ & Directive {
1224
+ Directive : "quic_gso" ,
1225
+ Args : []string {"somevalue" },
1226
+ Line : 5 ,
1227
+ },
1228
+ blockCtx {"http" , "server" },
1229
+ true ,
1230
+ },
1231
+ "quic_host_key ok" : {
1232
+ & Directive {
1233
+ Directive : "http3_max_concurrent_streams" ,
1234
+ Args : []string {"somefile" },
1235
+ Line : 5 ,
1236
+ },
1237
+ blockCtx {"http" , "server" },
1238
+ false ,
1239
+ },
1240
+ "quic_retry ok" : {
1241
+ & Directive {
1242
+ Directive : "quic_retry" ,
1243
+ Args : []string {"off" },
1244
+ Line : 5 ,
1245
+ },
1246
+ blockCtx {"http" , "server" },
1247
+ false ,
1248
+ },
1249
+ "quic_retry not ok" : {
1250
+ & Directive {
1251
+ Directive : "quic_retry" ,
1252
+ Args : []string {"somevalue" },
1253
+ Line : 5 ,
1254
+ },
1255
+ blockCtx {"http" , "server" },
1256
+ true ,
1257
+ },
1258
+ }
1259
+
1260
+ for name , tc := range testcases {
1261
+ tc := tc
1262
+ t .Run (name , func (t * testing.T ) {
1263
+ t .Parallel ()
1264
+ err := analyze ("nginx.conf" , tc .stmt , ";" , tc .ctx , & ParseOptions {})
1265
+
1266
+ if ! tc .wantErr && err != nil {
1267
+ t .Fatal (err )
1268
+ }
1269
+
1270
+ if tc .wantErr && err == nil {
1271
+ t .Fatal ("expected error, got nil" )
1272
+ }
1273
+ })
1274
+ }
1275
+ }
0 commit comments