file-sharing.scm 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2020 Simon South <simon@simonsouth.net>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (tests services file-sharing)
  19. #:use-module (gnu services file-sharing)
  20. #:use-module (srfi srfi-64))
  21. ;;; Tests for the (gnu services file-sharing) module.
  22. (test-begin "file-sharing")
  23. ;;;
  24. ;;; Transmission Daemon.
  25. ;;;
  26. (define %transmission-salt-length 8)
  27. (define (valid-transmission-salt? salt)
  28. (and (string? salt)
  29. (eqv? (string-length salt) %transmission-salt-length)))
  30. (test-assert "transmission-random-salt"
  31. (valid-transmission-salt? (transmission-random-salt)))
  32. (test-equal "transmission-password-hash, typical values"
  33. "{ef6fba106cdef3aac64d1410090cae353cbecde53ceVVQO2"
  34. (transmission-password-hash "transmission" "3ceVVQO2"))
  35. (test-equal "transmission-password-hash, empty password"
  36. "{820f816515d8969d058d07a1de018650619ee7ffCp.I5SWg"
  37. (transmission-password-hash "" "Cp.I5SWg"))
  38. (test-error "transmission-password-hash, salt value too short"
  39. (transmission-password-hash
  40. "transmission"
  41. (make-string (- %transmission-salt-length 1) #\a)))
  42. (test-error "transmission-password-hash, salt value too long"
  43. (transmission-password-hash
  44. "transmission"
  45. (make-string (+ %transmission-salt-length 1) #\a)))
  46. (test-end "file-sharing")