<commit_before>#
#
#            Nim - SSL integration tests
#        (c) Copyright 2017 Nim contributors
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#
## Warning: this test performs external networking.
## Test with:
## ./bin/nim c -d:ssl -p:. --threads:on -r tests/untestable/thttpclient_ssl.nim
##
## See https://github.com/FedericoCeratto/ssl-comparison/blob/master/README.md
## for a comparison with other clients.

import
  httpclient,
  net,
  strutils,
  threadpool,
  unittest


type
  # bad and dubious tests should not pass SSL validation
  # "_broken" mark the test as skipped. Some tests have different
  # behavior depending on OS and SSL version!
  # TODO: chase and fix the broken tests
  Category = enum
    good, bad, dubious, good_broken, bad_broken, dubious_broken
  CertTest = tuple[url:string, category:Category, desc: string]

const certificate_tests: array[0..55, CertTest] = [
  ("https://wrong.host.badssl.com/", bad, "wrong.host"),
  ("https://captive-portal.badssl.com/", bad, "captive-portal"),
  ("https://expired.badssl.com/", bad, "expired"),
  ("https://google.com/", good, "good"),
  ("https://self-signed.badssl.com/", bad, "self-signed"),
  ("https://untrusted-root.badssl.com/", bad, "untrusted-root"),
  ("https://revoked.badssl.com/", bad_broken, "revoked"),
  ("https://pinning-test.badssl.com/", bad_broken, "pinning-test"),
  ("https://no-common-name.badssl.com/", dubious_broken, "no-common-name"),
  ("https://no-subject.badssl.com/", dubious_broken, "no-subject"),
  ("https://incomplete-chain.badssl.com/", dubious_broken, "incomplete-chain"),
  ("https://sha1-intermediate.badssl.com/", bad_broken, "sha1-intermediate"),
  ("https://sha256.badssl.com/", good, "sha256"),
  ("https://sha384.badssl.com/", good, "sha384"),
  ("https://sha512.badssl.com/", good, "sha512"),
  ("https://1000-sans.badssl.com/", good, "1000-sans"),
  ("https://10000-sans.badssl.com/", good_broken, "10000-sans"),
  ("https://ecc256.badssl.com/", good, "ecc256"),
  ("https://ecc384.badssl.com/", good, "ecc384"),
  ("https://rsa2048.badssl.com/", good, "rsa2048"),
  ("https://rsa8192.badssl.com/", dubious_broken, "rsa8192"),
  ("http://http.badssl.com/", good, "regular http"),
  ("https://http.badssl.com/", bad_broken, "http on https URL"),  # FIXME
  ("https://cbc.badssl.com/", dubious_broken, "cbc"),
  ("https://rc4-md5.badssl.com/", bad, "rc4-md5"),
  ("https://rc4.badssl.com/", bad, "rc4"),
  ("https://3des.badssl.com/", bad, "3des"),
  ("https://null.badssl.com/", bad, "null"),
  ("https://mozilla-old.badssl.com/", bad_broken, "mozilla-old"),
  ("https://mozilla-intermediate.badssl.com/", dubious_broken, "mozilla-intermediate"),
  ("https://mozilla-modern.badssl.com/", good, "mozilla-modern"),
  ("https://dh480.badssl.com/", bad, "dh480"),
  ("https://dh512.badssl.com/", bad, "dh512"),
  ("https://dh1024.badssl.com/", dubious_broken, "dh1024"),
  ("https://dh2048.badssl.com/", good, "dh2048"),
  ("https://dh-small-subgroup.badssl.com/", bad_broken, "dh-small-subgroup"),
  ("https://dh-composite.badssl.com/", bad_broken, "dh-composite"),
  ("https://static-rsa.badssl.com/", dubious_broken, "static-rsa"),
  ("https://tls-v1-0.badssl.com:1010/", dubious_broken, "tls-v1-0"),
  ("https://tls-v1-1.badssl.com:1011/", dubious_broken, "tls-v1-1"),
  ("https://invalid-expected-sct.badssl.com/", bad_broken, "invalid-expected-sct"),
  ("https://hsts.badssl.com/", good, "hsts"),
  ("https://upgrade.badssl.com/", good, "upgrade"),
  ("https://preloaded-hsts.badssl.com/", good, "preloaded-hsts"),
  ("https://subdomain.preloaded-hsts.badssl.com/", bad, "subdomain.preloaded-hsts"),
  ("https://https-everywhere.badssl.com/", good, "https-everywhere"),
  ("https://long-extended-subdomain-name-containing-many-letters-and-dashes.badssl.com/", good,
    "long-extended-subdomain-name-containing-many-letters-and-dashes"),<commit_msg>untestable/thttpclient_ssl: some tests are no longer broken<commit_after>#
#
#            Nim - SSL integration tests
#        (c) Copyright 2017 Nim contributors
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#
## Warning: this test performs external networking.
## Test with:
## ./bin/nim c -d:ssl -p:. --threads:on -r tests/untestable/thttpclient_ssl.nim
##
## See https://github.com/FedericoCeratto/ssl-comparison/blob/master/README.md
## for a comparison with other clients.

import
  httpclient,
  net,
  strutils,
  threadpool,
  unittest


type
  # bad and dubious tests should not pass SSL validation
  # "_broken" mark the test as skipped. Some tests have different
  # behavior depending on OS and SSL version!
  # TODO: chase and fix the broken tests
  Category = enum
    good, bad, dubious, good_broken, bad_broken, dubious_broken
  CertTest = tuple[url:string, category:Category, desc: string]

const certificate_tests: array[0..55, CertTest] = [
  ("https://wrong.host.badssl.com/", bad, "wrong.host"),
  ("https://captive-portal.badssl.com/", bad, "captive-portal"),
  ("https://expired.badssl.com/", bad, "expired"),
  ("https://google.com/", good, "good"),
  ("https://self-signed.badssl.com/", bad, "self-signed"),
  ("https://untrusted-root.badssl.com/", bad, "untrusted-root"),
  ("https://revoked.badssl.com/", bad_broken, "revoked"),
  ("https://pinning-test.badssl.com/", bad_broken, "pinning-test"),
  ("https://no-common-name.badssl.com/", dubious_broken, "no-common-name"),
  ("https://no-subject.badssl.com/", dubious_broken, "no-subject"),
  ("https://incomplete-chain.badssl.com/", dubious_broken, "incomplete-chain"),
  ("https://sha1-intermediate.badssl.com/", bad, "sha1-intermediate"),
  ("https://sha256.badssl.com/", good, "sha256"),
  ("https://sha384.badssl.com/", good, "sha384"),
  ("https://sha512.badssl.com/", good, "sha512"),
  ("https://1000-sans.badssl.com/", good, "1000-sans"),
  ("https://10000-sans.badssl.com/", good_broken, "10000-sans"),
  ("https://ecc256.badssl.com/", good, "ecc256"),
  ("https://ecc384.badssl.com/", good, "ecc384"),
  ("https://rsa2048.badssl.com/", good, "rsa2048"),
  ("https://rsa8192.badssl.com/", dubious_broken, "rsa8192"),
  ("http://http.badssl.com/", good, "regular http"),
  ("https://http.badssl.com/", bad_broken, "http on https URL"),  # FIXME
  ("https://cbc.badssl.com/", dubious, "cbc"),
  ("https://rc4-md5.badssl.com/", bad, "rc4-md5"),
  ("https://rc4.badssl.com/", bad, "rc4"),
  ("https://3des.badssl.com/", bad, "3des"),
  ("https://null.badssl.com/", bad, "null"),
  ("https://mozilla-old.badssl.com/", bad_broken, "mozilla-old"),
  ("https://mozilla-intermediate.badssl.com/", dubious_broken, "mozilla-intermediate"),
  ("https://mozilla-modern.badssl.com/", good, "mozilla-modern"),
  ("https://dh480.badssl.com/", bad, "dh480"),
  ("https://dh512.badssl.com/", bad, "dh512"),
  ("https://dh1024.badssl.com/", dubious_broken, "dh1024"),
  ("https://dh2048.badssl.com/", good, "dh2048"),
  ("https://dh-small-subgroup.badssl.com/", bad_broken, "dh-small-subgroup"),
  ("https://dh-composite.badssl.com/", bad_broken, "dh-composite"),
  ("https://static-rsa.badssl.com/", dubious, "static-rsa"),
  ("https://tls-v1-0.badssl.com:1010/", dubious, "tls-v1-0"),
  ("https://tls-v1-1.badssl.com:1011/", dubious, "tls-v1-1"),
  ("https://invalid-expected-sct.badssl.com/", bad, "invalid-expected-sct"),
  ("https://hsts.badssl.com/", good, "hsts"),
  ("https://upgrade.badssl.com/", good, "upgrade"),
  ("https://preloaded-hsts.badssl.com/", good, "preloaded-hsts"),
  ("https://subdomain.preloaded-hsts.badssl.com/", bad, "subdomain.preloaded-hsts"),
  ("https://https-everywhere.badssl.com/", good, "https-everywhere"),
  ("https://long-extended-subdomain-name-containing-many-letters-and-dashes.badssl.com/", good,
    "long-extended-subdomain-name-containing-many-letters-and-dashes"),
{'fraction_non_alphanumeric': 0.2237744475488951, 'fraction_numerical': 0.031750063500127, 'mean_word_length': 4.126953125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 94, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1868381', 'n_tokens_mistral': 3130, 'n_tokens_neox': 2891, 'n_words': 503}