Skip to content

Commit b79e881

Browse files
committed
fix http and metrics flags
on beacon_node and validator_client tests - fix tls test by adding cert and key file
1 parent 21df9d1 commit b79e881

File tree

4 files changed

+85
-13
lines changed

4 files changed

+85
-13
lines changed

lighthouse/tests/beacon_node.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use lighthouse_network::PeerId;
1111
use std::fs::File;
1212
use std::io::{Read, Write};
1313
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
14+
use std::path::Path;
1415
use std::path::PathBuf;
1516
use std::process::Command;
1617
use std::str::FromStr;
@@ -1460,77 +1461,82 @@ fn disable_inbound_rate_limiter_flag() {
14601461
#[test]
14611462
fn http_allow_origin_flag() {
14621463
CommandLineTest::new()
1463-
.flag("http-allow-origin", Some("127.0.0.99"))
1464+
.flag("http", None)
1465+
.flag("http-allow-origin", Some("http://127.0.0.99"))
14641466
.run_with_zero_port()
14651467
.with_config(|config| {
1466-
assert_eq!(config.http_api.allow_origin, Some("127.0.0.99".to_string()));
1468+
assert_eq!(
1469+
config.http_api.allow_origin,
1470+
Some("http://127.0.0.99".to_string())
1471+
);
14671472
});
14681473
}
14691474
#[test]
14701475
fn http_allow_origin_all_flag() {
14711476
CommandLineTest::new()
1477+
.flag("http", None)
14721478
.flag("http-allow-origin", Some("*"))
14731479
.run_with_zero_port()
14741480
.with_config(|config| assert_eq!(config.http_api.allow_origin, Some("*".to_string())));
14751481
}
14761482
#[test]
14771483
fn http_allow_sync_stalled_flag() {
14781484
CommandLineTest::new()
1485+
.flag("http", None)
14791486
.flag("http-allow-sync-stalled", None)
14801487
.run_with_zero_port()
14811488
.with_config(|config| assert_eq!(config.http_api.allow_sync_stalled, true));
14821489
}
14831490
#[test]
14841491
fn http_enable_beacon_processor() {
14851492
CommandLineTest::new()
1493+
.flag("http", None)
14861494
.run_with_zero_port()
14871495
.with_config(|config| assert_eq!(config.http_api.enable_beacon_processor, true));
14881496

14891497
CommandLineTest::new()
1498+
.flag("http", None)
14901499
.flag("http-enable-beacon-processor", Some("true"))
14911500
.run_with_zero_port()
14921501
.with_config(|config| assert_eq!(config.http_api.enable_beacon_processor, true));
14931502

14941503
CommandLineTest::new()
1504+
.flag("http", None)
14951505
.flag("http-enable-beacon-processor", Some("false"))
14961506
.run_with_zero_port()
14971507
.with_config(|config| assert_eq!(config.http_api.enable_beacon_processor, false));
14981508
}
14991509
#[test]
15001510
fn http_tls_flags() {
1501-
let dir = TempDir::new().expect("Unable to create temporary directory");
15021511
CommandLineTest::new()
1512+
.flag("http", None)
15031513
.flag("http-enable-tls", None)
1504-
.flag(
1505-
"http-tls-cert",
1506-
dir.path().join("certificate.crt").as_os_str().to_str(),
1507-
)
1508-
.flag(
1509-
"http-tls-key",
1510-
dir.path().join("private.key").as_os_str().to_str(),
1511-
)
1514+
.flag("http-tls-cert", Some("tests/tls/cert.pem"))
1515+
.flag("http-tls-key", Some("tests/tls/key.rsa"))
15121516
.run_with_zero_port()
15131517
.with_config(|config| {
15141518
let tls_config = config
15151519
.http_api
15161520
.tls_config
15171521
.as_ref()
15181522
.expect("tls_config was empty.");
1519-
assert_eq!(tls_config.cert, dir.path().join("certificate.crt"));
1520-
assert_eq!(tls_config.key, dir.path().join("private.key"));
1523+
assert_eq!(tls_config.cert, Path::new("tests/tls/cert.pem"));
1524+
assert_eq!(tls_config.key, Path::new("tests/tls/key.rsa"));
15211525
});
15221526
}
15231527

15241528
#[test]
15251529
fn http_spec_fork_default() {
15261530
CommandLineTest::new()
1531+
.flag("http", None)
15271532
.run_with_zero_port()
15281533
.with_config(|config| assert_eq!(config.http_api.spec_fork_name, None));
15291534
}
15301535

15311536
#[test]
15321537
fn http_spec_fork_override() {
15331538
CommandLineTest::new()
1539+
.flag("http", None)
15341540
.flag("http-spec-fork", Some("altair"))
15351541
.run_with_zero_port()
15361542
.with_config(|config| assert_eq!(config.http_api.spec_fork_name, Some(ForkName::Altair)));

lighthouse/tests/tls/cert.pem

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIEADCCAmigAwIBAgICAcgwDQYJKoZIhvcNAQELBQAwLDEqMCgGA1UEAwwhcG9u
3+
eXRvd24gUlNBIGxldmVsIDIgaW50ZXJtZWRpYXRlMB4XDTE2MDgxMzE2MDcwNFoX
4+
DTIyMDIwMzE2MDcwNFowGTEXMBUGA1UEAwwOdGVzdHNlcnZlci5jb20wggEiMA0G
5+
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpVhh1/FNP2qvWenbZSghari/UThwe
6+
dynfnHG7gc3JmygkEdErWBO/CHzHgsx7biVE5b8sZYNEDKFojyoPHGWK2bQM/FTy
7+
niJCgNCLdn6hUqqxLAml3cxGW77hAWu94THDGB1qFe+eFiAUnDmob8gNZtAzT6Ky
8+
b/JGJdrEU0wj+Rd7wUb4kpLInNH/Jc+oz2ii2AjNbGOZXnRz7h7Kv3sO9vABByYe
9+
LcCj3qnhejHMqVhbAT1MD6zQ2+YKBjE52MsQKU/xhUpu9KkUyLh0cxkh3zrFiKh4
10+
Vuvtc+n7aeOv2jJmOl1dr0XLlSHBlmoKqH6dCTSbddQLmlK7dms8vE01AgMBAAGj
11+
gb4wgbswDAYDVR0TAQH/BAIwADALBgNVHQ8EBAMCBsAwHQYDVR0OBBYEFMeUzGYV
12+
bXwJNQVbY1+A8YXYZY8pMEIGA1UdIwQ7MDmAFJvEsUi7+D8vp8xcWvnEdVBGkpoW
13+
oR6kHDAaMRgwFgYDVQQDDA9wb255dG93biBSU0EgQ0GCAXswOwYDVR0RBDQwMoIO
14+
dGVzdHNlcnZlci5jb22CFXNlY29uZC50ZXN0c2VydmVyLmNvbYIJbG9jYWxob3N0
15+
MA0GCSqGSIb3DQEBCwUAA4IBgQBsk5ivAaRAcNgjc7LEiWXFkMg703AqDDNx7kB1
16+
RDgLalLvrjOfOp2jsDfST7N1tKLBSQ9bMw9X4Jve+j7XXRUthcwuoYTeeo+Cy0/T
17+
1Q78ctoX74E2nB958zwmtRykGrgE/6JAJDwGcgpY9kBPycGxTlCN926uGxHsDwVs
18+
98cL6ZXptMLTR6T2XP36dAJZuOICSqmCSbFR8knc/gjUO36rXTxhwci8iDbmEVaf
19+
BHpgBXGU5+SQ+QM++v6bHGf4LNQC5NZ4e4xvGax8ioYu/BRsB/T3Lx+RlItz4zdU
20+
XuxCNcm3nhQV2ZHquRdbSdoyIxV5kJXel4wCmOhWIq7A2OBKdu5fQzIAzzLi65EN
21+
RPAKsKB4h7hGgvciZQ7dsMrlGw0DLdJ6UrFyiR5Io7dXYT/+JP91lP5xsl6Lhg9O
22+
FgALt7GSYRm2cZdgi9pO9rRr83Br1VjQT1vHz6yoZMXSqc4A2zcN2a2ZVq//rHvc
23+
FZygs8miAhWPzqnpmgTj1cPiU1M=
24+
-----END CERTIFICATE-----

lighthouse/tests/tls/key.rsa

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-----BEGIN RSA PRIVATE KEY-----
2+
MIIEpAIBAAKCAQEAqVYYdfxTT9qr1np22UoIWq4v1E4cHncp35xxu4HNyZsoJBHR
3+
K1gTvwh8x4LMe24lROW/LGWDRAyhaI8qDxxlitm0DPxU8p4iQoDQi3Z+oVKqsSwJ
4+
pd3MRlu+4QFrveExwxgdahXvnhYgFJw5qG/IDWbQM0+ism/yRiXaxFNMI/kXe8FG
5+
+JKSyJzR/yXPqM9ootgIzWxjmV50c+4eyr97DvbwAQcmHi3Ao96p4XoxzKlYWwE9
6+
TA+s0NvmCgYxOdjLEClP8YVKbvSpFMi4dHMZId86xYioeFbr7XPp+2njr9oyZjpd
7+
Xa9Fy5UhwZZqCqh+nQk0m3XUC5pSu3ZrPLxNNQIDAQABAoIBAFKtZJgGsK6md4vq
8+
kyiYSufrcBLaaEQ/rkQtYCJKyC0NAlZKFLRy9oEpJbNLm4cQSkYPXn3Qunx5Jj2k
9+
2MYz+Sg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l2gl/vA0etPrto4RkVq
25+
UrkDO/9W4mZORClN3knxEFSTlYi8YOboxdlynpFfhcs82wFChs+Ydp1eEsVHAqtu
26+
T+uzn0sroycBiBfVB949LExnzGDFUkhG0i2c2InarQYLTsIyHCIDEA==
27+
-----END RSA PRIVATE KEY-----

lighthouse/tests/validator_client.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ fn http_flag() {
260260
fn http_address_flag() {
261261
let addr = "127.0.0.99".parse::<IpAddr>().unwrap();
262262
CommandLineTest::new()
263+
.flag("http", None)
263264
.flag("http-address", Some("127.0.0.99"))
264265
.flag("unencrypted-http-transport", None)
265266
.run()
@@ -269,6 +270,7 @@ fn http_address_flag() {
269270
fn http_address_ipv6_flag() {
270271
let addr = "::1".parse::<IpAddr>().unwrap();
271272
CommandLineTest::new()
273+
.flag("http", None)
272274
.flag("http-address", Some("::1"))
273275
.flag("unencrypted-http-transport", None)
274276
.run()
@@ -279,20 +281,23 @@ fn http_address_ipv6_flag() {
279281
fn missing_unencrypted_http_transport_flag() {
280282
let addr = "127.0.0.99".parse::<IpAddr>().unwrap();
281283
CommandLineTest::new()
284+
.flag("http", None)
282285
.flag("http-address", Some("127.0.0.99"))
283286
.run()
284287
.with_config(|config| assert_eq!(config.http_api.listen_addr, addr));
285288
}
286289
#[test]
287290
fn http_port_flag() {
288291
CommandLineTest::new()
292+
.flag("http", None)
289293
.flag("http-port", Some("9090"))
290294
.run()
291295
.with_config(|config| assert_eq!(config.http_api.listen_port, 9090));
292296
}
293297
#[test]
294298
fn http_allow_origin_flag() {
295299
CommandLineTest::new()
300+
.flag("http", None)
296301
.flag("http-allow-origin", Some("http://localhost:9009"))
297302
.run()
298303
.with_config(|config| {
@@ -305,32 +310,37 @@ fn http_allow_origin_flag() {
305310
#[test]
306311
fn http_allow_origin_all_flag() {
307312
CommandLineTest::new()
313+
.flag("http", None)
308314
.flag("http-allow-origin", Some("*"))
309315
.run()
310316
.with_config(|config| assert_eq!(config.http_api.allow_origin, Some("*".to_string())));
311317
}
312318
#[test]
313319
fn http_allow_keystore_export_default() {
314320
CommandLineTest::new()
321+
.flag("http", None)
315322
.run()
316323
.with_config(|config| assert!(!config.http_api.allow_keystore_export));
317324
}
318325
#[test]
319326
fn http_allow_keystore_export_present() {
320327
CommandLineTest::new()
328+
.flag("http", None)
321329
.flag("http-allow-keystore-export", None)
322330
.run()
323331
.with_config(|config| assert!(config.http_api.allow_keystore_export));
324332
}
325333
#[test]
326334
fn http_store_keystore_passwords_in_secrets_dir_default() {
327335
CommandLineTest::new()
336+
.flag("http", None)
328337
.run()
329338
.with_config(|config| assert!(!config.http_api.store_passwords_in_secrets_dir));
330339
}
331340
#[test]
332341
fn http_store_keystore_passwords_in_secrets_dir_present() {
333342
CommandLineTest::new()
343+
.flag("http", None)
334344
.flag("http-store-passwords-in-secrets-dir", None)
335345
.run()
336346
.with_config(|config| assert!(config.http_api.store_passwords_in_secrets_dir));
@@ -348,6 +358,7 @@ fn metrics_flag() {
348358
fn metrics_address_flag() {
349359
let addr = "127.0.0.99".parse::<IpAddr>().unwrap();
350360
CommandLineTest::new()
361+
.flag("metrics", None)
351362
.flag("metrics-address", Some("127.0.0.99"))
352363
.run()
353364
.with_config(|config| assert_eq!(config.http_metrics.listen_addr, addr));
@@ -356,20 +367,23 @@ fn metrics_address_flag() {
356367
fn metrics_address_ipv6_flag() {
357368
let addr = "::1".parse::<IpAddr>().unwrap();
358369
CommandLineTest::new()
370+
.flag("metrics", None)
359371
.flag("metrics-address", Some("::1"))
360372
.run()
361373
.with_config(|config| assert_eq!(config.http_metrics.listen_addr, addr));
362374
}
363375
#[test]
364376
fn metrics_port_flag() {
365377
CommandLineTest::new()
378+
.flag("metrics", None)
366379
.flag("metrics-port", Some("9090"))
367380
.run()
368381
.with_config(|config| assert_eq!(config.http_metrics.listen_port, 9090));
369382
}
370383
#[test]
371384
fn metrics_allow_origin_flag() {
372385
CommandLineTest::new()
386+
.flag("metrics", None)
373387
.flag("metrics-allow-origin", Some("http://localhost:9009"))
374388
.run()
375389
.with_config(|config| {
@@ -382,6 +396,7 @@ fn metrics_allow_origin_flag() {
382396
#[test]
383397
fn metrics_allow_origin_all_flag() {
384398
CommandLineTest::new()
399+
.flag("metrics", None)
385400
.flag("metrics-allow-origin", Some("*"))
386401
.run()
387402
.with_config(|config| assert_eq!(config.http_metrics.allow_origin, Some("*".to_string())));

0 commit comments

Comments
 (0)