Fix desktop WebSocket certificate verification
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import ssl
|
||||
|
||||
from sync_client import SyncClientThread
|
||||
|
||||
|
||||
def test_ssl_context_uses_bundled_ca_certificates():
|
||||
context = SyncClientThread._create_ssl_context()
|
||||
|
||||
assert context.verify_mode == ssl.CERT_REQUIRED
|
||||
assert context.check_hostname is True
|
||||
assert context.cert_store_stats()["x509_ca"] > 0
|
||||
|
||||
|
||||
def test_certificate_error_finds_nested_verification_error():
|
||||
certificate_error = ssl.SSLCertVerificationError(1, "certificate has expired")
|
||||
|
||||
try:
|
||||
raise RuntimeError("connection failed") from certificate_error
|
||||
except RuntimeError as error:
|
||||
assert SyncClientThread._certificate_error(error) is certificate_error
|
||||
|
||||
|
||||
def test_non_certificate_error_is_ignored():
|
||||
assert SyncClientThread._certificate_error(ConnectionError("offline")) is None
|
||||
Reference in New Issue
Block a user