Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions tests/test_certificates.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import json
import shlex

import pytest
from e2b import Sandbox

from harness import CodeInterpreter

pytestmark = pytest.mark.skip_debug

CHECK_CERTIFICATES = """
Expand Down Expand Up @@ -52,49 +49,6 @@ def test_certificate_stores(sandbox: Sandbox, python: str):
assert "Certificate stores verified" in result.stdout


CHECK_NODE_HTTPS = """
(async () => {
const https = require('node:https');
const probe = (host) => new Promise((resolve, reject) => {
const request = https.get(`https://${host}/`, (response) => {
response.resume();
resolve('connected');
});
request.setTimeout(15000, () => request.destroy(new Error('TLS probe timed out')));
request.on('error', (error) => {
if (error.code === 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' ||
error.code === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' ||
error.code === 'SELF_SIGNED_CERT_IN_CHAIN') {
resolve('untrusted');
} else {
reject(error);
}
});
});
const results = await Promise.all([
probe('dv-g3b-emudhra.we-have-a-problem.com'),
probe('dv-g3b-aaa-emudhra.we-have-a-problem.com'),
probe('nodejs.org'),
]);
console.log(JSON.stringify(results));
})()
"""


def test_node_certificate_stores(sandbox: Sandbox, client: CodeInterpreter):
command = CHECK_NODE_HTTPS
result = sandbox.commands.run(f"node -e {shlex.quote(command)}")
assert json.loads(result.stdout) == ["untrusted", "untrusted", "connected"]

execution = client.run_code("await " + command, language="js")
assert execution.error is None
assert json.loads("".join(execution.stdout)) == [
"untrusted",
"untrusted",
"connected",
]


def test_java_certificate_store(sandbox: Sandbox):
Comment thread
matthewlouisbrockman marked this conversation as resolved.
result = sandbox.commands.run(
"/usr/lib/jvm/jdk-11/bin/keytool -J-Duser.language=en -list -v -cacerts -storepass changeit",
Expand Down
Loading