Coverage report: /home/ellis/comp/core/lib/cry/tests.lisp

KindCoveredAll%
expression014 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 (cl:defpackage :cry/tests
2
   (:use :rt :std :cl 
3
    :cry :cry/hotp :cry/totp :cry/crc64 
4
    :cry/jwt :cry/b3 :cry/keyring :cry/authinfo 
5
    :cry/password :cry/drm :cry/ssl)
6
   (:shadowing-import-from :rt :random-bytes))
7
 
8
 (in-package :cry/tests)
9
 
10
 (defsuite :cry)
11
 (in-suite :cry)
12
 
13
 (keyutils:load-keyutils)
14
 
15
 (deftest hotp ()
16
   (is (integerp (hotp "1234" 100))))
17
 
18
 (deftest totp ()
19
   (is (integerp (totp "1234"))))
20
 
21
 (deftest crc64 ()
22
   (init-crc64 42)
23
   (is (integerp (crc64-sequence "aaaaaaaaaaaaaaaaaaaaaaa"))))
24
 
25
 (deftest b3 ()
26
   (blake3:load-blake3)
27
   (isequal
28
    (b3hash-string "1234")
29
    (b3hash-string "1234")))
30
 
31
 (deftest jwt ()
32
   ;; https://jwt.io/#debugger-io
33
   (multiple-value-bind (claims header)
34
       (cry/jwt:jwt-decode "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" :secret "your-256-bit-secret")
35
     (istype 'dat/json:json-object claims)
36
     (istype 'dat/json:json-object header)))
37
 
38
 (deftest keyring ()
39
   (let ((kr (make-keyring :user)))
40
     (istype 'keyring kr)
41
     (iszero (clear-keys kr))))
42
 
43
 (defvar *test-authinfo* "machine foo login bar port abc password hackme")
44
 
45
 (deftest authinfo ()
46
   (when-let ((f (probe-file "~/.authinfo")))
47
     (istype 'authinfo (deserialize f :authinfo)))
48
   (deserialize *test-authinfo* :authinfo))
49
 
50
 (deftest password ()
51
   (let ((secret "hackme")
52
         (salt (sb-ext:string-to-octets "pepper")))
53
     (istype 'string (make-password-hash secret salt))
54
     (let ((pw (make-instance 'password :password secret)))
55
       (istype 'password pw)
56
       (is (auth pw secret)))))
57
 
58