MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_self_signed_certificates

Function test_self_signed_certificates

tests/test_clnrest.py:43–58  ·  view source on GitHub ↗

Test that self-signed certificates have `clnrest-host` IP in Subject Alternative Name.

(node_factory)

Source from the content-addressed store, hash-verified

41
42
43def test_self_signed_certificates(node_factory):
44 """Test that self-signed certificates have `clnrest-host` IP in Subject Alternative Name."""
45 rest_port = str(node_factory.get_unused_port())
46 rest_host = '127.0.0.1'
47 base_url = f'https://{rest_host}:{rest_port}'
48 l1 = node_factory.get_node(options={'disable-plugin': 'cln-grpc',
49 'clnrest-port': rest_port,
50 'clnrest-host': rest_host})
51 # This might happen really early!
52 l1.daemon.logsearch_start = 0
53 l1.daemon.wait_for_log(r'plugin-clnrest: REST server running at ' + base_url)
54 ca_cert = Path(l1.daemon.lightning_dir) / TEST_NETWORK / 'ca.pem'
55
56 http_session = http_session_with_retry()
57 response = http_session.get(base_url + '/v1/list-methods', verify=ca_cert)
58 assert response.status_code == 200
59
60
61def test_uses_grpc_plugin_certificates(node_factory):

Callers

nothing calls this directly

Calls 5

http_session_with_retryFunction · 0.85
get_unused_portMethod · 0.80
wait_for_logMethod · 0.80
get_nodeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected