PageRenderTime 121ms CodeModel.GetById 40ms app.highlight 2ms RepoModel.GetById 78ms app.codeStats 0ms

/test/core/signature.lisp

http://github.com/skypher/cl-oauth
Lisp | 37 lines | 28 code | 7 blank | 2 comment | 0 complexity | 24e92256586304cbb6c8c6442532d22a MD5 | raw file
 1
 2(in-package :oauth-test)
 3
 4(def-suite signature :in oauth)
 5
 6(in-suite signature)
 7
 8(defvar *sample-signature-base-string* 
 9  (format nil "GET&http%3A%2F%2Fphotos.example.net%2Fphotos~
10               &file%3Dvacation.jpg%26oauth_consumer_key~
11               %3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh~
12               %26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp~
13               %3D1191242096%26oauth_token%3Dnnch734d00sl2jdk~
14               %26oauth_version%3D1.0%26size%3Doriginal"))
15
16;; A.5.1
17(test signature-base-string/spec
18  (let* ((*request-method* :get)
19         (uri "http://photos.example.net/photos")
20         (parameters (format nil "file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03~
21                                  &oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1~
22                                  &oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk~
23                                  &oauth_version=1.0&size=original"))
24         (parameters-alist (oauth::query-string->alist parameters))
25         (*get-parameters* parameters-alist)
26         (signature-base-string (signature-base-string :uri uri)))
27    (is (equal signature-base-string
28               *sample-signature-base-string*))))
29
30;; A.5.2
31(test hmac-sha1-digest/spec
32  (let* ((key "kd94hf93k423kf44&pfkkdhi9sl3r4s00")
33         (text *sample-signature-base-string*)
34         (digest (hmac-sha1 text key))
35         (digest/base64 (cl-base64:usb8-array-to-base64-string digest)))
36    (is (equal digest/base64 "tR3+Ty81lMeYAr/Fid0kMTYa/WM="))))
37