You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
1.7 KiB

  1. #!/bin/bash
  2. exname=$(basename $0)
  3. prefix_cmd="
  4. . /etc/shlib
  5. include common
  6. include parse
  7. . ../lib/common
  8. has_existing_cert() {
  9. echo \"Calling has_existing_cert $*\" >&2
  10. [ \"\$HAS_EXISTING_CERT\" == 'yes' ]
  11. }
  12. export -f has_existing_cert
  13. letsencrypt_cert_info() {
  14. echo \"Calling letsencrypt_cert_info $*\" >&2
  15. echo \"\$LETSENCRYPT_CERT_INFO\"
  16. }
  17. export -f letsencrypt_cert_info
  18. "
  19. try "
  20. HAS_EXISTING_CERT= ## False
  21. valid_existing_cert 30 'www.example.com'
  22. "
  23. is errlvl 1
  24. is err 'Calling has_existing_cert' RTRIM
  25. is out '' RTRIM
  26. try "
  27. HAS_EXISTING_CERT=yes ## False
  28. LETSENCRYPT_CERT_INFO='
  29. domains: www.example.com
  30. remaining: 74
  31. '
  32. valid_existing_cert 30 'www.example.com'
  33. " "existing and valid cert"
  34. is errlvl 0
  35. is err part 'Calling has_existing_cert' RTRIM
  36. is err part 'Querying www.example.com for previous info...' RTRIM
  37. is err part 'Calling letsencrypt_cert_info' RTRIM
  38. is out '' RTRIM
  39. try "
  40. HAS_EXISTING_CERT=yes ## False
  41. LETSENCRYPT_CERT_INFO='
  42. domains: www.example.com
  43. remaining: 74
  44. '
  45. valid_existing_cert 90 'www.example.com'
  46. " "days validity beneath threshold"
  47. is errlvl 1
  48. is out '' RTRIM
  49. try "
  50. HAS_EXISTING_CERT=yes ## False
  51. LETSENCRYPT_CERT_INFO='
  52. domains: www.example.com example.com
  53. remaining: 74
  54. '
  55. valid_existing_cert 30 'www.example.com'
  56. " "domains mismatch 1"
  57. is errlvl 2
  58. is out '' RTRIM
  59. try "
  60. HAS_EXISTING_CERT=yes ## False
  61. LETSENCRYPT_CERT_INFO='
  62. domains: www.example.com
  63. remaining: 74
  64. '
  65. valid_existing_cert 30 'www.example.com' example.com
  66. " "domains mismatch 2"
  67. is errlvl 2
  68. is out '' RTRIM
  69. try "
  70. HAS_EXISTING_CERT=yes ## False
  71. LETSENCRYPT_CERT_INFO='
  72. domains: www.example.com
  73. remaining: EXPIRED
  74. '
  75. valid_existing_cert 30 www.example.com
  76. " "expired"
  77. is errlvl 1
  78. is out '' RTRIM