CH-J SM Mobilegestione server su SSH
Menu
Sorgente pubblicata

CH-J SM Mobile

Sfoglia directory e file per una specifica release di applicazioni.

Scarica sorgente ZIP
CH-J / SM Mobile 134 file
sm-mobile-20261016T050549Z-3678f2a05fa9 Aggiunto: · Costruito:
File
test_linux.py Aggiunto: Data non registrata 2,0 KB · 31 righe
Scarica file
1#!/usr/bin/env python3
2"""Optional Linux SSH/password/monitor integration fixture; never an app dependency."""
3import argparse,os,pathlib,secrets,socket,subprocess,time
4root=pathlib.Path(__file__).resolve().parents[1]
5p=argparse.ArgumentParser()
6p.add_argument('--context',help='Docker context, e.g. colima-sm-mobile-test')
7args=p.parse_args()
8docker=['docker']+(['--context',args.context] if args.context else [])
9image='lscr.io/linuxserver/openssh-server@sha256:0f535b0faa7448511b23528165e9fbd4f1fe563b861b3dcaa5ddb0ddbfe2254c'
10name='sm-mobile-linux-'+secrets.token_hex(6)
11password=secrets.token_urlsafe(24)
12env={**os.environ,'USER_PASSWORD':password}
13subprocess.run(docker+['run','--rm','-d','--name',name,'--memory','256m','--cpus','1',
14 '-p','127.0.0.1:22239:2222','-e','USER_NAME=smtest','-e','PASSWORD_ACCESS=true',
15 '-e','USER_PASSWORD','-e','SUDO_ACCESS=false',image],env=env,check=True,stdout=subprocess.DEVNULL)
16try:
17 for attempt in range(80):
18 try:
19 with socket.create_connection(('127.0.0.1',22239),timeout=1) as probe:
20 if not probe.recv(128).startswith(b'SSH-'):raise OSError('SSH is not ready')
21 break
22 except OSError:time.sleep(.25)
23 else:raise SystemExit('Linux SSH fixture did not become ready.')
24 files=subprocess.check_output(docker+['exec',name,'find','/config','-name','*ed25519*.pub'],text=True).splitlines()
25 if len(files)!=1:raise SystemExit('Unexpected host-key files in Linux fixture.')
26 fingerprint=subprocess.check_output(docker+['exec',name,'ssh-keygen','-lf',files[0],'-E','sha256'],text=True).split()[1]
27 print('Testing real Linux OpenSSH using pinned image '+image,flush=True)
28 subprocess.run(['flutter','test','test/network/linux_test.dart','--reporter','expanded'],cwd=root,
29 env={**os.environ,'SM_LINUX_TEST':'1','SM_TEST_PASSWORD':password,'SM_TEST_FINGERPRINT':fingerprint},check=True)
30finally:
31 subprocess.run(docker+['rm','-f',name],check=False,stdout=subprocess.DEVNULL)
SHA-2567a275349c3ef11ef84f683eaf17d356af7f42d78b4180d83f93a569e84c6a0ea

CH-J Proprietary Software License 1.14 · La sorgente è fornita sotto CH-J Proprietary Software License 1.14. La sua disponibilità non modifica i termini di licenza o concede diritti aggiuntivi.

Archivio SHA-256c486a807e4828998b9c57ab0f2e760f7980b31965fe118e89d3e1a5a2b65be65