Replaces LICENSE (GPLv3 -> AGPLv3) and prepends `SPDX-License-Identifier: AGPL-3.0-or-later` to every source file across decnet/, decnet_web/, tests/, scripts/, and tools/. Rationale: closes the GPLv3 ASP loophole so any party operating a modified DECNET as a network service must offer their modified source. Personal copyright (Samuel Paschuan) + inbound=outbound contributions make a future unilateral relicense infeasible. - LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt) - COPYRIGHT: project copyright notice - tools/add_spdx_headers.py: idempotent header injector (shebang- and PEP 263-aware) Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh). No behavior change; comments only.
71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
import pytest
|
|
import pymysql
|
|
|
|
from tests.live.conftest import assert_rfc5424, _mysql_available
|
|
|
|
pytestmark = pytest.mark.skipif(
|
|
not _mysql_available(),
|
|
reason="MySQL not available on 127.0.0.1:3307"
|
|
)
|
|
|
|
@pytest.mark.live
|
|
class TestMySQLLive:
|
|
def test_handshake_received(self, live_service):
|
|
port, drain = live_service("mysql")
|
|
# Honeypot sends MySQL greeting then denies auth — OperationalError expected
|
|
try:
|
|
pymysql.connect(
|
|
host="127.0.0.1",
|
|
port=port,
|
|
user="root",
|
|
password="password",
|
|
connect_timeout=5,
|
|
)
|
|
except pymysql.err.OperationalError:
|
|
pass # expected: Access denied
|
|
|
|
def test_auth_logged(self, live_service):
|
|
port, drain = live_service("mysql")
|
|
try:
|
|
pymysql.connect(
|
|
host="127.0.0.1",
|
|
port=port,
|
|
user="admin",
|
|
password="hunter2",
|
|
connect_timeout=5,
|
|
)
|
|
except pymysql.err.OperationalError:
|
|
pass
|
|
lines = drain()
|
|
assert_rfc5424(lines, service="mysql", event_type="auth")
|
|
|
|
def test_username_in_log(self, live_service):
|
|
port, drain = live_service("mysql")
|
|
try:
|
|
pymysql.connect(
|
|
host="127.0.0.1",
|
|
port=port,
|
|
user="dbhacker",
|
|
password="letmein",
|
|
connect_timeout=5,
|
|
)
|
|
except pymysql.err.OperationalError:
|
|
pass
|
|
lines = drain()
|
|
matched = assert_rfc5424(lines, service="mysql", event_type="auth")
|
|
assert "dbhacker" in matched, (
|
|
f"Expected username in log line. Got:\n{matched!r}"
|
|
)
|
|
|
|
def test_connect_logged(self, live_service):
|
|
port, drain = live_service("mysql")
|
|
try:
|
|
pymysql.connect(
|
|
host="127.0.0.1", port=port, user="x", password="y", connect_timeout=5
|
|
)
|
|
except pymysql.err.OperationalError:
|
|
pass
|
|
lines = drain()
|
|
assert_rfc5424(lines, service="mysql", event_type="connect")
|