@@ -48,6 +48,8 @@ func TestMain(m *testing.M) {
48
48
DeploymentStatusEvent ,
49
49
ForkEvent ,
50
50
GollumEvent ,
51
+ InstallationEvent ,
52
+ IntegrationInstallationEvent ,
51
53
IssueCommentEvent ,
52
54
IssuesEvent ,
53
55
LabelEvent ,
@@ -57,6 +59,7 @@ func TestMain(m *testing.M) {
57
59
OrganizationEvent ,
58
60
OrgBlockEvent ,
59
61
PageBuildEvent ,
62
+ PingEvent ,
60
63
ProjectCardEvent ,
61
64
ProjectColumnEvent ,
62
65
ProjectEvent ,
@@ -1309,6 +1312,186 @@ func TestGollumEvent(t *testing.T) {
1309
1312
Equal (t , resp .StatusCode , http .StatusOK )
1310
1313
}
1311
1314
1315
+ func TestInstallationEvent (t * testing.T ) {
1316
+
1317
+ payload := `{
1318
+ "action": "created",
1319
+ "installation": {
1320
+ "id": 80429,
1321
+ "account": {
1322
+ "login": "PombeirP",
1323
+ "id": 138074,
1324
+ "avatar_url": "https://avatars1.githubusercontent.com/u/138074?v=4",
1325
+ "gravatar_id": "",
1326
+ "url": "https://api.github.com/users/PombeirP",
1327
+ "html_url": "https://github.com/PombeirP",
1328
+ "followers_url": "https://api.github.com/users/PombeirP/followers",
1329
+ "following_url": "https://api.github.com/users/PombeirP/following{/other_user}",
1330
+ "gists_url": "https://api.github.com/users/PombeirP/gists{/gist_id}",
1331
+ "starred_url": "https://api.github.com/users/PombeirP/starred{/owner}{/repo}",
1332
+ "subscriptions_url": "https://api.github.com/users/PombeirP/subscriptions",
1333
+ "organizations_url": "https://api.github.com/users/PombeirP/orgs",
1334
+ "repos_url": "https://api.github.com/users/PombeirP/repos",
1335
+ "events_url": "https://api.github.com/users/PombeirP/events{/privacy}",
1336
+ "received_events_url": "https://api.github.com/users/PombeirP/received_events",
1337
+ "type": "User",
1338
+ "site_admin": false
1339
+ },
1340
+ "repository_selection": "selected",
1341
+ "access_tokens_url": "https://api.github.com/installations/80429/access_tokens",
1342
+ "repositories_url": "https://api.github.com/installation/repositories",
1343
+ "html_url": "https://github.com/settings/installations/80429",
1344
+ "app_id": 8157,
1345
+ "target_id": 138074,
1346
+ "target_type": "User",
1347
+ "permissions": {
1348
+ "repository_projects": "write",
1349
+ "issues": "read",
1350
+ "metadata": "read",
1351
+ "pull_requests": "read"
1352
+ },
1353
+ "events": [
1354
+ "pull_request"
1355
+ ],
1356
+ "created_at": 1516025475,
1357
+ "updated_at": 1516025475,
1358
+ "single_file_name": null
1359
+ },
1360
+ "repositories": [
1361
+ {
1362
+ "id": 117381220,
1363
+ "name": "status-github-bot",
1364
+ "full_name": "PombeirP/status-github-bot"
1365
+ }
1366
+ ],
1367
+ "sender": {
1368
+ "login": "PombeirP",
1369
+ "id": 138074,
1370
+ "avatar_url": "https://avatars1.githubusercontent.com/u/138074?v=4",
1371
+ "gravatar_id": "",
1372
+ "url": "https://api.github.com/users/PombeirP",
1373
+ "html_url": "https://github.com/PombeirP",
1374
+ "followers_url": "https://api.github.com/users/PombeirP/followers",
1375
+ "following_url": "https://api.github.com/users/PombeirP/following{/other_user}",
1376
+ "gists_url": "https://api.github.com/users/PombeirP/gists{/gist_id}",
1377
+ "starred_url": "https://api.github.com/users/PombeirP/starred{/owner}{/repo}",
1378
+ "subscriptions_url": "https://api.github.com/users/PombeirP/subscriptions",
1379
+ "organizations_url": "https://api.github.com/users/PombeirP/orgs",
1380
+ "repos_url": "https://api.github.com/users/PombeirP/repos",
1381
+ "events_url": "https://api.github.com/users/PombeirP/events{/privacy}",
1382
+ "received_events_url": "https://api.github.com/users/PombeirP/received_events",
1383
+ "type": "User",
1384
+ "site_admin": false
1385
+ }
1386
+ }
1387
+ `
1388
+
1389
+ req , err := http .NewRequest ("POST" , "http://127.0.0.1:3010/webhooks" , bytes .NewBuffer ([]byte (payload )))
1390
+ req .Header .Set ("Content-Type" , "application/json" )
1391
+ req .Header .Set ("X-Github-Event" , "installation" )
1392
+ req .Header .Set ("X-Hub-Signature" , "sha1=987338c6e5c21794ab6c258abe51284f9b1df728" )
1393
+
1394
+ Equal (t , err , nil )
1395
+
1396
+ client := & http.Client {}
1397
+ resp , err := client .Do (req )
1398
+ Equal (t , err , nil )
1399
+
1400
+ defer resp .Body .Close ()
1401
+
1402
+ Equal (t , resp .StatusCode , http .StatusOK )
1403
+ }
1404
+
1405
+ func TestIntegrationInstallationEvent (t * testing.T ) {
1406
+
1407
+ payload := `{
1408
+ "action": "created",
1409
+ "installation": {
1410
+ "id": 80429,
1411
+ "account": {
1412
+ "login": "PombeirP",
1413
+ "id": 138074,
1414
+ "avatar_url": "https://avatars1.githubusercontent.com/u/138074?v=4",
1415
+ "gravatar_id": "",
1416
+ "url": "https://api.github.com/users/PombeirP",
1417
+ "html_url": "https://github.com/PombeirP",
1418
+ "followers_url": "https://api.github.com/users/PombeirP/followers",
1419
+ "following_url": "https://api.github.com/users/PombeirP/following{/other_user}",
1420
+ "gists_url": "https://api.github.com/users/PombeirP/gists{/gist_id}",
1421
+ "starred_url": "https://api.github.com/users/PombeirP/starred{/owner}{/repo}",
1422
+ "subscriptions_url": "https://api.github.com/users/PombeirP/subscriptions",
1423
+ "organizations_url": "https://api.github.com/users/PombeirP/orgs",
1424
+ "repos_url": "https://api.github.com/users/PombeirP/repos",
1425
+ "events_url": "https://api.github.com/users/PombeirP/events{/privacy}",
1426
+ "received_events_url": "https://api.github.com/users/PombeirP/received_events",
1427
+ "type": "User",
1428
+ "site_admin": false
1429
+ },
1430
+ "repository_selection": "selected",
1431
+ "access_tokens_url": "https://api.github.com/installations/80429/access_tokens",
1432
+ "repositories_url": "https://api.github.com/installation/repositories",
1433
+ "html_url": "https://github.com/settings/installations/80429",
1434
+ "app_id": 8157,
1435
+ "target_id": 138074,
1436
+ "target_type": "User",
1437
+ "permissions": {
1438
+ "repository_projects": "write",
1439
+ "issues": "read",
1440
+ "metadata": "read",
1441
+ "pull_requests": "read"
1442
+ },
1443
+ "events": [
1444
+ "pull_request"
1445
+ ],
1446
+ "created_at": 1516025475,
1447
+ "updated_at": 1516025475,
1448
+ "single_file_name": null
1449
+ },
1450
+ "repositories": [
1451
+ {
1452
+ "id": 117381220,
1453
+ "name": "status-github-bot",
1454
+ "full_name": "PombeirP/status-github-bot"
1455
+ }
1456
+ ],
1457
+ "sender": {
1458
+ "login": "PombeirP",
1459
+ "id": 138074,
1460
+ "avatar_url": "https://avatars1.githubusercontent.com/u/138074?v=4",
1461
+ "gravatar_id": "",
1462
+ "url": "https://api.github.com/users/PombeirP",
1463
+ "html_url": "https://github.com/PombeirP",
1464
+ "followers_url": "https://api.github.com/users/PombeirP/followers",
1465
+ "following_url": "https://api.github.com/users/PombeirP/following{/other_user}",
1466
+ "gists_url": "https://api.github.com/users/PombeirP/gists{/gist_id}",
1467
+ "starred_url": "https://api.github.com/users/PombeirP/starred{/owner}{/repo}",
1468
+ "subscriptions_url": "https://api.github.com/users/PombeirP/subscriptions",
1469
+ "organizations_url": "https://api.github.com/users/PombeirP/orgs",
1470
+ "repos_url": "https://api.github.com/users/PombeirP/repos",
1471
+ "events_url": "https://api.github.com/users/PombeirP/events{/privacy}",
1472
+ "received_events_url": "https://api.github.com/users/PombeirP/received_events",
1473
+ "type": "User",
1474
+ "site_admin": false
1475
+ }
1476
+ }
1477
+ `
1478
+
1479
+ req , err := http .NewRequest ("POST" , "http://127.0.0.1:3010/webhooks" , bytes .NewBuffer ([]byte (payload )))
1480
+ req .Header .Set ("Content-Type" , "application/json" )
1481
+ req .Header .Set ("X-Github-Event" , "integration_installation" )
1482
+ req .Header .Set ("X-Hub-Signature" , "sha1=987338c6e5c21794ab6c258abe51284f9b1df728" )
1483
+
1484
+ Equal (t , err , nil )
1485
+
1486
+ client := & http.Client {}
1487
+ resp , err := client .Do (req )
1488
+ Equal (t , err , nil )
1489
+
1490
+ defer resp .Body .Close ()
1491
+
1492
+ Equal (t , resp .StatusCode , http .StatusOK )
1493
+ }
1494
+
1312
1495
func TestIssueCommentEvent (t * testing.T ) {
1313
1496
1314
1497
payload := `{
@@ -2560,6 +2743,48 @@ func TestPageBuildEvent(t *testing.T) {
2560
2743
Equal (t , resp .StatusCode , http .StatusOK )
2561
2744
}
2562
2745
2746
+ func TestPingEvent (t * testing.T ) {
2747
+
2748
+ payload := `{
2749
+ "zen": "Keep it logically awesome.",
2750
+ "hook_id": 20081052,
2751
+ "hook": {
2752
+ "type": "App",
2753
+ "id": 20081052,
2754
+ "name": "web",
2755
+ "active": true,
2756
+ "events": [
2757
+ "pull_request"
2758
+ ],
2759
+ "config": {
2760
+ "content_type": "json",
2761
+ "insecure_ssl": "0",
2762
+ "secret": "********",
2763
+ "url": "https://ngrok.io/webhook"
2764
+ },
2765
+ "updated_at": "2018-01-15T10:48:54Z",
2766
+ "created_at": "2018-01-15T10:48:54Z",
2767
+ "app_id": 8157
2768
+ }
2769
+ }
2770
+ `
2771
+
2772
+ req , err := http .NewRequest ("POST" , "http://127.0.0.1:3010/webhooks" , bytes .NewBuffer ([]byte (payload )))
2773
+ req .Header .Set ("Content-Type" , "application/json" )
2774
+ req .Header .Set ("X-Github-Event" , "ping" )
2775
+ req .Header .Set ("X-Hub-Signature" , "sha1=f82267eb5c6408d5986209da906747f57c11b33b" )
2776
+
2777
+ Equal (t , err , nil )
2778
+
2779
+ client := & http.Client {}
2780
+ resp , err := client .Do (req )
2781
+ Equal (t , err , nil )
2782
+
2783
+ defer resp .Body .Close ()
2784
+
2785
+ Equal (t , resp .StatusCode , http .StatusOK )
2786
+ }
2787
+
2563
2788
func TestProjectCardEvent (t * testing.T ) {
2564
2789
2565
2790
payload := `{
0 commit comments