def test_parse_ssl_version_tlsv1(): content = 'SPAMDOPTIONS="--ssl-version tlsv1"' value = lib_spamd._parse_ssl_version(content) assert value == 'tlsv1' content = 'SPAMDOPTIONS="-cd -m5 --ssl-version tlsv1 -H"' value = lib_spamd._parse_ssl_version(content) assert value == 'tlsv1'
def test_parse_ssl_version_multiline(): content = 'SPAMDOPTIONS="--ssl \\\n --ssl-version tlsv1"\n' value = lib_spamd._parse_ssl_version(content) assert value == 'tlsv1' content = 'SPAMDOPTIONS="--ssl-version \\\n sslv3"\n' value = lib_spamd._parse_ssl_version(content) assert value == 'sslv3'
def test_parse_ssl_version_sslv3(): content = 'SPAMDOPTIONS="--ssl-version sslv3"' value = lib_spamd._parse_ssl_version(content) assert value == 'sslv3' content = 'SPAMDOPTIONS="-cd -m5 --ssl-version sslv3 -H"' value = lib_spamd._parse_ssl_version(content) assert value == 'sslv3'
def test_parse_ssl_version_repeated(): # The last --ssl-version option takes effect content = 'SPAMDOPTIONS="--ssl-version tlsv1 --ssl-version sslv3"\n' value = lib_spamd._parse_ssl_version(content) assert value == 'sslv3' content = 'SPAMDOPTIONS="--ssl-version sslv3 --ssl-version tlsv1"\n' value = lib_spamd._parse_ssl_version(content) assert value == 'sslv3'
def test_parse_ssl_version_invalid_argument(): # If an invalid argument is used, we treat it as if the option was not # specified at all, so that the config update actor doesn't touch it. We # don't want to break the config even more. content = 'SPAMDOPTIONS="--ssl-version foo"\n' value = lib_spamd._parse_ssl_version(content) assert value is None
def test_parse_ssl_version_multiline_comment(): content = 'SPAMDOPTIONS="--ssl-version tlsv1"\n' \ '# foo \\\nSPAMDOPTIONS="--ssl-version sslv3" \\\n still a comment' value = lib_spamd._parse_ssl_version(content) assert value == 'tlsv1'
def test_parse_ssl_version_last_assignment_takes_effect(): # The last assignment to SPAMDOPTIONS takes effect content = 'SPAMDOPTIONS="--ssl-version tlsv1"\nSPAMDOPTIONS="--ssl-version sslv3"\n' value = lib_spamd._parse_ssl_version(content) assert value == 'sslv3'
def test_parse_ssl_version_comments(): content = '# foo\nSPAMDOPTIONS="--ssl-version tlsv1"\n# bar\n' value = lib_spamd._parse_ssl_version(content) assert value == 'tlsv1'