Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / tests / services / file-sharing.scm
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
19 (define-module (tests services file-sharing)
20 #:use-module (gnu services file-sharing)
21 #:use-module (srfi srfi-64))
22
23 ;;; Tests for the (gnu services file-sharing) module.
24
25 (test-begin "file-sharing")
26
27 \f
28 ;;;
29 ;;; Transmission Daemon.
30 ;;;
31
32 (define %transmission-salt-length 8)
33
34 (define (valid-transmission-salt? salt)
35 (and (string? salt)
36 (eqv? (string-length salt) %transmission-salt-length)))
37
38 (test-assert "transmission-random-salt"
39 (valid-transmission-salt? (transmission-random-salt)))
40
41 (test-equal "transmission-password-hash, typical values"
42 "{ef6fba106cdef3aac64d1410090cae353cbecde53ceVVQO2"
43 (transmission-password-hash "transmission" "3ceVVQO2"))
44
45 (test-equal "transmission-password-hash, empty password"
46 "{820f816515d8969d058d07a1de018650619ee7ffCp.I5SWg"
47 (transmission-password-hash "" "Cp.I5SWg"))
48
49 (test-error "transmission-password-hash, salt value too short"
50 (transmission-password-hash
51 "transmission"
52 (make-string (- %transmission-salt-length 1) #\a)))
53
54 (test-error "transmission-password-hash, salt value too long"
55 (transmission-password-hash
56 "transmission"
57 (make-string (+ %transmission-salt-length 1) #\a)))
58
59 (test-end "file-sharing")