projects/guix·blob python-team · refs

62 lines · 2.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2020 Simon South <[email protected]>
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 ((guix diagnostics) #:select (formatted-message?))
22 #:use-module (srfi srfi-64))
23
24;;; Tests for the (gnu services file-sharing) module.
25
26(test-begin "file-sharing")
27
28
29;;;
30;;; Transmission Daemon.
31;;;
32
33(define %transmission-salt-length 8)
34
35(define (valid-transmission-salt? salt)
36 (and (string? salt)
37 (eqv? (string-length salt) %transmission-salt-length)))
38
39(test-assert "transmission-random-salt"
40 (valid-transmission-salt? (transmission-random-salt)))
41
42(test-equal "transmission-password-hash, typical values"
43 "{ef6fba106cdef3aac64d1410090cae353cbecde53ceVVQO2"
44 (transmission-password-hash "transmission" "3ceVVQO2"))
45
46(test-equal "transmission-password-hash, empty password"
47 "{820f816515d8969d058d07a1de018650619ee7ffCp.I5SWg"
48 (transmission-password-hash "" "Cp.I5SWg"))
49
50(test-error "transmission-password-hash, salt value too short"
51 formatted-message?
52 (transmission-password-hash
53 "transmission"
54 (make-string (- %transmission-salt-length 1) #\a)))
55
56(test-error "transmission-password-hash, salt value too long"
57 formatted-message?
58 (transmission-password-hash
59 "transmission"
60 (make-string (+ %transmission-salt-length 1) #\a)))
61
62(test-end "file-sharing")