1 parent
cc3ce49c7f
commit
9c450f1734
80 files changed
+422
-368
No files matched your search
@@ -116,9 +116,10 @@ def main():
|
||||
if digest(previous) != args.expected_config_sha256 or CONFIG.is_symlink():
|
||||
parser.error('线上配置与已审查版本不符')
|
||||
proposed = (evidence / 'smail.conf').read_bytes()
|
||||
expected = previous.replace(
|
||||
b'/var/lib/smail-acme-tls/certificates/cdis.cn.crt', b'/opt/smail/ssl/custom.crt').replace(
|
||||
b'/var/lib/smail-acme-tls/certificates/cdis.cn.key', b'/opt/smail/ssl/custom.key')
|
||||
certificate = f'/var/lib/smail-acme-tls/certificates/{deploy.MAIL_DOMAIN}.crt'.encode()
|
||||
private_key = f'/var/lib/smail-acme-tls/certificates/{deploy.MAIL_DOMAIN}.key'.encode()
|
||||
expected = previous.replace(certificate, b'/opt/smail/ssl/custom.crt').replace(
|
||||
private_key, b'/opt/smail/ssl/custom.key')
|
||||
if proposed != expected or proposed == previous:
|
||||
parser.error('候选配置必须且只能改变 Smail 证书读取路径')
|
||||
run('nginx', '-t')
|
||||
@@ -158,21 +159,21 @@ def main():
|
||||
|
||||
try:
|
||||
scripts = Scripts()
|
||||
scripts.feed(request('mail.cdis.cn', 443).decode('utf-8'))
|
||||
scripts.feed(request(deploy.VERIFY_HOSTNAMES[0], 443).decode('utf-8'))
|
||||
if not scripts.paths:
|
||||
raise RuntimeError('未找到用于既有连接测试的真实静态资源')
|
||||
asset = args.asset_path or scripts.paths[0]
|
||||
expected_body = request('mail.cdis.cn', 443, asset)
|
||||
expected_body = request(deploy.VERIFY_HOSTNAMES[0], 443, asset)
|
||||
if len(expected_body) < 65536:
|
||||
raise RuntimeError('静态资源过小,无法进行本次下载连续性检查')
|
||||
for host, port in (('mail.cdis.cn', 443), ('web.cdis.cn', 443)):
|
||||
for host, port in ((deploy.VERIFY_HOSTNAMES[0], 443), (deploy.CERTIFICATE_SNI, 443)):
|
||||
thread = threading.Thread(target=monitor, args=(host, port))
|
||||
thread.start()
|
||||
threads.append(thread)
|
||||
time.sleep(2)
|
||||
if len(report['samples']) < 4 or any(not item['ok'] for item in report['samples']):
|
||||
raise RuntimeError('迁移前连续探测未通过')
|
||||
secure, response = request('mail.cdis.cn', 443, asset, slow=True)
|
||||
secure, response = request(deploy.VERIFY_HOSTNAMES[0], 443, asset, slow=True)
|
||||
pending = (secure, response)
|
||||
prefix = response.read(1024)
|
||||
report['connectionOpenedBeforeReload'] = True
|
||||
|
||||
@@ -11,11 +11,13 @@ import subprocess
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
import deploy_certificate as deploy
|
||||
|
||||
|
||||
SERVER = 'https://acme-staging-v02.api.letsencrypt.org/directory'
|
||||
SOURCE = Path('/usr/local/libexec/smail-acme/renew_certificate.py')
|
||||
LEGACY_SOURCE_SHA256 = '6d0abbe9466f8becd61b1cb3c750bfffb938d16c5a9bcae0b96d1451227d4216'
|
||||
DOMAINS = {'cdis.cn', 'mail.cdis.cn', 'smtp.cdis.cn', 'imap.cdis.cn', 'pop.cdis.cn'}
|
||||
DOMAINS = set(deploy.DOMAINS)
|
||||
RUN = subprocess.run
|
||||
|
||||
|
||||
@@ -59,14 +61,14 @@ def main():
|
||||
run(['nginx', '-t'], check=True)
|
||||
run(['systemctl', 'is-active', '--quiet', 'nginx'], check=True)
|
||||
|
||||
certificate = stage / 'certificates/cdis.cn.crt'
|
||||
key = stage / 'certificates/cdis.cn.key'
|
||||
certificate = stage / f'certificates/{deploy.MAIL_DOMAIN}.crt'
|
||||
key = stage / f'certificates/{deploy.MAIL_DOMAIN}.key'
|
||||
old_certificate = digest(certificate)
|
||||
old_key = digest(key)
|
||||
protected = [Path('/opt/smail/smail'), Path('/opt/smail/smail-admin'),
|
||||
Path('/opt/smail/ssl/custom.crt'), Path('/opt/smail/ssl/custom.key'),
|
||||
Path('/var/lib/smail-acme-tls/certificates/cdis.cn.crt'),
|
||||
Path('/var/lib/smail-acme-tls/certificates/cdis.cn.key')]
|
||||
Path(f'/var/lib/smail-acme-tls/certificates/{deploy.MAIL_DOMAIN}.crt'),
|
||||
Path(f'/var/lib/smail-acme-tls/certificates/{deploy.MAIL_DOMAIN}.key')]
|
||||
protected.extend(sorted(Path('/etc/nginx/conf.d').glob('*.conf')))
|
||||
before = {path: digest(path) for path in protected}
|
||||
spec = importlib.util.spec_from_file_location('production_renew', SOURCE)
|
||||
|
||||
@@ -18,7 +18,7 @@ sys.path.insert(0, str(SCRIPTS))
|
||||
|
||||
|
||||
if os.name == 'posix':
|
||||
with patch.dict(os.environ, {'SMAIL_MAIL_DOMAIN': 'cdis.cn', 'SMAIL_WEB_DOMAIN': 'web.cdis.cn'}):
|
||||
with patch.dict(os.environ, {'SMAIL_MAIL_DOMAIN': 'example.com', 'SMAIL_WEB_DOMAIN': 'web.example.com'}):
|
||||
import deploy_certificate as deploy
|
||||
import renew_certificate as renew
|
||||
import nginx_certificate_cutover as cutover
|
||||
@@ -189,7 +189,7 @@ class DeploymentTests(unittest.TestCase):
|
||||
'-subj', '/CN=Smail isolated test CA',
|
||||
'-addext', 'keyUsage=critical,keyCertSign,cRLSign')
|
||||
cls.real_run('openssl', 'req', '-new', '-newkey', 'rsa:2048', '-nodes',
|
||||
'-keyout', str(cls.key), '-out', str(cls.csr), '-subj', '/CN=cdis.cn',
|
||||
'-keyout', str(cls.key), '-out', str(cls.csr), '-subj', '/CN=example.com',
|
||||
'-addext', 'basicConstraints=critical,CA:FALSE',
|
||||
'-addext', 'keyUsage=critical,digitalSignature,keyEncipherment',
|
||||
'-addext', 'extendedKeyUsage=serverAuth',
|
||||
@@ -208,9 +208,9 @@ class DeploymentTests(unittest.TestCase):
|
||||
self.backups = self.directory / 'backups'
|
||||
for directory in (self.source, self.target, self.backups):
|
||||
directory.mkdir(mode=0o700)
|
||||
for path, value in ((self.source / 'cdis.cn.crt', self.new.read_bytes()),
|
||||
(self.source / 'cdis.cn.key', self.key.read_bytes()),
|
||||
(self.source / 'cdis.cn.issuer.crt', self.ca.read_bytes()),
|
||||
for path, value in ((self.source / 'example.com.crt', self.new.read_bytes()),
|
||||
(self.source / 'example.com.key', self.key.read_bytes()),
|
||||
(self.source / 'example.com.issuer.crt', self.ca.read_bytes()),
|
||||
(self.target / 'custom.crt', self.old.read_bytes()),
|
||||
(self.target / 'custom.key', self.key.read_bytes())):
|
||||
path.write_bytes(value)
|
||||
@@ -263,20 +263,20 @@ class DeploymentTests(unittest.TestCase):
|
||||
self.assertEqual(path.stat().st_mode & 0o077, 0)
|
||||
|
||||
def test_unchanged_certificate_checks_live_without_reload(self):
|
||||
(self.source / 'cdis.cn.crt').write_bytes(self.old.read_bytes())
|
||||
(self.source / 'example.com.crt').write_bytes(self.old.read_bytes())
|
||||
deploy.main()
|
||||
self.assertNotIn(('systemctl', 'reload', 'nginx'), self.calls)
|
||||
self.live.assert_called_once()
|
||||
|
||||
def test_interrupted_publish_is_reconciled_when_files_already_match(self):
|
||||
(self.source / 'cdis.cn.crt').write_bytes(self.old.read_bytes())
|
||||
(self.source / 'example.com.crt').write_bytes(self.old.read_bytes())
|
||||
self.live.side_effect = [RuntimeError('上次重载前中断'), None]
|
||||
deploy.main()
|
||||
self.assertEqual(self.calls.count(('systemctl', 'reload', 'nginx')), 1)
|
||||
self.assertEqual(self.live.call_count, 2)
|
||||
|
||||
def test_failed_reconciliation_does_not_report_success(self):
|
||||
(self.source / 'cdis.cn.crt').write_bytes(self.old.read_bytes())
|
||||
(self.source / 'example.com.crt').write_bytes(self.old.read_bytes())
|
||||
self.live.side_effect = RuntimeError('线上证书不匹配')
|
||||
with self.assertRaisesRegex(RuntimeError, '线上证书不匹配'):
|
||||
deploy.main()
|
||||
@@ -299,13 +299,13 @@ class DeploymentTests(unittest.TestCase):
|
||||
def test_short_lived_certificate_is_rejected(self):
|
||||
self.real_run('openssl', 'x509', '-req', '-in', str(self.csr), '-CA', str(self.ca),
|
||||
'-CAkey', str(self.ca_key), '-set_serial', '3', '-days', '1',
|
||||
'-copy_extensions', 'copy', '-out', str(self.source / 'cdis.cn.crt'))
|
||||
'-copy_extensions', 'copy', '-out', str(self.source / 'example.com.crt'))
|
||||
with self.assertRaises(subprocess.CalledProcessError):
|
||||
deploy.main()
|
||||
self.assert_old_untouched()
|
||||
|
||||
def test_mismatched_key_is_rejected(self):
|
||||
(self.source / 'cdis.cn.key').write_bytes(self.ca_key.read_bytes())
|
||||
(self.source / 'example.com.key').write_bytes(self.ca_key.read_bytes())
|
||||
with self.assertRaisesRegex(RuntimeError, '不匹配'):
|
||||
deploy.main()
|
||||
self.assert_old_untouched()
|
||||
@@ -317,7 +317,7 @@ class DeploymentTests(unittest.TestCase):
|
||||
self.assertEqual((self.target / 'custom.crt').read_bytes(), self.old.read_bytes())
|
||||
|
||||
def test_nginx_still_using_candidate_is_rejected(self):
|
||||
self.config += 'ssl_certificate ' + str(self.source / 'cdis.cn.crt') + ';\n'
|
||||
self.config += 'ssl_certificate ' + str(self.source / 'example.com.crt') + ';\n'
|
||||
with self.assertRaisesRegex(RuntimeError, '签发目录'):
|
||||
deploy.main()
|
||||
self.assert_old_untouched()
|
||||
@@ -353,7 +353,7 @@ class DeploymentTests(unittest.TestCase):
|
||||
self.live.assert_called_with(deploy.fingerprint(self.old))
|
||||
|
||||
def test_unreadable_private_permissions_are_rejected(self):
|
||||
(self.source / 'cdis.cn.key').chmod(0o644)
|
||||
(self.source / 'example.com.key').chmod(0o644)
|
||||
with self.assertRaisesRegex(RuntimeError, '权限'):
|
||||
deploy.main()
|
||||
self.assert_old_untouched()
|
||||
@@ -381,7 +381,7 @@ class DeploymentTests(unittest.TestCase):
|
||||
validate = deploy.validate
|
||||
|
||||
def mutate(snapshot):
|
||||
(self.source / 'cdis.cn.crt').write_bytes(b'changed-after-snapshot')
|
||||
(self.source / 'example.com.crt').write_bytes(b'changed-after-snapshot')
|
||||
validate(snapshot)
|
||||
|
||||
with patch.object(deploy, 'validate', side_effect=mutate):
|
||||
@@ -400,7 +400,7 @@ class DeploymentTests(unittest.TestCase):
|
||||
for name in ('client_body', 'proxy', 'fastcgi', 'uwsgi', 'scgi'))
|
||||
+ 'server {\n'
|
||||
+ 'listen 127.0.0.1:18443 ssl;\nlisten 127.0.0.1:18002 ssl;\n'
|
||||
+ 'server_name mail.cdis.cn;\n' + self.config
|
||||
+ 'server_name mail.example.com;\n' + self.config
|
||||
+ 'location / { return 200 "ready"; }\n}\n}\n', encoding='utf-8')
|
||||
arguments = ('nginx', '-c', str(configuration), '-p', str(self.directory))
|
||||
|
||||
@@ -430,7 +430,7 @@ class DeploymentTests(unittest.TestCase):
|
||||
deploy.main()
|
||||
self.real_verify(deploy.fingerprint(self.new))
|
||||
self.assertIsNone(process.poll())
|
||||
(self.source / 'cdis.cn.crt').write_bytes(self.old.read_bytes())
|
||||
(self.source / 'example.com.crt').write_bytes(self.old.read_bytes())
|
||||
attempted = False
|
||||
|
||||
def fail_after_live_update(expected):
|
||||
|
||||
@@ -14,7 +14,7 @@ BASE = Path(__file__).resolve().parent
|
||||
SCRIPTS = BASE if (BASE / 'renew_certificate.py').exists() else BASE.parents[1] / 'deploy/nginx'
|
||||
sys.path.insert(0, str(SCRIPTS))
|
||||
if os.name == 'posix':
|
||||
with patch.dict(os.environ, {'SMAIL_MAIL_DOMAIN': 'cdis.cn', 'SMAIL_WEB_DOMAIN': 'web.cdis.cn'}):
|
||||
with patch.dict(os.environ, {'SMAIL_MAIL_DOMAIN': 'example.com', 'SMAIL_WEB_DOMAIN': 'web.example.com'}):
|
||||
import renew_certificate as renew
|
||||
else:
|
||||
renew = None
|
||||
@@ -31,7 +31,7 @@ class WebrootTests(unittest.TestCase):
|
||||
path.chmod(0o755)
|
||||
for context in (patch.object(renew, 'WEBROOT', self.webroot),
|
||||
patch.object(renew, 'ROOT', self.directory),
|
||||
patch.object(renew, 'DOMAINS', ('cdis.cn', 'web.cdis.cn')),
|
||||
patch.object(renew, 'DOMAINS', ('example.com', 'web.example.com')),
|
||||
patch.dict(os.environ, {'SMAIL_ACME_CHALLENGE': 'http'}, clear=True)):
|
||||
context.start()
|
||||
self.addCleanup(context.stop)
|
||||
@@ -75,7 +75,7 @@ class WebrootTests(unittest.TestCase):
|
||||
self.assertEqual(renew.challenge_arguments(), ['--http', '--http.webroot', str(self.webroot)])
|
||||
|
||||
def test_wildcard_certificate_rejects_http_challenge(self):
|
||||
with patch.object(renew, 'DOMAINS', ('cdis.cn', '*.cdis.cn')):
|
||||
with patch.object(renew, 'DOMAINS', ('example.com', '*.example.com')):
|
||||
with self.assertRaisesRegex(RuntimeError, '泛域名证书必须使用 DNS 验证'):
|
||||
renew.challenge_arguments()
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class DomainAcceptanceTest(unittest.TestCase):
|
||||
self.assertIn("DOMAINS = (MAIL_DOMAIN, '*.' + MAIL_DOMAIN)", CERTIFICATE)
|
||||
self.assertIn("configured_domain('SMAIL_MAIL_DOMAIN')", CERTIFICATE)
|
||||
self.assertIn("configured_domain('SMAIL_WEB_DOMAIN')", CERTIFICATE)
|
||||
self.assertNotIn('cdis.cn', CERTIFICATE)
|
||||
self.assertNotRegex(CERTIFICATE, r"(?i)(?:[a-z0-9-]+\.)+(?:cn|com|net)")
|
||||
self.assertIn("any(domain.startswith('*.') for domain in DOMAINS)", RENEWAL)
|
||||
self.assertIn('DOMAINS = deploy.DOMAINS', RENEWAL)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import verify_nginx_tls as verify
|
||||
|
||||
|
||||
class RedirectAcceptanceTest(unittest.TestCase):
|
||||
expected = 'https://web.cdis.cn/acceptance?x=1'
|
||||
expected = 'https://web.example.com/acceptance?x=1'
|
||||
|
||||
def check(self, first, second):
|
||||
results = {'checks': []}
|
||||
@@ -29,12 +29,12 @@ class RedirectAcceptanceTest(unittest.TestCase):
|
||||
self.assertEqual(self.check(self.response(), self.response()), [])
|
||||
|
||||
def test_internal_https_port_is_failure(self):
|
||||
failures = self.check(self.response(), self.response('https://web.cdis.cn:8002/acceptance?x=1'))
|
||||
failures = self.check(self.response(), self.response('https://web.example.com:8002/acceptance?x=1'))
|
||||
self.assertEqual(len(failures), 1)
|
||||
self.assertEqual(failures[0]['port'], 8001)
|
||||
|
||||
def test_public_port_does_not_skip_validation(self):
|
||||
failures = self.check(self.response('http://web.cdis.cn/acceptance?x=1'), self.response())
|
||||
failures = self.check(self.response('http://web.example.com/acceptance?x=1'), self.response())
|
||||
self.assertEqual([item['port'] for item in failures], [80])
|
||||
|
||||
def test_missing_location_records_failure(self):
|
||||
@@ -46,7 +46,7 @@ class RedirectAcceptanceTest(unittest.TestCase):
|
||||
self.assertEqual(failures[0]['actualStatus'], 200)
|
||||
|
||||
def test_path_and_query_must_be_preserved(self):
|
||||
for location in ('https://web.cdis.cn/', 'https://web.cdis.cn/acceptance',
|
||||
for location in ('https://web.example.com/', 'https://web.example.com/acceptance',
|
||||
'https://other.invalid/acceptance?x=1'):
|
||||
with self.subTest(location=location):
|
||||
self.assertTrue(self.check(self.response(), self.response(location)))
|
||||
|
||||
@@ -4,6 +4,7 @@ from datetime import datetime, timezone
|
||||
import hashlib
|
||||
import http.client
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import smtplib
|
||||
import socket
|
||||
@@ -11,7 +12,19 @@ import ssl
|
||||
import subprocess
|
||||
|
||||
|
||||
HOST = 'web.cdis.cn'
|
||||
def required_domain(name):
|
||||
value = os.environ.get(name, '').strip().lower()
|
||||
if not value:
|
||||
raise RuntimeError(f'?????????? {name}')
|
||||
return value
|
||||
|
||||
|
||||
MAIL_DOMAIN = required_domain('SMAIL_MAIL_DOMAIN')
|
||||
WEB_DOMAIN = required_domain('SMAIL_WEB_DOMAIN')
|
||||
SMTP_DOMAIN = required_domain('SMAIL_SMTP_DOMAIN')
|
||||
IMAP_DOMAIN = required_domain('SMAIL_IMAP_DOMAIN')
|
||||
POP_DOMAIN = required_domain('SMAIL_POP_DOMAIN')
|
||||
HOST = WEB_DOMAIN
|
||||
CONTEXT = ssl.create_default_context()
|
||||
|
||||
|
||||
@@ -47,9 +60,9 @@ def main():
|
||||
leaf = subprocess.run(['openssl', 'x509', '-in', '/opt/smail/ssl/custom.crt', '-outform', 'DER'],
|
||||
check=True, capture_output=True).stdout
|
||||
expected = hashlib.sha256(leaf).hexdigest()
|
||||
for port, host in [(443, HOST), (443, 'cdis.cn'), (443, 'mail.cdis.cn'),
|
||||
(8002, HOST), (465, 'smtp.cdis.cn'),
|
||||
(993, 'imap.cdis.cn'), (995, 'pop.cdis.cn')]:
|
||||
for port, host in [(443, HOST), (443, MAIL_DOMAIN), (443, SMTP_DOMAIN),
|
||||
(8002, HOST), (465, SMTP_DOMAIN),
|
||||
(993, IMAP_DOMAIN), (995, POP_DOMAIN)]:
|
||||
with socket.create_connection(('127.0.0.1', port), timeout=10) as raw:
|
||||
with CONTEXT.wrap_socket(raw, server_hostname=host) as stream:
|
||||
actual = hashlib.sha256(stream.getpeercert(binary_form=True)).hexdigest()
|
||||
@@ -59,7 +72,7 @@ def main():
|
||||
for port in (25, 587):
|
||||
with smtplib.SMTP(timeout=10) as client:
|
||||
assert client.connect('127.0.0.1', port)[0] == 220
|
||||
client._host = 'smtp.cdis.cn'
|
||||
client._host = SMTP_DOMAIN
|
||||
assert client.ehlo('localhost')[0] == 250
|
||||
assert not client.has_extn('auth'), 'plaintext AUTH advertised'
|
||||
assert client.has_extn('starttls')
|
||||
@@ -87,7 +100,7 @@ def main():
|
||||
raise AssertionError('unknown SNI accepted')
|
||||
root = json.loads(Path('/opt/smail/config/config.json').read_text())
|
||||
assert root['http']['port'] == 8001 and root['http']['httpsPort'] == 8002
|
||||
assert root['security']['webAuthnRpOrigins'] == ['https://web.cdis.cn']
|
||||
assert root['security']['webAuthnRpOrigins'] == ['https://' + WEB_DOMAIN]
|
||||
results['fingerprintSHA256'] = expected
|
||||
results['status'] = 'failed' if results['failures'] else 'passed'
|
||||
print(json.dumps(results, ensure_ascii=False, indent=2))
|
||||
|
||||
@@ -42,7 +42,7 @@ def main():
|
||||
args = parser.parse_args()
|
||||
if not args.confirm_staging_challenge or os.geteuid() != 0 or run('hostname') != 'ikun2':
|
||||
parser.error('只允许在 47 服务器明确执行测试 CA 的全新 HTTP 挑战')
|
||||
if '*.cdis.cn' in renew.DOMAINS:
|
||||
if any(domain.startswith('*.') for domain in renew.DOMAINS):
|
||||
parser.error('当前泛域名证书必须使用 DNS-01,不能执行 HTTP-01 演练')
|
||||
if file_state(CONFIG)['sha256'] != CONFIG_SHA:
|
||||
parser.error('Nginx 配置与已审查模板不符,停止演练')
|
||||
@@ -80,7 +80,7 @@ def main():
|
||||
Path('/usr/local/libexec/smail-acme/deploy_certificate.py'),
|
||||
Path('/etc/systemd/system/smail-certificate-renew.service')]
|
||||
protected.extend(sorted(Path('/etc/nginx/conf.d').glob('*.conf')))
|
||||
protected.extend(sorted(Path('/var/lib/smail-acme-tls/certificates').glob('cdis.cn.*')))
|
||||
protected.extend(sorted(Path('/var/lib/smail-acme-tls/certificates').glob(f'{renew.deploy.MAIL_DOMAIN}.*')))
|
||||
before = {str(path): file_state(path) for path in protected}
|
||||
before_services = service_state()
|
||||
challenge_dir = renew.WEBROOT / '.well-known/acme-challenge'
|
||||
@@ -92,7 +92,7 @@ def main():
|
||||
stop = threading.Event()
|
||||
|
||||
def sample():
|
||||
for host in ('mail.cdis.cn', 'web.cdis.cn'):
|
||||
for host in (renew.deploy.VERIFY_HOSTNAMES[0], renew.deploy.CERTIFICATE_SNI):
|
||||
value = {'host': host, 'timeUTC': datetime.now(timezone.utc).isoformat()}
|
||||
try:
|
||||
value['bytes'] = len(monitor.request(host, 443))
|
||||
@@ -135,8 +135,8 @@ def main():
|
||||
result = subprocess.run(command, stdout=log, stderr=subprocess.STDOUT, timeout=630)
|
||||
report['exitCode'] = result.returncode
|
||||
assert result.returncode == 0, '全新 HTTP 挑战失败,日志已保留'
|
||||
certificate = state / 'certificates/cdis.cn.crt'
|
||||
key = state / 'certificates/cdis.cn.key'
|
||||
certificate = state / f'certificates/{renew.deploy.MAIL_DOMAIN}.crt'
|
||||
key = state / f'certificates/{renew.deploy.MAIL_DOMAIN}.key'
|
||||
public_cert = run('openssl', 'x509', '-in', str(certificate), '-pubkey', '-noout')
|
||||
public_key = run('openssl', 'pkey', '-in', str(key), '-pubout')
|
||||
assert public_cert == public_key
|
||||
|
||||
@@ -19,7 +19,7 @@ dkim_pub = ''.join(pub_lines)
|
||||
dkim_val = 'v=DKIM1; k=rsa; p=' + dkim_pub
|
||||
print('DKIM Value:', dkim_val)
|
||||
|
||||
dmarc_val = 'v=DMARC1; p=quarantine; rua=mailto:admin@solit.cn'
|
||||
dmarc_val = 'v=DMARC1; p=quarantine; rua=mailto:admin@example.com'
|
||||
print('DMARC Value:', dmarc_val)
|
||||
|
||||
def aliyun_request(params):
|
||||
@@ -44,7 +44,7 @@ def aliyun_request(params):
|
||||
with urllib.request.urlopen(req) as response:
|
||||
return json.loads(response.read().decode('utf-8'))
|
||||
|
||||
records = aliyun_request({'Action': 'DescribeDomainRecords', 'DomainName': 'solit.cn', 'PageSize': 50})
|
||||
records = aliyun_request({'Action': 'DescribeDomainRecords', 'DomainName': 'example.com', 'PageSize': 50})
|
||||
existing = { (r.get('RR'), r.get('Type')): r.get('RecordId') for r in records.get('DomainRecords', {}).get('Record', []) }
|
||||
print('Existing RRs:', list(existing.keys()))
|
||||
|
||||
@@ -52,7 +52,7 @@ if ('_dmarc', 'TXT') not in existing:
|
||||
print('Adding _dmarc...')
|
||||
res = aliyun_request({
|
||||
'Action': 'AddDomainRecord',
|
||||
'DomainName': 'solit.cn',
|
||||
'DomainName': 'example.com',
|
||||
'RR': '_dmarc',
|
||||
'Type': 'TXT',
|
||||
'Value': dmarc_val,
|
||||
@@ -66,7 +66,7 @@ if ('default._domainkey', 'TXT') not in existing:
|
||||
print('Adding default._domainkey...')
|
||||
res = aliyun_request({
|
||||
'Action': 'AddDomainRecord',
|
||||
'DomainName': 'solit.cn',
|
||||
'DomainName': 'example.com',
|
||||
'RR': 'default._domainkey',
|
||||
'Type': 'TXT',
|
||||
'Value': dkim_val,
|
||||
|
||||
@@ -32,9 +32,9 @@ def aliyun_request(params):
|
||||
|
||||
dkim_pub = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm1F4k0SRUf0aAkIAJewM/oNzARx0XJjCXbA+HZNpqWg0rFpmGzNUsdXaD6Lw3VGok9P2JaE2t8wQxdIqZGX8f1WjXSEYkN2jv4mY2MTECy4Git8gwlwgXG4oBNcfdQ4MXJj+5YYRuqxAZPKhVoJgWbZwpHWmgdoKIoPHJVBRZQ00+K18WqYJC+kXQYGiB6+ztbYIhlZlvgoaPcvApMJE7TdhCulHKSG0DSz+lX4GaYzxGUZuGgKIb5lUBeatSsKsM8WH2eNG2NP+zS/HIdWsppkUh6u4m8V+8K3ieMENPxOsAJ9DSg1GFtCf1WU7KqTmUeQsApZOxbaHWn0W+6nfjwIDAQAB'
|
||||
dkim_val = 'v=DKIM1; k=rsa; p=' + dkim_pub
|
||||
dmarc_val = 'v=DMARC1; p=quarantine; rua=mailto:admin@solit.cn'
|
||||
dmarc_val = 'v=DMARC1; p=quarantine; rua=mailto:admin@example.com'
|
||||
|
||||
records = aliyun_request({'Action': 'DescribeDomainRecords', 'DomainName': 'solit.cn', 'PageSize': 50})
|
||||
records = aliyun_request({'Action': 'DescribeDomainRecords', 'DomainName': 'example.com', 'PageSize': 50})
|
||||
existing = { (r.get('RR'), r.get('Type')): r.get('RecordId') for r in records.get('DomainRecords', {}).get('Record', []) }
|
||||
print('Existing RRs:', list(existing.keys()))
|
||||
|
||||
@@ -42,7 +42,7 @@ if ('_dmarc', 'TXT') not in existing:
|
||||
print('Adding _dmarc...')
|
||||
res = aliyun_request({
|
||||
'Action': 'AddDomainRecord',
|
||||
'DomainName': 'solit.cn',
|
||||
'DomainName': 'example.com',
|
||||
'RR': '_dmarc',
|
||||
'Type': 'TXT',
|
||||
'Value': dmarc_val,
|
||||
@@ -54,7 +54,7 @@ if ('default._domainkey', 'TXT') not in existing:
|
||||
print('Adding default._domainkey...')
|
||||
res = aliyun_request({
|
||||
'Action': 'AddDomainRecord',
|
||||
'DomainName': 'solit.cn',
|
||||
'DomainName': 'example.com',
|
||||
'RR': 'default._domainkey',
|
||||
'Type': 'TXT',
|
||||
'Value': dkim_val,
|
||||
|
||||
@@ -38,12 +38,12 @@ def aliyun_request(params):
|
||||
|
||||
dkim_pub = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm1F4k0SRUf0aAkIAJewM/oNzARx0XJjCXbA+HZNpqWg0rFpmGzNUsdXaD6Lw3VGok9P2JaE2t8wQxdIqZGX8f1WjXSEYkN2jv4mY2MTECy4Git8gwlwgXG4oBNcfdQ4MXJj+5YYRuqxAZPKhVoJgWbZwpHWmgdoKIoPHJVBRZQ00+K18WqYJC+kXQYGiB6+ztbYIhlZlvgoaPcvApMJE7TdhCulHKSG0DSz+lX4GaYzxGUZuGgKIb5lUBeatSsKsM8WH2eNG2NP+zS/HIdWsppkUh6u4m8V+8K3ieMENPxOsAJ9DSg1GFtCf1WU7KqTmUeQsApZOxbaHWn0W+6nfjwIDAQAB'
|
||||
dkim_val = 'v=DKIM1; k=rsa; p=' + dkim_pub
|
||||
dmarc_val = 'v=DMARC1; p=quarantine; rua=mailto:admin@solit.cn'
|
||||
dmarc_val = 'v=DMARC1; p=quarantine; rua=mailto:admin@example.com'
|
||||
|
||||
print('--- 添加 _dmarc ---')
|
||||
res_dmarc = aliyun_request({
|
||||
'Action': 'AddDomainRecord',
|
||||
'DomainName': 'solit.cn',
|
||||
'DomainName': 'example.com',
|
||||
'RR': '_dmarc',
|
||||
'Type': 'TXT',
|
||||
'Value': dmarc_val,
|
||||
@@ -54,7 +54,7 @@ print('Success:', res_dmarc)
|
||||
print('--- 添加 default._domainkey ---')
|
||||
res_dkim = aliyun_request({
|
||||
'Action': 'AddDomainRecord',
|
||||
'DomainName': 'solit.cn',
|
||||
'DomainName': 'example.com',
|
||||
'RR': 'default._domainkey',
|
||||
'Type': 'TXT',
|
||||
'Value': dkim_val,
|
||||
|
||||
@@ -26,8 +26,8 @@ def aliyun_request(params):
|
||||
with urllib.request.urlopen(req) as response:
|
||||
return json.loads(response.read().decode('utf-8'))
|
||||
|
||||
records = aliyun_request({'Action': 'DescribeDomainRecords', 'DomainName': 'solit.cn', 'PageSize': 50})
|
||||
print('Total records in solit.cn:', records.get('TotalCount'))
|
||||
records = aliyun_request({'Action': 'DescribeDomainRecords', 'DomainName': 'example.com', 'PageSize': 50})
|
||||
print('Total records in example.com:', records.get('TotalCount'))
|
||||
for r in records.get('DomainRecords', {}).get('Record', []):
|
||||
rr = r.get('RR')
|
||||
t = r.get('Type')
|
||||
|
||||
@@ -7,13 +7,13 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -8,20 +8,20 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
page.locator('button.login-btn').click()
|
||||
page.wait_for_timeout(2500)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 打印页面上的 sender 相关信息
|
||||
@@ -31,7 +31,7 @@ with sync_playwright() as p:
|
||||
# 尝试用正确的选择器选 input
|
||||
input_elem = page.locator('.border-less-select input').first
|
||||
input_elem.click()
|
||||
page.keyboard.type('testuser2@solit.cn')
|
||||
page.keyboard.type('testuser2@example.com')
|
||||
page.wait_for_timeout(500)
|
||||
page.keyboard.press('Enter')
|
||||
page.wait_for_timeout(500)
|
||||
|
||||
@@ -7,13 +7,13 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -8,7 +8,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -16,20 +16,20 @@ with sync_playwright() as p:
|
||||
|
||||
page.on('response', lambda res: print('[API RES]', res.status, res.url, res.text()[:200]) if 'email' in res.url or 'send' in res.url else None)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
page.locator('button.login-btn').click()
|
||||
page.wait_for_timeout(3000)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 填写收件人
|
||||
to_input = page.locator('.border-less-select input').first
|
||||
to_input.click()
|
||||
to_input.fill('testuser2@solit.cn')
|
||||
to_input.fill('testuser2@example.com')
|
||||
page.wait_for_timeout(500)
|
||||
# 模拟键盘回车和下拉项选择
|
||||
page.keyboard.press('Enter')
|
||||
|
||||
@@ -62,7 +62,7 @@ def wait_ready():
|
||||
result = subprocess.run([
|
||||
'curl', '--silent', '--fail', '--max-time', '2', '--noproxy', '*',
|
||||
'--cacert', str(ROOT / 'ssl/custom.crt'), '--resolve',
|
||||
'web.solit.cn:443:127.0.0.1', 'https://web.solit.cn/api/ping',
|
||||
'web.example.com:443:127.0.0.1', 'https://web.example.com/api/ping',
|
||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
if result.returncode == 0 and run('systemctl', 'is-active', 'smail.service') == 'active':
|
||||
return
|
||||
|
||||
@@ -20,7 +20,7 @@ from database_inventory import sqlite_inventory
|
||||
ROOT = Path('/opt/smail')
|
||||
DATABASE_NAME = 'smail.db'
|
||||
RUN = time.strftime('%Y%m%d-%H%M%S')
|
||||
DOMAIN = 'solit.cn'
|
||||
DOMAIN = 'example.com'
|
||||
BODY = '内部25端口中文正文验收:邮件必须真实入库,并且只属于指定收件人。'
|
||||
ATTACHMENT = '中文附件内容,内部收信验收。'.encode('utf-8')
|
||||
|
||||
@@ -43,7 +43,7 @@ def connect():
|
||||
assert code in (502, 523, 538), f'plaintext AUTH not rejected: {code}'
|
||||
# 仅本次客户端信任部署证书,仍校验主机名和证书有效期。
|
||||
context = ssl.create_default_context(cafile=str(ROOT / 'ssl/custom.crt'))
|
||||
client._host = 'mail.solit.cn'
|
||||
client._host = 'mail.example.com'
|
||||
client.starttls(context=context)
|
||||
client.ehlo('internal-check.invalid')
|
||||
assert client.sock.getpeername()[0] == '127.0.0.1'
|
||||
@@ -54,7 +54,7 @@ def connect():
|
||||
def deliver(label, recipients, multipart=False):
|
||||
message = EmailMessage(policy=SMTP)
|
||||
message['From'] = '内部验收 <probe@internal-check.invalid>'
|
||||
message['To'] = 'remotecheck@solit.cn'
|
||||
message['To'] = 'remotecheck@example.com'
|
||||
message['Subject'] = f'内部25端口验收 {label} {RUN}'
|
||||
message['Message-ID'] = f'<internal-{RUN}-{label}@internal-check.invalid>'
|
||||
message['Date'] = formatdate(localtime=False, usegmt=True)
|
||||
@@ -94,10 +94,10 @@ def main():
|
||||
assert set(users) == {'admin', 'remotecheck'}
|
||||
results = []
|
||||
cases = [
|
||||
('text', ['remotecheck@solit.cn'], False, {users['remotecheck']}),
|
||||
('multipart', ['remotecheck@solit.cn', 'admin@solit.cn'], True, set(users.values())),
|
||||
('admin_only', ['admin@solit.cn'], True, {users['admin']}),
|
||||
('unknown', [f'missing-{RUN}@solit.cn'], False, {users['admin']}),
|
||||
('text', ['remotecheck@example.com'], False, {users['remotecheck']}),
|
||||
('multipart', ['remotecheck@example.com', 'admin@example.com'], True, set(users.values())),
|
||||
('admin_only', ['admin@example.com'], True, {users['admin']}),
|
||||
('unknown', [f'missing-{RUN}@example.com'], False, {users['admin']}),
|
||||
('relay', ['nobody@external-check.invalid'], False, {users['admin']}),
|
||||
]
|
||||
for label, recipients, multipart, expected_users in cases:
|
||||
|
||||
@@ -97,7 +97,7 @@ def main():
|
||||
probe = subprocess.run([
|
||||
'nsenter', '--target', pid, '--net', 'curl', '--silent', '--fail', '--max-time', '2',
|
||||
'--noproxy', '*', '--cacert', str(restored / 'ssl/custom.crt'),
|
||||
'--resolve', 'web.solit.cn:443:127.0.0.1', 'https://web.solit.cn/api/ping',
|
||||
'--resolve', 'web.example.com:443:127.0.0.1', 'https://web.example.com/api/ping',
|
||||
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
if probe.returncode == 0:
|
||||
ready = True
|
||||
@@ -112,14 +112,14 @@ import smtplib,ssl,sys
|
||||
from email.message import EmailMessage
|
||||
message=EmailMessage()
|
||||
message['From']='restore@review.invalid'
|
||||
message['To']='remotecheck@solit.cn'
|
||||
message['To']='remotecheck@example.com'
|
||||
message['Subject']='restore-review'
|
||||
message['Message-ID']='<restore-'+sys.argv[2]+'@review.invalid>'
|
||||
message.set_content('restore database write check')
|
||||
context=ssl.create_default_context(cafile=sys.argv[1])
|
||||
with smtplib.SMTP('127.0.0.1',25,timeout=20) as client:
|
||||
client.ehlo('restore.invalid')
|
||||
client._host='mail.solit.cn'
|
||||
client._host='mail.example.com'
|
||||
client.starttls(context=context)
|
||||
client.ehlo('restore.invalid')
|
||||
assert not client.send_message(message)
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -19,7 +19,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 1. 登录
|
||||
print('--- Step 1: Login ---')
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
@@ -30,7 +30,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 2. 验证收件箱安全提示
|
||||
print('--- Step 2: Inbox Security Tags ---')
|
||||
page.goto('https://mail.solit.cn/#/list?tag=0', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/list?tag=0', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
page.screenshot(path=os.path.join(output_dir, '02_inbox_list.png'))
|
||||
|
||||
@@ -41,7 +41,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 3. 验证发件箱状态标签与错误详情
|
||||
print('--- Step 3: Outbox Status Tags & Error Dialog ---')
|
||||
page.goto('https://mail.solit.cn/#/list?tag=1', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/list?tag=1', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
page.screenshot(path=os.path.join(output_dir, '03_outbox_list.png'))
|
||||
success_tags = page.locator('.mail-status-tags .el-tag--success')
|
||||
@@ -61,7 +61,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 4. 验证写信页联系人
|
||||
print('--- Step 4: Editer Page Contacts ---')
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
page.screenshot(path=os.path.join(output_dir, '05_editer_page.png'))
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -11,13 +11,13 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -20,7 +20,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -32,8 +32,8 @@ with sync_playwright() as p:
|
||||
write_log('=== 开始端到端自动化测试:发件前新增刷新按钮与定时刷新机制 ===')
|
||||
|
||||
# 步骤 1:访问登录页
|
||||
write_log('1. 打开登录页面 https://mail.solit.cn/#/login')
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
write_log('1. 打开登录页面 https://mail.example.com/#/login')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
page.screenshot(path=os.path.join(output_dir, '01_login_page.png'))
|
||||
write_log(' 登录页面加载成功并已截图')
|
||||
|
||||
@@ -107,7 +107,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 步骤 6:检查未登录状态下的刷新按钮及轮询
|
||||
write_log('6. 测试退出登录后未登录状态的表现')
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
page.wait_for_timeout(1500)
|
||||
page.screenshot(path=os.path.join(output_dir, '06_logout_page.png'))
|
||||
|
||||
|
||||
@@ -39,15 +39,15 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
# 1. 访问登录页面
|
||||
write_log('1. 打开登录页面 https://mail.solit.cn/#/login')
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
write_log('1. 打开登录页面 https://mail.example.com/#/login')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
page.wait_for_timeout(1000)
|
||||
page.screenshot(path=os.path.join(output_dir, '20_login_page.png'))
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -19,7 +19,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 1. 登录 xuans
|
||||
print('1. 登录 xuans...')
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
@@ -28,7 +28,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 2. 检查收件箱中的信任发件人交互
|
||||
print('2. 检查收件箱信任操作...')
|
||||
page.goto('https://mail.solit.cn/#/list?tag=0', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/list?tag=0', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
danger_tags = page.locator('.mail-status-tags .el-tag--danger')
|
||||
@@ -47,13 +47,13 @@ with sync_playwright() as p:
|
||||
|
||||
# 3. 检查发件箱标签
|
||||
print('3. 检查发件箱...')
|
||||
page.goto('https://mail.solit.cn/#/list?tag=%7B%22type%22%3A1%2C%22status%22%3A-1%7D', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/list?tag=%7B%22type%22%3A1%2C%22status%22%3A-1%7D', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
page.screenshot(path=os.path.join(output_dir, '32_outbox_view.png'))
|
||||
|
||||
# 4. 进入写信页,测试删除联系人
|
||||
print('4. 写信页测试删除联系人...')
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
wrapper = page.locator('.border-less-select .el-select__wrapper')
|
||||
@@ -69,14 +69,14 @@ with sync_playwright() as p:
|
||||
|
||||
# 5. 验证多租户隔离:登录 testuser2
|
||||
print('5. 验证多租户隔离...')
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('testuser2')
|
||||
inputs.nth(1).fill('12345678')
|
||||
page.locator('button.login-btn').click()
|
||||
page.wait_for_timeout(2500)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
wrapper = page.locator('.border-less-select .el-select__wrapper')
|
||||
|
||||
@@ -45,12 +45,12 @@ with sync_playwright() as p:
|
||||
page.screenshot(path=os.path.join(test_log_dir, 'step3_domain.png'))
|
||||
|
||||
# Step 3: 设置域名
|
||||
print('设置域名: web=mail.solit.cn, smtp=solit.cn...')
|
||||
print('设置域名: web=mail.example.com, smtp=example.com...')
|
||||
domain_inputs = page.locator('.form input')
|
||||
print('域名页输入框数量:', domain_inputs.count())
|
||||
if domain_inputs.count() >= 2:
|
||||
domain_inputs.nth(0).fill('mail.solit.cn')
|
||||
domain_inputs.nth(1).fill('solit.cn')
|
||||
domain_inputs.nth(0).fill('mail.example.com')
|
||||
domain_inputs.nth(1).fill('example.com')
|
||||
|
||||
time.sleep(1)
|
||||
page.screenshot(path=os.path.join(test_log_dir, 'step3_domain_filled.png'))
|
||||
|
||||
@@ -51,10 +51,10 @@ with sync_playwright() as p:
|
||||
domain_inputs = page.locator('.ctn input')
|
||||
print('域名输入框数量:', domain_inputs.count())
|
||||
if domain_inputs.count() >= 2:
|
||||
domain_inputs.nth(0).fill('mail.solit.cn')
|
||||
domain_inputs.nth(1).fill('solit.cn')
|
||||
domain_inputs.nth(0).fill('mail.example.com')
|
||||
domain_inputs.nth(1).fill('example.com')
|
||||
elif domain_inputs.count() == 1:
|
||||
domain_inputs.first.fill('solit.cn')
|
||||
domain_inputs.first.fill('example.com')
|
||||
|
||||
time.sleep(1)
|
||||
page.screenshot(path=os.path.join(test_log_dir, 'step3_domain_filled.png'))
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
"""读取由用户显式提供的远程验收参数。"""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def required(name):
|
||||
value = os.environ.get(name, '').strip()
|
||||
if not value:
|
||||
raise RuntimeError(f'?????????? {name}')
|
||||
return value
|
||||
|
||||
|
||||
def optional(name, default=''):
|
||||
return os.environ.get(name, default).strip()
|
||||
|
||||
|
||||
WEB_URL = required('SMAIL_WEB_URL')
|
||||
MAIL_DOMAIN = required('SMAIL_MAIL_DOMAIN')
|
||||
MAIL_HOST = required('SMAIL_MAIL_HOST')
|
||||
ADMIN_ACCOUNT = required('SMAIL_ADMIN_ACCOUNT')
|
||||
ADMIN_PASSWORD = required('SMAIL_ADMIN_PASSWORD')
|
||||
SMTP_HOST = required('SMAIL_RELAY_HOST')
|
||||
SMTP_PORT = int(required('SMAIL_RELAY_PORT'))
|
||||
SMTP_USERNAME = required('SMAIL_RELAY_USERNAME')
|
||||
SMTP_PASSWORD = required('SMAIL_RELAY_PASSWORD')
|
||||
FROM_ADDRESS = required('SMAIL_FROM_ADDRESS')
|
||||
|
||||
@@ -16,7 +16,7 @@ def prepare_nginx(target, root, template):
|
||||
assert 'proxy_pass https://127.0.0.1:8002;' in source
|
||||
assert 'proxy_ssl_verify on;' in source
|
||||
assert 'proxy_set_header X-Forwarded-For $remote_addr;' in source
|
||||
site = source.replace('solit.cn', 'runtime.invalid')
|
||||
site = source.replace('example.com', 'runtime.invalid')
|
||||
site = site.replace('/opt/smail/ssl/custom.crt', str(root / 'ssl/runtime.crt'))
|
||||
site = site.replace('/opt/smail/ssl/custom.key', str(root / 'ssl/runtime.key'))
|
||||
site = site.replace('/etc/ssl/certs/ca-certificates.crt', str(root / 'ssl/runtime.crt'))
|
||||
|
||||
@@ -4,25 +4,28 @@ ssh.set_missing_host_key_policy(paramiko.RejectPolicy())
|
||||
from remote_ssh import connect_remote
|
||||
connect_remote(ssh)
|
||||
|
||||
s = '''import smtplib, ssl
|
||||
s = '''import os
|
||||
import smtplib, ssl
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
for target, subj in [
|
||||
('gfxezc@163.com', 'Smail DirectMail Test - Admin'),
|
||||
('xuanspark@163.com', 'Smail DirectMail Test - User'),
|
||||
('likb_blue@163.com', 'Smail DirectMail Test - SuperAdmin')
|
||||
]:
|
||||
recipients = [item.strip() for item in os.environ['SMAIL_TEST_RECIPIENTS'].split(',') if item.strip()]
|
||||
for target in recipients:
|
||||
msg = MIMEText('Smail DirectMail test outbound delivery', 'plain', 'utf-8')
|
||||
msg['From'] = 'xuans@solit.cn'
|
||||
msg['From'] = os.environ['SMAIL_FROM_ADDRESS']
|
||||
msg['To'] = target
|
||||
msg['Subject'] = subj
|
||||
msg['Subject'] = 'Smail DirectMail Test'
|
||||
|
||||
context = ssl.create_default_context()
|
||||
with smtplib.SMTP_SSL('smtpdm.aliyun.com', 465, context=context) as server:
|
||||
server.login('xuans@solit.cn', 'Solit12ABcd')
|
||||
res = server.sendmail('xuans@solit.cn', [target], msg.as_string())
|
||||
with smtplib.SMTP_SSL(
|
||||
os.environ['SMAIL_RELAY_HOST'],
|
||||
int(os.environ['SMAIL_RELAY_PORT']),
|
||||
context=context,
|
||||
) as server:
|
||||
username = os.environ['SMAIL_RELAY_USERNAME']
|
||||
server.login(username, os.environ['SMAIL_RELAY_PASSWORD'])
|
||||
res = server.sendmail(os.environ['SMAIL_FROM_ADDRESS'], [target], msg.as_string())
|
||||
print(f'Send to {target}: {res}')
|
||||
'''
|
||||
'''
|
||||
sftp = ssh.open_sftp()
|
||||
with sftp.file('/tmp/test_send_all.py', 'w') as f:
|
||||
f.write(s)
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -19,7 +19,7 @@ with sync_playwright() as p:
|
||||
|
||||
page.on('response', lambda res: print('[API]', res.status, res.url, res.text()[:250]) if 'email' in res.url or 'group' in res.url else None)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -11,8 +11,8 @@ opener = urllib.request.build_opener(urllib.request.HTTPSHandler(context=ctx), u
|
||||
login_payload = json.dumps({'account': 'xuans', 'password': '12345678'}).encode('utf-8')
|
||||
req = urllib.request.Request('https://47.108.78.12/api/v1/login', data=login_payload, headers={
|
||||
'Content-Type': 'application/json',
|
||||
'Host': 'mail.solit.cn',
|
||||
'Origin': 'https://mail.solit.cn'
|
||||
'Host': 'mail.example.com',
|
||||
'Origin': 'https://mail.example.com'
|
||||
})
|
||||
resp = opener.open(req, timeout=5)
|
||||
print('Login resp:', resp.read().decode())
|
||||
@@ -24,9 +24,9 @@ for c in cj:
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Host': 'mail.solit.cn',
|
||||
'Origin': 'https://mail.solit.cn',
|
||||
'Referer': 'https://mail.solit.cn/',
|
||||
'Host': 'mail.example.com',
|
||||
'Origin': 'https://mail.example.com',
|
||||
'Referer': 'https://mail.example.com/',
|
||||
'X-CSRF-Token': csrf_token
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ opener = urllib.request.build_opener(urllib.request.HTTPSHandler(context=ctx), u
|
||||
login_payload = json.dumps({"account": "xuans", "password": "12345678"}).encode("utf-8")
|
||||
req = urllib.request.Request("https://47.108.78.12/api/v1/login", data=login_payload, headers={
|
||||
"Content-Type": "application/json",
|
||||
"Host": "mail.solit.cn",
|
||||
"Origin": "https://mail.solit.cn"
|
||||
"Host": "mail.example.com",
|
||||
"Origin": "https://mail.example.com"
|
||||
})
|
||||
opener.open(req, timeout=5)
|
||||
|
||||
@@ -21,9 +21,9 @@ for c in cj:
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Host": "mail.solit.cn",
|
||||
"Origin": "https://mail.solit.cn",
|
||||
"Referer": "https://mail.solit.cn/",
|
||||
"Host": "mail.example.com",
|
||||
"Origin": "https://mail.example.com",
|
||||
"Referer": "https://mail.example.com/",
|
||||
"X-CSRF-Token": csrf_token
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -30,7 +30,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 1. 登录页检查忘记密码入口
|
||||
write_log('1. 打开登录页面')
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
page.screenshot(path=os.path.join(output_dir, '10_login_page_forgot_btn.png'))
|
||||
|
||||
forgot_btn = page.locator('button.forgot-password-btn, a:has-text("忘记密码")')
|
||||
@@ -39,7 +39,7 @@ with sync_playwright() as p:
|
||||
forgot_btn.first.click()
|
||||
page.wait_for_timeout(1500)
|
||||
else:
|
||||
page.goto('https://mail.solit.cn/#/forgot-password', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/forgot-password', wait_until='networkidle')
|
||||
page.wait_for_timeout(1500)
|
||||
|
||||
write_log(f' 当前页面 URL: {page.url}')
|
||||
|
||||
@@ -9,8 +9,8 @@ opener = urllib.request.build_opener(urllib.request.HTTPSHandler(context=ctx), u
|
||||
login_payload = json.dumps({"account": "xuans", "password": "12345678"}).encode("utf-8")
|
||||
req = urllib.request.Request("https://47.108.78.12/api/v1/login", data=login_payload, headers={
|
||||
"Content-Type": "application/json",
|
||||
"Host": "mail.solit.cn",
|
||||
"Origin": "https://mail.solit.cn"
|
||||
"Host": "mail.example.com",
|
||||
"Origin": "https://mail.example.com"
|
||||
})
|
||||
opener.open(req, timeout=5)
|
||||
|
||||
@@ -21,9 +21,9 @@ for c in cj:
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Host": "mail.solit.cn",
|
||||
"Origin": "https://mail.solit.cn",
|
||||
"Referer": "https://mail.solit.cn/",
|
||||
"Host": "mail.example.com",
|
||||
"Origin": "https://mail.example.com",
|
||||
"Referer": "https://mail.example.com/",
|
||||
"X-CSRF-Token": csrf_token
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -19,7 +19,7 @@ with sync_playwright() as p:
|
||||
|
||||
page.on('response', lambda res: print('[API]', res.status, res.url) if 'log' in res.url or 'audit' in res.url else None)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -11,13 +11,13 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -19,7 +19,7 @@ with sync_playwright() as p:
|
||||
|
||||
page.on('response', lambda res: print('[API]', res.status, res.url) if 'api' in res.url else None)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
@@ -27,7 +27,7 @@ with sync_playwright() as p:
|
||||
page.wait_for_timeout(3000)
|
||||
|
||||
# 查看侧边栏并点击“写邮件”或路由切换到 /editer
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
page.screenshot(path=os.path.join(test_dir, '01_editer_page.png'))
|
||||
|
||||
@@ -38,7 +38,7 @@ with sync_playwright() as p:
|
||||
# 填写收件人
|
||||
# 收件人是一个 el-select 允许输入的
|
||||
to_input = page.locator('.border-less-select input').first
|
||||
to_input.fill('testuser2@solit.cn')
|
||||
to_input.fill('testuser2@example.com')
|
||||
page.keyboard.press('Enter')
|
||||
page.wait_for_timeout(500)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
page.on("response", lambda res: print("[RES]", res.status, res.url, res.text()) if "question" in res.url else None)
|
||||
|
||||
# 登录
|
||||
page.goto("https://mail.solit.cn/#/login")
|
||||
page.goto("https://mail.example.com/#/login")
|
||||
page.wait_for_selector(".login-btn")
|
||||
inputs = page.locator(".login-content input")
|
||||
inputs.nth(0).fill("xuans")
|
||||
@@ -20,7 +20,7 @@ with sync_playwright() as p:
|
||||
page.wait_for_timeout(3000)
|
||||
|
||||
# 直接访问设置安全路由
|
||||
page.goto("https://mail.solit.cn/#/setting?tab=security")
|
||||
page.goto("https://mail.example.com/#/setting?tab=security")
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 查看当前页面按钮和文本
|
||||
|
||||
@@ -11,13 +11,13 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -11,13 +11,13 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -8,20 +8,20 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
page.locator('button.login-btn').click()
|
||||
page.wait_for_timeout(2500)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 观察 el-select 结构
|
||||
@@ -31,7 +31,7 @@ with sync_playwright() as p:
|
||||
page.wait_for_timeout(500)
|
||||
|
||||
# 打印当前 active 元素或者向页面输入
|
||||
page.keyboard.type('testuser2@solit.cn')
|
||||
page.keyboard.type('testuser2@example.com')
|
||||
page.wait_for_timeout(500)
|
||||
page.screenshot(path='test-log/typing_step1.png')
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -19,7 +19,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 登录
|
||||
print('1. 登录 xuans...')
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
@@ -28,14 +28,14 @@ with sync_playwright() as p:
|
||||
|
||||
# 打开写信页
|
||||
print('2. 前往写信页...')
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 填写收件人
|
||||
select_box = page.locator('.border-less-select')
|
||||
select_box.click()
|
||||
page.wait_for_timeout(300)
|
||||
page.keyboard.type('testuser2@solit.cn')
|
||||
page.keyboard.type('testuser2@example.com')
|
||||
page.wait_for_timeout(500)
|
||||
page.keyboard.press('Enter')
|
||||
page.wait_for_timeout(500)
|
||||
@@ -54,7 +54,7 @@ with sync_playwright() as p:
|
||||
|
||||
# 再次前往写信页,查看下拉列表
|
||||
print('4. 重新进入写信页,查看历史联系人下拉...')
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
select_box = page.locator('.border-less-select')
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -19,14 +19,14 @@ with sync_playwright() as p:
|
||||
|
||||
page.on('response', lambda res: print('[API RES]', res.status, res.url, res.text()[:200]) if 'email' in res.url or 'send' in res.url else None)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
page.locator('button.login-btn').click()
|
||||
page.wait_for_timeout(3000)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 聚焦到收件人输入框
|
||||
@@ -35,7 +35,7 @@ with sync_playwright() as p:
|
||||
page.wait_for_timeout(300)
|
||||
|
||||
to_input = page.locator('.border-less-select input').first
|
||||
to_input.fill('testuser2@solit.cn')
|
||||
to_input.fill('testuser2@example.com')
|
||||
page.wait_for_timeout(300)
|
||||
page.keyboard.press('Enter')
|
||||
page.wait_for_timeout(500)
|
||||
@@ -65,7 +65,7 @@ with sync_playwright() as p:
|
||||
print('发送后当前页面 URL:', page.url)
|
||||
|
||||
# 检查已发送列表
|
||||
page.goto('https://mail.solit.cn/#/list?tag=outbox', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/list?tag=outbox', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
page.screenshot(path=os.path.join(test_dir, '12_outbox_list.png'))
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -18,21 +18,21 @@ with sync_playwright() as p:
|
||||
page.on('pageerror', lambda err: print('[PAGE ERROR]', err))
|
||||
page.on('response', lambda res: print('[NET RES]', res.status, res.url) if '/api/' in res.url else None)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
page.locator('button.login-btn').click()
|
||||
page.wait_for_timeout(2500)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 选择收件人
|
||||
wrapper = page.locator('.border-less-select .el-select__wrapper')
|
||||
wrapper.click()
|
||||
page.wait_for_timeout(300)
|
||||
page.keyboard.type('testuser2@solit.cn')
|
||||
page.keyboard.type('testuser2@example.com')
|
||||
page.wait_for_timeout(500)
|
||||
|
||||
item = page.locator('.el-select-dropdown__item:visible').first
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -19,21 +19,21 @@ with sync_playwright() as p:
|
||||
|
||||
page.on('response', lambda res: print('[API RES]', res.status, res.url, res.text()[:200]) if 'send' in res.url else None)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
page.locator('button.login-btn').click()
|
||||
page.wait_for_timeout(3000)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 模拟真实在 el-select 内部输入并点击创建选项
|
||||
select_box = page.locator('.border-less-select')
|
||||
select_box.click()
|
||||
page.wait_for_timeout(300)
|
||||
page.keyboard.type('testuser2@solit.cn')
|
||||
page.keyboard.type('testuser2@example.com')
|
||||
page.wait_for_timeout(500)
|
||||
|
||||
# 检查下拉列表中出现的“创建”选项或按 Enter
|
||||
@@ -71,7 +71,7 @@ with sync_playwright() as p:
|
||||
print('当前页面 URL:', page.url)
|
||||
|
||||
# 检查发件箱
|
||||
page.goto('https://mail.solit.cn/#/list?tag={"type":1,"status":-1}', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/list?tag={"type":1,"status":-1}', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
page.screenshot(path=os.path.join(test_dir, '24_outbox.png'))
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ for pwd in ["12345678", "123456", "testuser2", "Password123!", "Tester123456!"]:
|
||||
login_payload = json.dumps({"account": "testuser2", "password": pwd}).encode("utf-8")
|
||||
req = urllib.request.Request("https://47.108.78.12/api/v1/login", data=login_payload, headers={
|
||||
"Content-Type": "application/json",
|
||||
"Host": "mail.solit.cn",
|
||||
"Origin": "https://mail.solit.cn"
|
||||
"Host": "mail.example.com",
|
||||
"Origin": "https://mail.example.com"
|
||||
})
|
||||
try:
|
||||
resp = opener.open(req, timeout=5)
|
||||
|
||||
@@ -11,7 +11,7 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
@@ -19,7 +19,7 @@ with sync_playwright() as p:
|
||||
|
||||
page.on('response', lambda res: print('[API]', res.status, res.url, res.text()[:200]) if 'user' in res.url else None)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -11,13 +11,13 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
|
||||
@@ -1,51 +1,56 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import requests, json
|
||||
import urllib3
|
||||
urllib3.disable_warnings()
|
||||
import json
|
||||
|
||||
s = requests.Session()
|
||||
# 47.108.78.12 80 端口
|
||||
r_login = s.post('http://47.108.78.12:80/api/login', json={'username': 'xuans', 'password': '12345678'})
|
||||
import requests
|
||||
|
||||
from runtime_inputs import (
|
||||
ADMIN_ACCOUNT,
|
||||
ADMIN_PASSWORD,
|
||||
FROM_ADDRESS,
|
||||
MAIL_DOMAIN,
|
||||
SMTP_HOST,
|
||||
SMTP_PASSWORD,
|
||||
SMTP_USERNAME,
|
||||
required,
|
||||
)
|
||||
|
||||
base_url = required('SMAIL_HTTP_URL').rstrip('/')
|
||||
session = requests.Session()
|
||||
r_login = session.post(
|
||||
base_url + '/api/login',
|
||||
json={'username': ADMIN_ACCOUNT, 'password': ADMIN_PASSWORD},
|
||||
timeout=15,
|
||||
)
|
||||
print('Login:', r_login.status_code, r_login.text)
|
||||
|
||||
r_get = s.get('http://47.108.78.12:80/api/v1/config/mail')
|
||||
r_get = session.get(base_url + '/api/v1/config/mail', timeout=15)
|
||||
print('Get mail:', r_get.status_code, r_get.text)
|
||||
|
||||
# 模拟前端发送的 validate 请求
|
||||
data = r_get.json().get('data', {})
|
||||
generation = data.get('meta', {}).get('generation', 2)
|
||||
|
||||
# 用户在前端填入的配置
|
||||
payload = json.loads(json.dumps(data))
|
||||
# 注意前端 parsePayload 会对 payload 做一些处理:
|
||||
# delete payload.relayPasswordStatus
|
||||
# if (payload.relay && 'password' in payload.relay) delete payload.relay.password
|
||||
if 'relayPasswordStatus' in payload:
|
||||
del payload['relayPasswordStatus']
|
||||
if 'relay' in payload and 'password' in payload['relay']:
|
||||
del payload['relay']['password']
|
||||
|
||||
payload['relay']['relayHost'] = 'smtpm.aliyun.com'
|
||||
payload['relay']['relayPort'] = 587
|
||||
payload['relay']['username'] = 'xuans'
|
||||
payload['relay']['from'] = 'xuans@solit.cn'
|
||||
payload['relay']['fromDomain'] = 'solit.cn'
|
||||
payload['relay']['relayHost'] = SMTP_HOST
|
||||
payload['relay']['relayPort'] = int(required('SMAIL_RELAY_PORT'))
|
||||
payload['relay']['username'] = SMTP_USERNAME
|
||||
payload['relay']['from'] = FROM_ADDRESS
|
||||
payload['relay']['fromDomain'] = MAIL_DOMAIN
|
||||
|
||||
secretChanges = {
|
||||
'relay.password': {'operation': 'replace', 'value': {'plaintext': 'Solit12ABcd'}}
|
||||
secret_changes = {
|
||||
'relay.password': {'operation': 'replace', 'value': {'plaintext': SMTP_PASSWORD}}
|
||||
}
|
||||
|
||||
req_body = {
|
||||
request_body = {
|
||||
'expectedGeneration': generation,
|
||||
'payload': payload,
|
||||
'secretChanges': secretChanges,
|
||||
'confirmation': {'confirmed': True, 'method': 'recent_auth'}
|
||||
'secretChanges': secret_changes,
|
||||
'confirmation': {'confirmed': True, 'method': 'recent_auth'},
|
||||
}
|
||||
|
||||
print('Testing validate with smtpm.aliyun.com...')
|
||||
r_val = s.post('http://47.108.78.12:80/api/v1/config/mail/validate', json=req_body)
|
||||
print('Testing validate with user-provided relay host...')
|
||||
r_val = session.post(base_url + '/api/v1/config/mail/validate', json=request_body, timeout=15)
|
||||
print('Validate res:', r_val.status_code, r_val.text)
|
||||
|
||||
# 再测一次直接 PUT (UpdateConfig)
|
||||
r_put = s.put('http://47.108.78.12:80/api/v1/config/mail', json=req_body)
|
||||
print('PUT res:', r_put.status_code, r_put.text)
|
||||
r_put = session.put(base_url + '/api/v1/config/mail', json=request_body, timeout=15)
|
||||
print('PUT res:', r_put.status_code, r_put.text)
|
||||
@@ -1,14 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import requests
|
||||
import urllib3
|
||||
urllib3.disable_warnings()
|
||||
|
||||
session = requests.Session()
|
||||
login_res = session.post('https://mail.solit.cn/api/login', json={'username': 'xuans', 'password': '12345678'}, verify=False)
|
||||
from runtime_inputs import ADMIN_ACCOUNT, ADMIN_PASSWORD, MAIL_HOST, WEB_URL
|
||||
|
||||
base_url = WEB_URL.rstrip('/')
|
||||
login_res = requests.post(
|
||||
base_url + '/api/login',
|
||||
json={'username': ADMIN_ACCOUNT, 'password': ADMIN_PASSWORD},
|
||||
timeout=15,
|
||||
)
|
||||
print('Login status:', login_res.status_code, login_res.text)
|
||||
|
||||
get_res = session.get('https://mail.solit.cn/api/v1/config/mail', verify=False)
|
||||
get_res = requests.get(base_url + '/api/v1/config/mail', timeout=15)
|
||||
print('Config mail get:', get_res.status_code, get_res.text)
|
||||
|
||||
status_res = session.get('https://mail.solit.cn/api/v1/config/status', verify=False)
|
||||
print('Config status:', status_res.status_code, status_res.text)
|
||||
status_res = requests.get(base_url + '/api/v1/config/status', timeout=15)
|
||||
print('Config status:', status_res.status_code, status_res.text)
|
||||
@@ -8,20 +8,20 @@ with sync_playwright() as p:
|
||||
args=[
|
||||
'--no-sandbox',
|
||||
'--ignore-certificate-errors',
|
||||
'--host-resolver-rules=MAP mail.solit.cn 47.108.78.12, MAP solit.cn 47.108.78.12'
|
||||
'--host-resolver-rules=MAP mail.example.com 47.108.78.12, MAP example.com 47.108.78.12'
|
||||
]
|
||||
)
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 900}, ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
inputs = page.locator('.login-content input')
|
||||
inputs.nth(0).fill('xuans')
|
||||
inputs.nth(1).fill('12345678')
|
||||
page.locator('button.login-btn').click()
|
||||
page.wait_for_timeout(2500)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/editer', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/editer', wait_until='networkidle')
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 展开下拉列表
|
||||
|
||||
@@ -18,7 +18,7 @@ with sync_playwright() as p:
|
||||
page.on('request', lambda req: print('[REQ]', req.method, req.url) if 'api' in req.url else None)
|
||||
page.on('response', lambda res: print('[RES]', res.status, res.url) if 'api' in res.url else None)
|
||||
|
||||
page.goto('https://mail.solit.cn/#/login', wait_until='networkidle')
|
||||
page.goto('https://mail.example.com/#/login', wait_until='networkidle')
|
||||
time.sleep(2)
|
||||
|
||||
acc = page.locator('.login-content input').nth(0)
|
||||
|
||||
@@ -9,8 +9,8 @@ opener = urllib.request.build_opener(urllib.request.HTTPSHandler(context=ctx), u
|
||||
login_payload = json.dumps({"account": "testuser2", "password": "Password123!"}).encode("utf-8")
|
||||
req = urllib.request.Request("https://47.108.78.12/api/v1/login", data=login_payload, headers={
|
||||
"Content-Type": "application/json",
|
||||
"Host": "mail.solit.cn",
|
||||
"Origin": "https://mail.solit.cn"
|
||||
"Host": "mail.example.com",
|
||||
"Origin": "https://mail.example.com"
|
||||
})
|
||||
resp = opener.open(req, timeout=5)
|
||||
data = json.loads(resp.read().decode())
|
||||
@@ -23,9 +23,9 @@ for c in cj:
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Host": "mail.solit.cn",
|
||||
"Origin": "https://mail.solit.cn",
|
||||
"Referer": "https://mail.solit.cn/",
|
||||
"Host": "mail.example.com",
|
||||
"Origin": "https://mail.example.com",
|
||||
"Referer": "https://mail.example.com/",
|
||||
"X-CSRF-Token": csrf_token
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ opener = urllib.request.build_opener(urllib.request.HTTPSHandler(context=ctx), u
|
||||
login_payload = json.dumps({"account": "testuser2", "password": "Password123!"}).encode("utf-8")
|
||||
req = urllib.request.Request("https://47.108.78.12/api/v1/login", data=login_payload, headers={
|
||||
"Content-Type": "application/json",
|
||||
"Host": "mail.solit.cn",
|
||||
"Origin": "https://mail.solit.cn"
|
||||
"Host": "mail.example.com",
|
||||
"Origin": "https://mail.example.com"
|
||||
})
|
||||
resp = opener.open(req, timeout=5)
|
||||
data = json.loads(resp.read().decode())
|
||||
@@ -23,9 +23,9 @@ for c in cj:
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Host": "mail.solit.cn",
|
||||
"Origin": "https://mail.solit.cn",
|
||||
"Referer": "https://mail.solit.cn/",
|
||||
"Host": "mail.example.com",
|
||||
"Origin": "https://mail.example.com",
|
||||
"Referer": "https://mail.example.com/",
|
||||
"X-CSRF-Token": csrf_token
|
||||
}
|
||||
|
||||
|
||||
@@ -85,11 +85,11 @@ def main():
|
||||
assert control.st_uid == database.stat().st_uid
|
||||
summary['control_socket_mode'] = oct(stat.S_IMODE(control.st_mode))
|
||||
curl = ['curl', '--silent', '--show-error', '--fail', '--max-time', '10', '--noproxy', '*',
|
||||
'--cacert', str(root / 'ssl/custom.crt'), '--resolve', 'web.solit.cn:443:127.0.0.1']
|
||||
run(*curl, 'https://web.solit.cn/api/ping')
|
||||
'--cacert', str(root / 'ssl/custom.crt'), '--resolve', 'web.example.com:443:127.0.0.1']
|
||||
run(*curl, 'https://web.example.com/api/ping')
|
||||
summary['unauthenticated'] = {}
|
||||
for endpoint in ('/api/v1/user/info', '/api/v1/email/list'):
|
||||
response = json.loads(run(*curl, '-X', 'POST', 'https://web.solit.cn' + endpoint))
|
||||
response = json.loads(run(*curl, '-X', 'POST', 'https://web.example.com' + endpoint))
|
||||
assert response['errorNo'] == 403 and not response.get('data')
|
||||
summary['unauthenticated'][endpoint] = response['errorNo']
|
||||
entries = run('journalctl', '-u', 'smail.service', '--since', args.since, '--output=json', '--no-pager')
|
||||
|
||||
Reference in new issue
Block a user