@@ -13,4 +13,188 @@ require http_client
1313
1414require json
1515
16- # temporarily removing public tests - they regularly fail from actions
16+ # Confirm the GET extension works
17+ query III
18+ WITH __input AS (
19+ SELECT
20+ http_get(
21+ 'https://httpbingo.org/delay/0'
22+ ) AS res
23+ ),
24+ __response AS (
25+ SELECT
26+ (res->>'status')::INT AS status,
27+ (res->>'reason') AS reason,
28+ unnest( from_json(((res->>'body')::JSON)->'headers', '{"Host": "VARCHAR[]"}') ) AS features
29+ FROM
30+ __input
31+ )
32+ SELECT
33+ __response.status,
34+ __response.reason,
35+ __response.Host[1] AS host
36+ FROM
37+ __response
38+ ;
39+ ----
40+ 200 OK httpbingo.org
41+
42+ # Confirm the GET extension works with headers and params
43+ query III
44+ WITH __input AS (
45+ SELECT
46+ http_get(
47+ 'https://httpbingo.org/delay/0',
48+ headers => MAP {
49+ 'accept': 'application/json',
50+ },
51+ params => MAP {
52+ 'limit': 10
53+ }
54+ ) AS res
55+ ),
56+ __response AS (
57+ SELECT
58+ (res->>'status')::INT AS status,
59+ (res->>'reason') AS reason,
60+ unnest( from_json(((res->>'body')::JSON)->'headers', '{"Host": "VARCHAR[]"}') ) AS features
61+ FROM
62+ __input
63+ )
64+ SELECT
65+ __response.status,
66+ __response.reason,
67+ __response.Host[1] AS host
68+ FROM
69+ __response
70+ ;
71+ ----
72+ 200 OK httpbingo.org
73+
74+ # Confirm the POST extension works
75+ query III
76+ WITH __input AS (
77+ SELECT
78+ http_post(
79+ 'https://httpbingo.org/delay/0',
80+ headers => MAP {
81+ 'accept': 'application/json',
82+ },
83+ params => MAP {
84+ }
85+ ) AS res
86+ ),
87+ __response AS (
88+ SELECT
89+ (res->>'status')::INT AS status,
90+ (res->>'reason') AS reason,
91+ unnest( from_json(((res->>'body')::JSON)->'headers', '{"Host": "VARCHAR[]"}') ) AS features
92+ FROM
93+ __input
94+ )
95+ SELECT
96+ __response.status,
97+ __response.reason,
98+ __response.Host[1] AS host
99+ FROM
100+ __response
101+ ;
102+ ----
103+ 200 OK httpbingo.org
104+
105+ # Confirm the POST extension works with headers and params
106+ query I
107+ WITH __input AS (
108+ SELECT
109+ http_post(
110+ 'https://earth-search.aws.element84.com/v0/search',
111+ headers => MAP {
112+ 'Content-Type': 'application/json',
113+ 'Accept-Encoding': 'gzip',
114+ 'Accept': 'application/geo+json'
115+ },
116+ params => {
117+ 'collections': ['sentinel-s2-l2a-cogs'],
118+ 'ids': ['S2A_56LPN_20210930_0_L2A'],
119+ 'datetime': '2021-09-30/2021-09-30',
120+ 'limit': 10
121+ }
122+ ) AS res
123+ ),
124+ __response AS (
125+ SELECT
126+ unnest( from_json(((res->>'body')::JSON)->'features', '["json"]') ) AS features
127+ FROM
128+ __input
129+ )
130+ SELECT
131+ features->>'id' AS id
132+ FROM
133+ __response
134+ ;
135+ ----
136+ S2A_56LPN_20210930_0_L2A
137+
138+ # Confirm the POST function with form request works
139+ query III
140+ WITH __input AS (
141+ SELECT
142+ http_post_form(
143+ 'https://httpbingo.org/delay/0',
144+ headers => MAP {
145+ 'accept': 'application/json',
146+ },
147+ params => MAP {
148+ 'limit': 10
149+ }
150+ ) AS res
151+ ),
152+ __response AS (
153+ SELECT
154+ (res->>'status')::INT AS status,
155+ (res->>'reason') AS reason,
156+ unnest( from_json(((res->>'body')::JSON)->'headers', '{"Host": "VARCHAR[]"}') ) AS features
157+ FROM
158+ __input
159+ )
160+ SELECT
161+ __response.status,
162+ __response.reason,
163+ __response.Host[1] AS host
164+ FROM
165+ __response
166+ ;
167+ ----
168+ 200 OK httpbingo.org
169+
170+ # Confirm the POST function with form encoding transmits a single value
171+ query III
172+ WITH __input AS (
173+ SELECT
174+ http_post_form(
175+ 'https://httpbingo.org/delay/0',
176+ headers => MAP {
177+ 'accept': 'application/json',
178+ },
179+ params => MAP {
180+ 'limit': 10
181+ }
182+ ) AS res
183+ ),
184+ __response AS (
185+ SELECT
186+ (res->>'status')::INT AS status,
187+ (res->>'reason') AS reason,
188+ unnest( from_json(((res->>'body')::JSON)->'form', '{"limit": "VARCHAR[]"}') ) AS features
189+ FROM
190+ __input
191+ )
192+ SELECT
193+ __response.status,
194+ __response.reason,
195+ __response.limit[1] AS limit
196+ FROM
197+ __response
198+ ;
199+ ----
200+ 200 OK 10
0 commit comments