changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/lib/net/tests.lisp

changeset 698: 96958d3eb5b0
parent: 7ce855f76e1d
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 (defpackage :net/tests
2  (:use :rt :std :cl :net :sb-concurrency :sb-thread :dat/proto :sb-bsd-sockets))
3 
4 (in-package :net/tests)
5 
6 (defsuite :net)
7 (in-suite :net)
8 (in-readtable :std)
9 
10 (deftest sanity ())
11 
12 (deftest dns ()
13  (is (stringp (resolve "compiler.company"))))
14 
15 (deftest tcp ()
16  (with-tcp-client (client)
17  (is (typep client 'sb-bsd-sockets:inet-socket))
18  (is (= (get-protocol-by-name :tcp)
19  (socket-protocol client)))))
20 
21 (deftest udp ()
22  (with-udp-client (client)
23  (is (typep client 'sb-bsd-sockets:inet-socket))
24  (is (= (get-protocol-by-name :udp)
25  (socket-protocol client)))))
26 
27 (deftest tlv ()
28  (is (= 4 (length (serialize (make-instance 'tlv :type 0 :length 1 :value #(1)) :bytes)))))
29 
30 (deftest osc ())
31 
32 (deftest http ()
33  (let ((req (make-http-request))
34  (cb (make-callbacks)))
35  (parse-request
36  req cb
37  (sb-ext:string-to-octets #"GET /cookies HTTP/1.1
38 Host: 127.0.0.1:8080
39 Connection: keep-alive
40 Cache-Control: max-age=0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
41 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
42 Accept-Encoding: gzip,deflate,sdch
43 Accept-Language: en-US,en;q=0.8
44 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
45 Cookie: name=wookie
46 
47 "#))
48  (is cb)
49  (is req)))
50 
51 (deftest req ()
52  (is (req:get (uri:uri "https://compiler.company/index.html"))))
53 
54 (deftest fetch ()
55  (is (fetch:download "https://compiler.company/index.html" :output "/tmp/index.html" :progress t))
56  (is (delete-file "/tmp/index.html")))
57 
58 (deftest cookies ()
59  (let ((cookies (net/cookie:make-cookie-jar))
60  (cookie (net/cookie:make-cookie)))
61  (net/cookie:merge-cookies cookies #(cookie))
62  (is (= 1 (length (net/cookie:cookie-jar-cookies cookies))))
63  (is (net/cookie:cookie= cookie (net/cookie:make-cookie)))
64  (is (stringp (net/cookie:write-cookie-header (list cookie))))))
65 
66 
67 (deftest srv ()
68  (is (pathnamep (default-web-directory))))