-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpull.yml
More file actions
156 lines (140 loc) · 6.17 KB
/
pull.yml
File metadata and controls
156 lines (140 loc) · 6.17 KB
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
# Copyright (C) 2021 CGI France
#
# This file is part of LINO.
#
# LINO is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LINO is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LINO. If not, see <http:#www.gnu.org/licenses/>.
name: http pull
testcases:
- name: prepare test
steps:
# Clean working directory
- script: rm -f *
- script: sudo docker compose -p lino stop source dest && sudo docker compose -p lino rm -f source dest && sudo docker compose -p lino up -d source dest && sudo docker compose -p lino up -d --build lino
# .devcontainer and lino http share same test workdir
# edit yaml here is the same as in lino-http's container
- script: lino dataconnector add --password-from-env PASSWORD source postgresql://postgres:sakila@source:5432/postgres?sslmode=disable
- script: count=0; while ! lino dc ping source; do echo wait $count; ((count++)) && ((count>=10)) && break; sleep 1; done
assertions:
- result.code ShouldEqual 0
- script: lino relation extract source
- script: lino table extract source --only-tables
- script: lino id create store
- script: sed -i "s/true/false/g" ingress-descriptor.yaml
- script: lino id set-child-lookup staff_store_id_fkey true
- script: cp * /workspace/tests/workspace
- name: pull bad source
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/badsource
assertions:
- result.statuscode ShouldEqual 404
- |
result.body ShouldContainSubstring '{"error": "Data Connector badsource not found"}'
- name: pull no query
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source
assertions:
- result.statuscode ShouldEqual 200
- result.body ShouldContainSubstring {"address_id":1,"last_update":"2006-02-15T09:57:12Z","manager_staff_id":1,"store_id":1,"staff_store_id_fkey":[{"active":true,"address_id":3,"email":"Mike.Hillyer@sakilastaff.com","first_name":"Mike","last_name":"Hillyer","last_update":"2006-05-16T16:13:11.79328Z","password":"8cb2237d0679ca88db6464eac60da96345513964","picture":"iVBORw0KWgo=","staff_id":1,"store_id":1,"username":"Mike"}]}
- result.body ShouldContainSubstring {"address_id":2,"last_update":"2006-02-15T09:57:12Z","manager_staff_id":2,"store_id":2,"staff_store_id_fkey":[{"active":true,"address_id":4,"email":"Jon.Stephens@sakilastaff.com","first_name":"Jon","last_name":"Stephens","last_update":"2006-05-16T16:13:11.79328Z","password":"8cb2237d0679ca88db6464eac60da96345513964","picture":null,"staff_id":2,"store_id":2,"username":"Jon"}]}
- name: pull limit
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source?limit=1
assertions:
- result.statuscode ShouldEqual 200
- result.bodyjson.address_id ShouldEqual 1
- name: pull filter
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source?filter=address_id:2
assertions:
- result.statuscode ShouldEqual 200
- result.bodyjson.address_id ShouldEqual 2
- name: pull filter empty
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source?filter=address_id:99
assertions:
- result.statuscode ShouldEqual 200
- result.body ShouldBeEmpty
- name: pull filter multi values
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source?filter=address_id:1,store_id:1
assertions:
- result.statuscode ShouldEqual 200
- result.bodyjson.address_id ShouldEqual 1
- name: pull filter without values
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source?filter=address_id
assertions:
- result.statuscode ShouldEqual 400
- |
result.body ShouldContainSubstring '{"error": "param filter must be a string map (key1:value1,key2:value2)"}'
- name: pull table content
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source?table=customer&limit=1
assertions:
- result.statuscode ShouldEqual 200
- result.body ShouldContainSubstring '{"active":1,"activebool":true,"address_id":5,"create_date":"2006-02-14T00:00:00Z","customer_id":1,"email":"MARY.SMITH@sakilacustomer.org","first_name":"MARY","last_name":"SMITH","last_update":"2006-02-15T09:57:20Z","store_id":1}'
- name: pull where
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source?table=customer&where=address_id%3E14&limit=1
assertions:
- result.statuscode ShouldEqual 200
- result.bodyjson.address_id ShouldEqual 15
- name: pull whith good Origin header
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source?limit=1
headers:
Origin: http://localhost:3000
assertions:
- result.statuscode ShouldEqual 200
- result.headers.Access-Control-Allow-Origin ShouldEqual http://localhost:3000
- name: pull with bad Origin header
steps:
- type: http
method: GET
url: http://lino:8000/api/v1/data/source?limit=1
headers:
Origin: http://foo.com
assertions:
- result.statuscode ShouldEqual 200
- result.headers.Access-Control-Allow-Origin ShouldBeNil
- name: pull with bad method
steps:
- type: http
method: POST
url: http://lino:8000/api/v1/
headers:
Origin: http://localhost:3000
assertions:
- result.statuscode ShouldEqual 404
- result.headers.Access-Control-Allow-Origin ShouldBeNil