Recently Written · git

clic

MIRROR ONLY Gopher client with pretty colours in Common Lisp

git clone https://github.com/equwal/clic

Log | Files | Refs


3rdparties/software/cl+ssl-20200427-git/test/sni.lisp (1819 bytes)

1 ;;;; -*- Mode: LISP; Syntax: COMMON-LISP; indent-tabs-mode: nil; coding: utf-8; show-trailing-whitespace: t -*-
2 
3 (in-package :cl+ssl.test)
4 
5 (def-suite :cl+ssl.sni :in :cl+ssl
6   :description "Server Name Indications tests")
7 
8 (in-suite :cl+ssl.sni)
9 
10 (defun make-request-to-sni-test-server (sni-enabled)
11   (usocket:with-client-socket (socket stream "sni.velox.ch" 443
12                                       :element-type '(unsigned-byte 8))
13     (let* ((ssl-stream (cl+ssl:make-ssl-client-stream stream
14                                                       :hostname (if sni-enabled "sni.velox.ch")))
15            (char-stream (flexi-streams:make-flexi-stream ssl-stream
16                                                          :external-format '(:utf-8 :eol-style :crlf)))
17            (reply-buf (make-string 1000)))
18       (unwind-protect
19            (progn
20              (format char-stream "GET / HTTP/1.1~%")
21              (format char-stream "Host: sni.velox.ch~%~%")
22              (finish-output char-stream)
23              (read-sequence reply-buf char-stream)
24              reply-buf)
25         (close ssl-stream)))))
26 
27 (defun sni-test-request-succeeded-p (response)
28   (search "Great!" response))
29 
30 (defun sni-test-request-failed-p (response)
31   (search "Unfortunately" response))
32 
33 ;; Disable the SNI tests because sni.velox.ch was shut down and we
34 ;; haven't found a replacement.
35 ;;
36 ;; (test (sni.disabled :compile-at :definition-time)
37 ;;   (is-true (sni-test-request-failed-p (make-request-to-sni-test-server nil))
38 ;;            "Request to SNI test server should've failed because SNI was disabled"))
39 ;;
40 ;; (test (sni.enabled :compile-at :definition-time)
41 ;;   (is-true (sni-test-request-succeeded-p (make-request-to-sni-test-server t))
42 ;;            "Request to SNI test server should've succeseeded because SNI was enabled"))