Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

114 строки
3.2 KiB

  1. { stdenv
  2. , buildPythonPackage
  3. , fetchPypi
  4. , openssl
  5. , cryptography
  6. , pyasn1
  7. , idna
  8. , pytest
  9. , pretend
  10. , flaky
  11. , glibcLocales
  12. , six
  13. , fetchpatch
  14. }:
  15. with stdenv.lib;
  16. let
  17. # https://github.com/pyca/pyopenssl/issues/791
  18. # These tests, we disable in the case that libressl is passed in as openssl.
  19. failingLibresslTests = [
  20. "test_op_no_compression"
  21. "test_npn_advertise_error"
  22. "test_npn_select_error"
  23. "test_npn_client_fail"
  24. "test_npn_success"
  25. "test_use_certificate_chain_file_unicode"
  26. "test_use_certificate_chain_file_bytes"
  27. "test_add_extra_chain_cert"
  28. "test_set_session_id_fail"
  29. "test_verify_with_revoked"
  30. "test_set_notAfter"
  31. "test_set_notBefore"
  32. ];
  33. # these tests are extremely tightly wed to the exact output of the openssl cli tool,
  34. # including exact punctuation.
  35. failingOpenSSL_1_1Tests = [
  36. "test_dump_certificate"
  37. "test_dump_privatekey_text"
  38. "test_dump_certificate_request"
  39. "test_export_text"
  40. ];
  41. disabledTests = [
  42. # https://github.com/pyca/pyopenssl/issues/692
  43. # These tests, we disable always.
  44. "test_set_default_verify_paths"
  45. "test_fallback_default_verify_paths"
  46. # https://github.com/pyca/pyopenssl/issues/768
  47. "test_wantWriteError"
  48. ] ++ (
  49. optionals (hasPrefix "libressl" openssl.meta.name) failingLibresslTests
  50. ) ++ (
  51. optionals (versionAtLeast (getVersion openssl.name) "1.1") failingOpenSSL_1_1Tests
  52. );
  53. # Compose the final string expression, including the "-k" and the single quotes.
  54. testExpression = optionalString (disabledTests != [])
  55. "-k 'not ${concatStringsSep " and not " disabledTests}'";
  56. in
  57. buildPythonPackage rec {
  58. pname = "pyOpenSSL";
  59. version = "19.1.0";
  60. src = fetchPypi {
  61. inherit pname version;
  62. sha256 = "9a24494b2602aaf402be5c9e30a0b82d4a5c67528fe8fb475e3f3bc00dd69507";
  63. };
  64. outputs = [ "out" "dev" ];
  65. checkPhase = ''
  66. runHook preCheck
  67. export LANG="en_US.UTF-8"
  68. py.test tests ${testExpression}
  69. runHook postCheck
  70. '';
  71. patches = [
  72. # 4 patches for 2020 bug
  73. # https://github.com/pyca/pyopenssl/pull/828
  74. (fetchpatch {
  75. url = "https://github.com/pyca/pyopenssl/commit/0d2fd1a24b30077ead6960bd63b4a9893a57c101.patch";
  76. sha256 = "1c27g53qrwxddyx04sxf8yvj7xgbaabla7mc1cgbfd426rncbqf3";
  77. })
  78. (fetchpatch {
  79. url = "https://github.com/pyca/pyopenssl/commit/d08a742573c3205348a4eec9a65abaf6c16110c4.patch";
  80. sha256 = "18xn8s1wpycz575ivrbsbs0qd2q48z8pdzsjzh8i60xba3f8yj2f";
  81. })
  82. (fetchpatch {
  83. url = "https://github.com/pyca/pyopenssl/commit/60b9e10e6da7ccafaf722def630285f54510ed12.patch";
  84. sha256 = "0aw8qvy8m0bhgp39lmbcrpprpg4bhpssm327hyrk476wwgajk01j";
  85. })
  86. (fetchpatch {
  87. url = "https://github.com/pyca/pyopenssl/commit/7a37cc23fcbe43abe785cd4badd14bdc7acfb175.patch";
  88. sha256 = "1c7zb568rs71rsl16p6dq7aixwlkgzfnba4vzmfvbmy3zsnaslq2";
  89. })
  90. ];
  91. # Seems to fail unpredictably on Darwin. See https://hydra.nixos.org/build/49877419/nixlog/1
  92. # for one example, but I've also seen ContextTests.test_set_verify_callback_exception fail.
  93. doCheck = !stdenv.isDarwin;
  94. nativeBuildInputs = [ openssl ];
  95. propagatedBuildInputs = [ cryptography pyasn1 idna six ];
  96. checkInputs = [ pytest pretend flaky glibcLocales ];
  97. }