-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-bind-valid.sh
More file actions
executable file
·85 lines (68 loc) · 2.13 KB
/
test-bind-valid.sh
File metadata and controls
executable file
·85 lines (68 loc) · 2.13 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
#!/usr/bin/env bash
cleanup() {
echo "Cleaning up..."
if [[ -n "$provider_pid" ]]; then
kill -SIGTERM "$provider_pid" 2>/dev/null
fi
}
./cloudpipe provider &
provider_pid=$!
echo "Provider process started with PID $provider_pid"
trap cleanup EXIT
sleep 1
provider=http://localhost:8001
offer=`curl -s -u foo:bar $provider/backend/offers | jq -r .[0].name`
binding=`curl -s -X POST -u foo:bar $provider/backend/offers/$offer/bindings -H "Content-Type: application/json" -d '
{
"id":"frontend"
}
'
`
pipe=`echo $binding | jq -r ._links.self.href`
eadapter=`curl -s -u foo:bar $provider/backend/offers/$offer | jq -r .defaultAdapters.[0]`
eproto=`curl -s -u foo:bar $provider/backend/offers/$offer/protos | jq -r .[0].id`
adapter=`echo $binding | jq -r .adapters.[0]`
proto=`echo $binding | jq -r .proto`
if [ "$eadapter" != "$adapter" ]; then
echo "Adapters don't match: '$eadapter' != '$adapter'"
exit 1
fi
if [ "$eproto" != "$proto" ]; then
echo "Protos don't match: '$eproto' != '$proto'"
exit 1
fi
eadapterhref=$provider/backend/offers/$offer/adapters/$eadapter
eprotohref=$provider/backend/offers/$offer/protos/$eproto
adapterhref=`curl -s -u foo:bar $pipe | jq -r ._links.adapters.[0].href`
protohref=`curl -s -u foo:bar $pipe | jq -r ._links.proto.href`
if [ "$eadapterhref" != "$adapterhref" ]; then
echo "Adapter Hrefs don't match: '$eadapterhref' != '$adapterhref'"
exit 1
fi
if [ "$eprotohref" != "$protohref" ]; then
echo "Proto Hrefs don't match: '$eprotohref' != '$protohref'"
exit 1
fi
euri=`curl -s -u foo:bar $pipe | jq -r .this.data.URI`
# test that uri can't be updated to an unmatching schema
code=`
curl -s --output /dev/stderr --write-out "%{http_code}" -X PATCH -u foo:bar $provider/backend/pipes/frontend -H "Content-Type: application/json" -d '
{
"this": {
"data":{
"URI": "http://bad.data"
}
}
}
'
`
if [ "$code" != 400 ]; then
echo "Code doesn't match $code != 400"
exit 1
fi
uri=`curl -s -u foo:bar $pipe | jq -r .this.data.URI`
if [ "$euri" != "$uri" ]; then
echo "URIs don't match: '$euri' != '$uri'"
exit 1
fi
echo "SUCCESS"