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

Function test_self_signed_certificates

tests/test_clnrest.py:42–57  ·  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

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