4 (luna-define-class test-sasl (lunit-test-case))
6 (luna-define-method test-sasl-find-mechanism ((case test-sasl))
7 (let ((mechanisms sasl-mechanisms))
9 (let* ((sasl-mechanisms (list (car mechanisms))))
11 (sasl-find-mechanism (list (car mechanisms)))))
12 (setq mechanisms (cdr mechanisms)))))
14 (luna-define-method test-sasl-digest-md5-imap ((case test-sasl))
15 (let* ((sasl-mechanisms '("DIGEST-MD5"))
17 (sasl-find-mechanism '("DIGEST-MD5")))
19 (sasl-make-client mechanism "chris" "imap" "elwood.innosoft.com"))
25 (sasl-client-set-property client 'realm "elwood.innosoft.com")
26 (sasl-client-set-property client 'cnonce "OA6MHXh6VqTrRk")
27 (setq step (sasl-next-step client nil))
29 step "realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",\
30 qop=\"auth\",algorithm=md5-sess,charset=utf-8")
31 (setq step (sasl-next-step client step))
33 (setq response (sasl-digest-md5-parse-string (sasl-step-data step)))
36 (plist-get response 'response) "d388dad90d4bbd760a152321f2143af7"))))
38 (luna-define-method test-sasl-digest-md5-acap ((case test-sasl))
39 (let* ((sasl-mechanisms '("DIGEST-MD5"))
41 (sasl-find-mechanism '("DIGEST-MD5")))
43 (sasl-make-client mechanism "chris" "acap" "elwood.innosoft.com"))
49 (sasl-client-set-property client 'realm "elwood.innosoft.com")
50 (sasl-client-set-property client 'cnonce "OA9BSuZWMSpW8m")
51 (setq step (sasl-next-step client nil))
53 step "realm=\"elwood.innosoft.com\",nonce=\"OA9BSXrbuRhWay\",qop=\"auth\",\
54 algorithm=md5-sess,charset=utf-8")
55 (setq step (sasl-next-step client step))
57 (setq response (sasl-digest-md5-parse-string (sasl-step-data step)))
60 (plist-get response 'response) "6084c6db3fede7352c551284490fd0fc"))))
62 (luna-define-method test-sasl-scram-md5-imap ((case test-sasl))
63 (let* ((sasl-mechanisms '("SCRAM-MD5"))
65 (sasl-find-mechanism '("SCRAM-MD5")))
67 (sasl-make-client mechanism "chris" "imap" "eleanor.innosoft.com"))
73 (sasl-client-set-property client 'nonce
74 "<t4n4Pab9HB0Am/QLXB72eg@eleanor.innosoft.com>")
75 (setq step (sasl-next-step client nil))
76 (sasl-step-set-data step "")
77 (setq step (sasl-next-step client step))
81 "dGVzdHNhbHQBAAAAaW1hcEBlbGVhbm9yLmlubm9zb2Z0LmNvbQBqaGNOWmxSdVBiemlGcCt2TFYrTkN3"))
82 (setq step (sasl-next-step client step))
84 (string= (sasl-step-data step)
85 (base64-decode-string "AQAAAMg9jU8CeB4KOfk7sUhSQPs=")))))
87 (luna-define-method test-sasl-ntlm-imap ((case test-sasl))
88 (let* ((sasl-mechanisms '("NTLM"))
90 (sasl-find-mechanism '("NTLM")))
92 (sasl-make-client mechanism "kawagish@nokiaseap" "imap" "xxx.yyy.com"))
94 #'(lambda (passphrase)
99 (setq step (sasl-next-step client nil))
100 ;; generate authentication request
101 (sasl-step-set-data step "")
102 (setq step (sasl-next-step client step))
103 (sasl-step-data step)
104 ;; (base64-encode-string (sasl-step-data step) t) is sent to server
105 ;; generate response to challenge
109 (base64-decode-string
110 "TlRMTVNTUAACAAAADAAMADAAAAAFggEApmEjGvh9M8YAAAAAAAAAAAAAAAA8AAAATgBPAEsARQBYAEMA")))
111 (setq step (sasl-next-step client step))
112 (sasl-step-data step)
113 (setq response (base64-encode-string (sasl-step-data step) t))
116 response "TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAABIAEgBwAAAAEAAQAIIAAAAQABAAkgAAAAAAAABiAAAABYIBAIwN9i7qK/9Y31dIDR6JQTaBbjcLJm8Sc6VogMe7fnHP96+eQ5Yf3ys2nIY4rx+iQG4AbwBrAGkAYQBzAGUAYQBwAGsAYQB3AGEAZwBpAHMAaABrAGEAdwBhAGcAaQBzAGgA"))