|
1322 | 1322 |
|
1323 | 1323 | (deftest test-http-versions-config
|
1324 | 1324 | (testing "ssl-context as options map"
|
| 1325 | + |
1325 | 1326 | (testing "with different HTTP versions in ALPN config"
|
1326 | 1327 | (let [result (try-start-server
|
1327 | 1328 | {:http-versions [:http2]
|
|
1330 | 1331 | (netty/application-protocol-config [:http1]))})]
|
1331 | 1332 | (is (instance? ExceptionInfo result))
|
1332 | 1333 | (is (= "Some desired HTTP versions are not part of ALPN config." (ex-message result)))))
|
| 1334 | + |
1333 | 1335 | (testing "with different preference order in ALPN config"
|
1334 | 1336 | (let [result (try-start-server
|
1335 | 1337 | {:http-versions [:http2 :http1]
|
|
1338 | 1340 | (netty/application-protocol-config [:http1 :http2]))})]
|
1339 | 1341 | (is (instance? ExceptionInfo result))
|
1340 | 1342 | (is (= "Desired HTTP version preference order differs from ALPN config." (ex-message result)))))
|
| 1343 | + |
1341 | 1344 | (testing "with extra HTTP versions in the ALPN config"
|
1342 | 1345 | (let [result (try-start-server
|
1343 | 1346 | {:http-versions [:http1]
|
|
1346 | 1349 | (netty/application-protocol-config [:http1 :http2]))})]
|
1347 | 1350 | (is (instance? ExceptionInfo result))
|
1348 | 1351 | (is (= "ALPN config contains more HTTP versions than desired." (ex-message result)))))
|
| 1352 | + |
1349 | 1353 | (testing "with matching ALPN config"
|
1350 | 1354 | (let [result (try-start-server
|
1351 | 1355 | {:http-versions [:http2 :http1]
|
1352 | 1356 | :ssl-context (assoc test-ssl/server-ssl-context-opts
|
1353 | 1357 | :application-protocol-config
|
1354 | 1358 | (netty/application-protocol-config [:http2 :http1]))})]
|
1355 | 1359 | (is (= :started result))))
|
| 1360 | + |
1356 | 1361 | (testing "with no ALPN config"
|
1357 | 1362 | (let [result (try-start-server
|
1358 | 1363 | {:http-versions [:http2 :http1]
|
1359 | 1364 | :ssl-context test-ssl/server-ssl-context-opts})]
|
1360 | 1365 | (is (= :started result)))))
|
| 1366 | + |
1361 | 1367 | (testing "ssl-context as SslContext instance"
|
| 1368 | + |
1362 | 1369 | (testing "with different HTTP versions in ALPN config"
|
1363 | 1370 | (let [result (try-start-server
|
1364 | 1371 | {:http-versions [:http2]
|
|
1368 | 1375 | (netty/application-protocol-config [:http1])))})]
|
1369 | 1376 | (is (instance? ExceptionInfo result))
|
1370 | 1377 | (is (= "Some desired HTTP versions are not part of ALPN config." (ex-message result)))))
|
| 1378 | + |
1371 | 1379 | (testing "with different preference order in ALPN config"
|
1372 | 1380 | (let [result (try-start-server
|
1373 | 1381 | {:http-versions [:http2 :http1]
|
|
1377 | 1385 | (netty/application-protocol-config [:http1 :http2])))})]
|
1378 | 1386 | (is (instance? ExceptionInfo result))
|
1379 | 1387 | (is (= "Desired HTTP version preference order differs from ALPN config." (ex-message result)))))
|
| 1388 | + |
1380 | 1389 | (testing "with extra HTTP versions in the ALPN config"
|
1381 | 1390 | (let [result (try-start-server
|
1382 | 1391 | {:http-versions [:http1]
|
|
1386 | 1395 | (netty/application-protocol-config [:http1 :http2])))})]
|
1387 | 1396 | (is (instance? ExceptionInfo result))
|
1388 | 1397 | (is (= "ALPN config contains more HTTP versions than desired." (ex-message result)))))
|
| 1398 | + |
1389 | 1399 | (testing "with matching ALPN config"
|
1390 | 1400 | (let [result (try-start-server
|
1391 | 1401 | {:http-versions [:http2 :http1]
|
|
1394 | 1404 | :application-protocol-config
|
1395 | 1405 | (netty/application-protocol-config [:http2 :http1])))})]
|
1396 | 1406 | (is (= :started result))))
|
| 1407 | + |
1397 | 1408 | (testing "with no ALPN config"
|
1398 | 1409 | (let [result (try-start-server
|
1399 | 1410 | {:http-versions [:http2 :http1]
|
1400 | 1411 | :ssl-context test-ssl/server-ssl-context})]
|
1401 | 1412 | (is (instance? ExceptionInfo result))
|
1402 | 1413 | (is (= "Some desired HTTP versions are not part of ALPN config." (ex-message result))))))
|
| 1414 | + |
1403 | 1415 | (testing "HTTP/2 without ssl-context"
|
1404 | 1416 | (let [result (try-start-server
|
1405 | 1417 | {:http-versions [:http2]})]
|
1406 | 1418 | (is (instance? IllegalArgumentException result))
|
1407 | 1419 | (is (= "HTTP/2 requires ssl-context to be given or use-h2c? to be true." (ex-message result)))))
|
| 1420 | + |
1408 | 1421 | (testing "HTTP/2 without ssl-context but with h2c"
|
1409 | 1422 | (let [result (try-start-server
|
1410 | 1423 | {:use-h2c? true
|
1411 | 1424 | :http-versions [:http2]})]
|
1412 | 1425 | (is (= :started result))))
|
| 1426 | + |
1413 | 1427 | (testing "HTTP/2 with ssl-context *and* with h2c"
|
1414 | 1428 | (let [result (try-start-server
|
1415 | 1429 | {:use-h2c? true
|
1416 | 1430 | :http-versions [:http2]
|
1417 | 1431 | :ssl-context test-ssl/server-ssl-context-opts})]
|
1418 | 1432 | (is (instance? IllegalArgumentException result))
|
1419 | 1433 | (is (= "use-h2c? must not be true when ssl-context is given." (ex-message result)))))
|
| 1434 | + |
1420 | 1435 | (testing "h2c without HTTP/2"
|
1421 | 1436 | (let [result (try-start-server
|
1422 | 1437 | {:use-h2c? true
|
|
0 commit comments