Changeset 17894 in project


Ignore:
Timestamp:
04/24/10 08:23:12 (9 years ago)
Author:
certainty
Message:

enabled authentication as md5 is now available. Adjusted dependencies and tests accordingly

Location:
release/4/dict/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/dict/trunk/dict.meta

    r14520 r17894  
    66 (license "MIT")
    77 (doc-from-wiki)
    8  (depends defstruct)
     8 (depends defstruct md5 utf8)
    99 (test-depends test)
    1010 (files "dict.setup" "dict.scm" "dict.html"))
  • release/4/dict/trunk/dict.scm

    r15039 r17894  
    88;; Version: $Id$
    99;; Version:
    10 ;; Last-Updated: Sa Jun 20 19:11:44 2009 (CEST)
    11 ;;           By: David Krentzlin <david@lisp-unleashed.de>
    12 ;;     Update #: 453
     10;; Last-Updated: Sa Apr 24 08:57:40 2010 (CEST)
     11;;           By: David Krentzlin
     12;;     Update #: 459
    1313;; URL:
    1414;; Keywords:
     
    7373    make-connection connect disconnect connection-msg-id connection-server-capabilities
    7474    *current-log-port* !match !define !databases !strategies !server-information !database-information
    75     !help !status !quit !announce-client)
     75    !help !status !quit !announce-client !authenticate)
    7676 
    7777  (import scheme chicken)
    78   (require-library tcp defstruct regex srfi-13 srfi-14)
    79   (import tcp defstruct
     78  (require-library tcp defstruct regex srfi-13 srfi-14 md5)
     79  (import tcp defstruct
     80          (only md5 md5-digest)
    8081          (only srfi-14 char-set:digit)
    8182          (only srfi-13 string-join string-index string-trim-right string-trim-both string-trim string-skip string-take string-drop)
     
    445446      (values (status:ok? status) status)))
    446447
    447   ;;enable this once md5 has been ported to chicken 4
    448   ;; (define (!authenticate con username password)
    449   ;;   (send-command con +cmd:authenticate+ username (compute-password con password))
    450   ;;   (let ((status (read-status-response (connection-input-port con))))
    451   ;;     (status:authentication-successful? status)))
    452 
    453   ;; (define (compute-password con password)
    454   ;;   (md5:digest (string-append (connection-msg-id con) password)))
     448 
     449  (define (!authenticate con username password)
     450     (send-command con +cmd:auth+ username (compute-password con password))
     451     (let ((status (read-status-response (connection-input-port con))))
     452       (status:authentication-successful? status)))
     453
     454  (define (compute-password con password)
     455     (md5-digest (string-append (connection-msg-id con) password)))
    455456
    456457
  • release/4/dict/trunk/test/dict-test.scm

    r14353 r17894  
    88;; Version: $Id$
    99;; Version:
    10 ;; Last-Updated: Di Apr 21 21:31:33 2009 (CEST)
    11 ;;           By: David Krentzlin <david@lisp-unleashed.de>
    12 ;;     Update #: 286
     10;; Last-Updated: Sa Apr 24 09:00:52 2010 (CEST)
     11;;           By: David Krentzlin
     12;;     Update #: 292
    1313;; URL:
    1414;; Keywords:
     
    5959
    6060
    61 (use test utf8 utf8-srfi-13 utf8-srfi-14 dict)
     61(use test utf8 utf8-srfi-13 utf8-srfi-14 dict md5)
    6262
    6363;;some helpers
     
    126126     
    127127(test-end "status")
    128 
    129 (test-begin "commands")
    130 (test "define-cmd expands correctly" #t #t)
    131 (test-end "commands")
    132128           
    133129
     
    257253                              (list s r)))))
    258254   ;;enable this once md5 has been ported to chicken 4
    259    ;; (define test-password (md5:digest (string-append "<test@example.org>" "test")))
    260 
    261    ;; (test "authenticate success"
    262    ;;       `((output . ,(conc "AUTH user " test-password "\r\n"))
    263    ;;         (result . #t))
    264    ;;       (with-stubbed-io "230 authenticated\r\n"
    265    ;;                        (lambda (con)
    266    ;;                          (!authenticate con "test" "test"))))
    267    ;; (test "authenticate failure" #t #t)
     255    (define test-password (md5-digest (string-append "<test@example.org>" "test")))
     256
     257    (test "authenticate success"
     258          `((output . ,(conc "AUTH test " test-password "\r\n"))
     259            (result . #t))
     260          (with-stubbed-io "230 authenticated\r\n"
     261                           (lambda (con)
     262                             (!authenticate con "test" "test"))))
     263    (test "authenticate failure" #t #t)
    268264                   
    269265(test-end "commands")
     
    271267
    272268
    273 (test-begin "dict-system")
    274 
    275 (test-end "dict-system")
     269;;(test-begin "dict-system")
     270
     271;;(test-end "dict-system")
    276272
    277273           
Note: See TracChangeset for help on using the changeset viewer.