File: change_tests_to_httpbin.patch

package info (click to toggle)
nng 1.11-3
  • links: PTS
  • area: main
  • in suites: sid
  • size: 5,672 kB
  • sloc: ansic: 77,665; sh: 321; cpp: 62; makefile: 30
file content (156 lines) | stat: -rw-r--r-- 4,477 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
From 59d5f279622b2cd7556bf70eb817693f061c4820 Mon Sep 17 00:00:00 2001
From: Garrett D'Amore <garrett@damore.org>
Date: Fri, 30 Jan 2026 22:46:29 -0800
Subject: [PATCH] tests: change from example.com to httpbin for http client
 test

---
 tests/httpclient.c | 53 +++++++++++++++++-----------------------------
 1 file changed, 20 insertions(+), 33 deletions(-)

diff --git a/tests/httpclient.c b/tests/httpclient.c
index e153a987b..1763e225d 100644
--- a/tests/httpclient.c
+++ b/tests/httpclient.c
@@ -26,24 +26,20 @@
 #include "convey.h"
 #include "trantest.h"
 
-const uint8_t example_sum[20] = { 0x4a, 0x3c, 0xe8, 0xee, 0x11, 0xe0, 0x91,
-	0xdd, 0x79, 0x23, 0xf4, 0xd8, 0xc6, 0xe5, 0xb5, 0xe4, 0x1e, 0xc7, 0xc0,
-	0x47 };
-
 const uint8_t chunked_sum[20] = { 0x9b, 0x06, 0xfb, 0xee, 0x51, 0xc6, 0x42,
 	0x69, 0x1c, 0xb3, 0xaa, 0x38, 0xce, 0xb8, 0x0b, 0x3a, 0xc8, 0x3b, 0x96,
 	0x68 };
 
 TestMain("HTTP Client", {
-	Convey("Given a TCP connection to example.com", {
-		nng_aio *        aio;
+	Convey("Given a TCP connection to httpbin.org", {
+		nng_aio         *aio;
 		nng_http_client *cli;
-		nng_http_conn *  http;
-		nng_url *        url;
+		nng_http_conn   *http;
+		nng_url         *url;
 
 		So(nng_aio_alloc(&aio, NULL, NULL) == 0);
 
-		So(nng_url_parse(&url, "http://example.com/") == 0);
+		So(nng_url_parse(&url, "http://httpbin.org/") == 0);
 
 		nng_aio_set_timeout(aio, 10000);
 		So(nng_http_client_alloc(&cli, url) == 0);
@@ -81,7 +77,7 @@ TestMain("HTTP Client", {
 
 			Convey("The message contents are correct", {
 				uint8_t     digest[20];
-				void *      data;
+				void       *data;
 				const char *cstr;
 				size_t      sz;
 				nng_iov     iov;
@@ -106,17 +102,14 @@ TestMain("HTTP Client", {
 				nng_http_conn_read_all(http, aio);
 				nng_aio_wait(aio);
 				So(nng_aio_result(aio) == 0);
-
-				nni_sha1(data, sz, digest);
-				So(memcmp(digest, example_sum, 20) == 0);
 			});
 		});
 	});
 
 	Convey("Given a client", {
-		nng_aio *        aio;
+		nng_aio         *aio;
 		nng_http_client *cli;
-		nng_url *        url;
+		nng_url         *url;
 
 		So(nng_aio_alloc(&aio, NULL, NULL) == 0);
 
@@ -134,7 +127,7 @@ TestMain("HTTP Client", {
 		Convey("One off exchange works", {
 			nng_http_req *req;
 			nng_http_res *res;
-			void *        data;
+			void         *data;
 			size_t        len;
 			uint8_t       digest[20];
 
@@ -150,15 +143,13 @@ TestMain("HTTP Client", {
 			So(nng_aio_result(aio) == 0);
 			So(nng_http_res_get_status(res) == 200);
 			nng_http_res_get_data(res, &data, &len);
-			nni_sha1(data, len, digest);
-			So(memcmp(digest, example_sum, 20) == 0);
 		});
 
 		Convey("Connection reuse works", {
-			nng_http_req * req;
-			nng_http_res * res1;
-			nng_http_res * res2;
-			void *         data;
+			nng_http_req  *req;
+			nng_http_res  *res1;
+			nng_http_res  *res2;
+			void          *data;
 			size_t         len;
 			uint8_t        digest[20];
 			nng_http_conn *conn = NULL;
@@ -185,16 +176,12 @@ TestMain("HTTP Client", {
 			So(nng_aio_result(aio) == 0);
 			So(nng_http_res_get_status(res1) == 200);
 			nng_http_res_get_data(res1, &data, &len);
-			nni_sha1(data, len, digest);
-			So(memcmp(digest, example_sum, 20) == 0);
 
 			nng_http_conn_transact(conn, req, res2, aio);
 			nng_aio_wait(aio);
 			So(nng_aio_result(aio) == 0);
 			So(nng_http_res_get_status(res2) == 200);
 			nng_http_res_get_data(res2, &data, &len);
-			nni_sha1(data, len, digest);
-			So(memcmp(digest, example_sum, 20) == 0);
 		});
 	});
 
@@ -203,11 +190,11 @@ TestMain("HTTP Client", {
 	// are unavoidable in the infrastructure.  We will revisit when we
 	// provide our own HTTP test server on localhost.
 	SkipConvey("Client times out", {
-		nng_aio *        aio;
+		nng_aio         *aio;
 		nng_http_client *cli;
-		nng_url *        url;
-		nng_http_req *   req;
-		nng_http_res *   res;
+		nng_url         *url;
+		nng_http_req    *req;
+		nng_http_res    *res;
 
 		So(nng_aio_alloc(&aio, NULL, NULL) == 0);
 
@@ -234,9 +221,9 @@ TestMain("HTTP Client", {
 	});
 
 	Convey("Given a client (chunked)", {
-		nng_aio *        aio;
+		nng_aio         *aio;
 		nng_http_client *cli;
-		nng_url *        url;
+		nng_url         *url;
 
 		So(nng_aio_alloc(&aio, NULL, NULL) == 0);
 
@@ -257,7 +244,7 @@ TestMain("HTTP Client", {
 		Convey("One off exchange works", {
 			nng_http_req *req;
 			nng_http_res *res;
-			void *        data;
+			void         *data;
 			size_t        len;
 			uint8_t       digest[20];