· 7 years ago · Mar 01, 2018, 12:56 PM
1 def "Deep link activation"() {
2 given:
3 def webhookKey = '1153AFBD-6E69-4C8A-B78B-E3828C6AFD99'.toLowerCase();
4 def secretKey = 'ece9c236';
5 def webhookSubscription = [
6 "type" : "message_allow",
7 "object" : [
8 "user_id": testAccountId,
9 "key" : webhookKey
10 ],
11 "groupId": testGroupId,
12 "secret" : secretKey
13 ]
14 when:
15 def response = vkSrvClient.post(
16 path : '/webhook/' + webhookKey,
17 body : webhookSubscription,
18 requestContentType: ContentType.JSON
19 )
20 def receivedMessageEnvelope = commandsListener.receiveMessage(3) {
21 def body = new JsonSlurper().parse(it.body);
22 return body.name == "SubscriptionCreated"
23 }
24 then: "subscription with deep link was created"
25 receivedMessageEnvelope != null
26 with(receivedMessageEnvelope.customProperties) {
27 TB_CHANNEL == 'vk'
28 TB_CHANNEL_ID as Integer == -1
29 TB_ACCOUNT_ID as String == 22
30 }
31 def receivedMessage = new JsonSlurper().parse(receivedMessageEnvelope?.body);
32 receivedMessage.accountId == 22
33 receivedMessage.channel == "vk"
34 receivedMessage.channelId == -1
35 receivedMessage.text == webhookSubscription
36 then: "webhook controller worked correctly"
37
38 vkSql.firstRow("SELECT count(1) c FROM vk_srv_db.webhookKey WHERE accountId =?", testAccountId).c == 1
39
40 response.status == 200
41 response.body.$error == null
42 response.body.$value.accountId == testAccountId
43 !(response.body.$value.remoteContact.empty)
44 }