-
Notifications
You must be signed in to change notification settings - Fork 77
/
create-test-user.sh
executable file
·181 lines (141 loc) · 7.75 KB
/
create-test-user.sh
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/sh
XTOKEN=$1
if [ -z $XTOKEN ]; then
echo "The API token is missing, assuming the DEMO API token"
XTOKEN="DEMO"
fi
DATABUNKER="http://localhost:3000"
RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider -XPOST \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"title":"send sms","script":"<script>alert(1);</script>","fulldesc":"full desc","applicableto":"empty"}'`
echo "Create processing activity entity: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/lbasis/send-sms -XPOST \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"module":"login-page","fulldesc":"full","shortdesc":"short","requiredmsg":"required","usercontrol":false,"requiredflag":true}'`
echo "Create legal basis entity: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/blah -XPOST \
-H "X-Bunker-Token: $XTOKEN"`
echo "Trying to link a fake legal basis to processing activity: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/core-send-sms-on-login -XPOST \
-H "X-Bunker-Token: $XTOKEN"`
echo "Linking existing legal basis 2 to processing activity: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/core-send-sms-on-login -XPOST \
-H "X-Bunker-Token: $XTOKEN"`
echo "Linking again existing legal basis 2 to processing activity: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/core-send-email-on-login -XPOST \
-H "X-Bunker-Token: $XTOKEN"`
echo "Linking existing legal basis 3 to processing activity: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/send-sms -XPOST \
-H "X-Bunker-Token: $XTOKEN"`
echo "Linking existing legal basis to processing activity: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/pactivity/share-data-with-sms-provider/send-sms -XDELETE \
-H "X-Bunker-Token: $XTOKEN"`
echo "Unlinking legal basis to processing activity: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/pactivity -H "X-Bunker-Token: $XTOKEN"`
echo "Get a list of processing activities: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/lbasis -H "X-Bunker-Token: $XTOKEN"`
echo "Get a list of legal basis objects: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/lbasis/send-sms -XDELETE -H "X-Bunker-Token: $XTOKEN"`
echo "Deleting legal basis object: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login/email/[email protected] -XPOST \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"lawfulbasis":"contract"}'`
echo "Giving consent for legal basis obj 2: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login -XDELETE -H "X-Bunker-Token: $XTOKEN"`
echo "Revoking legal basis object 2: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/contract-approval/email/[email protected] -XPOST \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"lawfulbasis":"contract"}'`
echo "Giving consent for a fake legal basis: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login/email/[email protected] -XDELETE -H "X-Bunker-Token: $XTOKEN"`
echo "Withdraw legal basis 2 consent: $RESULT"
echo "Creating user."
RESULT=`curl -s $DATABUNKER/v1/user \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"fname":"Test","lname":"Account","email":"[email protected]","phone":"4444","passportid":"123456789","status":"prospect"}'`
STATUS=`echo $RESULT | jq ".status" | tr -d '"'`
if [ "$STATUS" = "error" ]; then
echo "Error to create user, trying to update by phone. Result: $RESULT"
RESULT=`curl -s -X PUT $DATABUNKER/v1/user/phone/4444 \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"fname":"Test","lname":"Account","email":"[email protected]"}'`
echo "Result: $RESULT"
RESULT=`curl -s -X PUT $DATABUNKER/v1/user/email/[email protected] \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"fname":"Test","lname":"Account","phone":"4444"}'`
echo "Result: $RESULT"
STATUS=`echo $RESULT | jq ".status" | tr -d '"'`
fi
if [ "$STATUS" = "error" ]; then
echo "Failed to fetch user by email, got: $RESULT"
exit
fi
TOKEN=`echo $RESULT | jq ".token" | tr -d '"'`
echo "User token is $TOKEN"
RESULT=`curl -s $DATABUNKER/v1/userapp/token/$TOKEN/shipping \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"country":"UK","city":"London","address":"221B Baker Street","postcode":"12345","status":"new"}'`
echo "User shipping record created, status $RESULT"
RESULT=`curl -s $DATABUNKER/v1/userapp/token/$TOKEN/shipping -XPUT \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"status":"delivered"}'`
echo "User shipping record updated, status $RESULT"
RESULT=`curl -s $DATABUNKER/v1/userapp/token/$TOKEN/shipping \
-H "X-Bunker-Token: $XTOKEN"`
echo "User shipping record ready, status $RESULT"
RESULT=`curl -s $DATABUNKER/v1/sharedrecord/token/$TOKEN \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"app":"shipping","fields":"address"}'`
echo "Shared record created, status $RESULT"
RECORD=`echo $RESULT | jq ".record" | tr -d '"'`
echo $RECORD
RESULT=`curl -s $DATABUNKER/v1/get/$RECORD`
echo "Get shared record (no password/access token): $RESULT"
RESULT=`curl -s $DATABUNKER/v1/userapp/token/$TOKEN \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json"`
echo "View list of all user apps $RESULT"
RESULT=`curl -s $DATABUNKER/v1/userapps \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json"`
echo "View list of all apps $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/send-sms/token/$TOKEN -XPOST \
-H "X-Bunker-Token: $XTOKEN" -d "expiration=30s"`
echo "Enable consent send-sms for user by token: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login/email/[email protected] -XPOST \
-H "X-Bunker-Token: $XTOKEN"`
echo "Enable consent send-sms for user by email: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/core-send-sms-on-login/phone/4444 -XDELETE \
-H "X-Bunker-Token: $XTOKEN"`
echo "Withdraw consent send-sms for user by phone: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/send-sms/token/$TOKEN \
-H "X-Bunker-Token: $XTOKEN"`
echo "View this specific consent only: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/token/$TOKEN \
-H "X-Bunker-Token: $XTOKEN"`
echo "View all user consents: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/agreement/send-sms \
-H "X-Bunker-Token: $XTOKEN"`
echo "View all users with send-sms consent on: $RESULT"
SESSION="84493d20-2ea5-11eb-86f0-2e04ce962524"
RESULT=`curl -s $DATABUNKER/v1/session/$SESSION -XPOST \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"clientip":"1.1.1.1","x-forwarded-for":"2.2.2.2","info":"email"}'`
echo "Create session 2: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/session/$SESSION \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json"`
echo "Get session 1: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/sessions/phone/4444 \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json"`
echo "Get sessions: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/session/$SESSION -XPOST \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"clientip":"1.1.1.1","x-forwarded-for":"2.2.2.2","info":"email","phone":"4444"}'`
echo "Create session 2: $RESULT"
RESULT=`curl -s $DATABUNKER/v1/sessions/phone/4444 \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json"`
echo "Get sessions: $RESULT"
echo "Creating user."
RESULT=`curl -s $DATABUNKER/v1/user \
-H "X-Bunker-Token: $XTOKEN" -H "Content-Type: application/json" \
-d '{"test":"custtom-test","custom":"alex"}'`
RESULT=`curl -s $DATABUNKER/v1/user/custom/alex -H "X-Bunker-Token: $XTOKEN"`
echo "Result: $RESULT"