s = open('test/config/http/hsm.conf').read() old = ''' ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-SM2-SM4-GCM-SM3:ECDHE-SM2-SM4-CBC-SM3:ECC-SM2-SM4-GCM-SM3:ECC-SM2-SM4-CBC-SM3; ssl_conf_command Ciphersuites TLS_SM4_GCM_SM3:TLS_SM4_CCM_SM3; ssl_verify_client off; ssl_prefer_server_ciphers on; ssl_certificate /usr/local/nginx/conf/man/certs/sm2.sig.pem; ssl_certificate_key /usr/local/nginx/conf/man/certs/sm2.sig.key; ''' new = ''' ssl_protocols TLSv1.2 TLSv1.3; ssl_ntls on; ssl_ciphers ECDHE-SM2-SM4-GCM-SM3:ECDHE-SM2-SM4-CBC-SM3:ECC-SM2-SM4-GCM-SM3:ECC-SM2-SM4-CBC-SM3; ssl_conf_command Ciphersuites TLS_SM4_GCM_SM3:TLS_SM4_CCM_SM3; ssl_verify_client off; ssl_prefer_server_ciphers on; ssl_certificate /usr/local/nginx/conf/man/certs/sm2.sig.pem /usr/local/nginx/conf/man/certs/sm2.enc.pem; ssl_certificate_key /usr/local/nginx/conf/man/certs/sm2.sig.key /usr/local/nginx/conf/man/certs/sm2.enc.key; ''' assert old in s, 'block not found' s = s.replace(old, new) open('test/config/http/hsm.conf', 'w').write(s) print('CONF_UPDATED')