| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 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 | |
| 25 |
|
| 26 | (test-begin "file-sharing")
|
| 27 |
|
| 28 |
|
| 29 | |
| 30 | |
| 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")
|