@@ -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 ,
@@ -1309,6 +1311,186 @@ func TestGollumEvent(t *testing.T) {
1309
1311
Equal (t , resp .StatusCode , http .StatusOK )
1310
1312
}
1311
1313
1314
+ func TestInstallationEvent (t * testing.T ) {
1315
+
1316
+ payload := `{
1317
+ "action": "created",
1318
+ "installation": {
1319
+ "id": 80429,
1320
+ "account": {
1321
+ "login": "PombeirP",
1322
+ "id": 138074,
1323
+ "avatar_url": "https://avatars1.githubusercontent.com/u/138074?v=4",
1324
+ "gravatar_id": "",
1325
+ "url": "https://api.github.com/users/PombeirP",
1326
+ "html_url": "https://github.com/PombeirP",
1327
+ "followers_url": "https://api.github.com/users/PombeirP/followers",
1328
+ "following_url": "https://api.github.com/users/PombeirP/following{/other_user}",
1329
+ "gists_url": "https://api.github.com/users/PombeirP/gists{/gist_id}",
1330
+ "starred_url": "https://api.github.com/users/PombeirP/starred{/owner}{/repo}",
1331
+ "subscriptions_url": "https://api.github.com/users/PombeirP/subscriptions",
1332
+ "organizations_url": "https://api.github.com/users/PombeirP/orgs",
1333
+ "repos_url": "https://api.github.com/users/PombeirP/repos",
1334
+ "events_url": "https://api.github.com/users/PombeirP/events{/privacy}",
1335
+ "received_events_url": "https://api.github.com/users/PombeirP/received_events",
1336
+ "type": "User",
1337
+ "site_admin": false
1338
+ },
1339
+ "repository_selection": "selected",
1340
+ "access_tokens_url": "https://api.github.com/installations/80429/access_tokens",
1341
+ "repositories_url": "https://api.github.com/installation/repositories",
1342
+ "html_url": "https://github.com/settings/installations/80429",
1343
+ "app_id": 8157,
1344
+ "target_id": 138074,
1345
+ "target_type": "User",
1346
+ "permissions": {
1347
+ "repository_projects": "write",
1348
+ "issues": "read",
1349
+ "metadata": "read",
1350
+ "pull_requests": "read"
1351
+ },
1352
+ "events": [
1353
+ "pull_request"
1354
+ ],
1355
+ "created_at": 1516025475,
1356
+ "updated_at": 1516025475,
1357
+ "single_file_name": null
1358
+ },
1359
+ "repositories": [
1360
+ {
1361
+ "id": 117381220,
1362
+ "name": "status-github-bot",
1363
+ "full_name": "PombeirP/status-github-bot"
1364
+ }
1365
+ ],
1366
+ "sender": {
1367
+ "login": "PombeirP",
1368
+ "id": 138074,
1369
+ "avatar_url": "https://avatars1.githubusercontent.com/u/138074?v=4",
1370
+ "gravatar_id": "",
1371
+ "url": "https://api.github.com/users/PombeirP",
1372
+ "html_url": "https://github.com/PombeirP",
1373
+ "followers_url": "https://api.github.com/users/PombeirP/followers",
1374
+ "following_url": "https://api.github.com/users/PombeirP/following{/other_user}",
1375
+ "gists_url": "https://api.github.com/users/PombeirP/gists{/gist_id}",
1376
+ "starred_url": "https://api.github.com/users/PombeirP/starred{/owner}{/repo}",
1377
+ "subscriptions_url": "https://api.github.com/users/PombeirP/subscriptions",
1378
+ "organizations_url": "https://api.github.com/users/PombeirP/orgs",
1379
+ "repos_url": "https://api.github.com/users/PombeirP/repos",
1380
+ "events_url": "https://api.github.com/users/PombeirP/events{/privacy}",
1381
+ "received_events_url": "https://api.github.com/users/PombeirP/received_events",
1382
+ "type": "User",
1383
+ "site_admin": false
1384
+ }
1385
+ }
1386
+ `
1387
+
1388
+ req , err := http .NewRequest ("POST" , "http://127.0.0.1:3010/webhooks" , bytes .NewBuffer ([]byte (payload )))
1389
+ req .Header .Set ("Content-Type" , "application/json" )
1390
+ req .Header .Set ("X-Github-Event" , "installation" )
1391
+ req .Header .Set ("X-Hub-Signature" , "sha1=987338c6e5c21794ab6c258abe51284f9b1df728" )
1392
+
1393
+ Equal (t , err , nil )
1394
+
1395
+ client := & http.Client {}
1396
+ resp , err := client .Do (req )
1397
+ Equal (t , err , nil )
1398
+
1399
+ defer resp .Body .Close ()
1400
+
1401
+ Equal (t , resp .StatusCode , http .StatusOK )
1402
+ }
1403
+
1404
+ func TestIntegrationInstallationEvent (t * testing.T ) {
1405
+
1406
+ payload := `{
1407
+ "action": "created",
1408
+ "installation": {
1409
+ "id": 80429,
1410
+ "account": {
1411
+ "login": "PombeirP",
1412
+ "id": 138074,
1413
+ "avatar_url": "https://avatars1.githubusercontent.com/u/138074?v=4",
1414
+ "gravatar_id": "",
1415
+ "url": "https://api.github.com/users/PombeirP",
1416
+ "html_url": "https://github.com/PombeirP",
1417
+ "followers_url": "https://api.github.com/users/PombeirP/followers",
1418
+ "following_url": "https://api.github.com/users/PombeirP/following{/other_user}",
1419
+ "gists_url": "https://api.github.com/users/PombeirP/gists{/gist_id}",
1420
+ "starred_url": "https://api.github.com/users/PombeirP/starred{/owner}{/repo}",
1421
+ "subscriptions_url": "https://api.github.com/users/PombeirP/subscriptions",
1422
+ "organizations_url": "https://api.github.com/users/PombeirP/orgs",
1423
+ "repos_url": "https://api.github.com/users/PombeirP/repos",
1424
+ "events_url": "https://api.github.com/users/PombeirP/events{/privacy}",
1425
+ "received_events_url": "https://api.github.com/users/PombeirP/received_events",
1426
+ "type": "User",
1427
+ "site_admin": false
1428
+ },
1429
+ "repository_selection": "selected",
1430
+ "access_tokens_url": "https://api.github.com/installations/80429/access_tokens",
1431
+ "repositories_url": "https://api.github.com/installation/repositories",
1432
+ "html_url": "https://github.com/settings/installations/80429",
1433
+ "app_id": 8157,
1434
+ "target_id": 138074,
1435
+ "target_type": "User",
1436
+ "permissions": {
1437
+ "repository_projects": "write",
1438
+ "issues": "read",
1439
+ "metadata": "read",
1440
+ "pull_requests": "read"
1441
+ },
1442
+ "events": [
1443
+ "pull_request"
1444
+ ],
1445
+ "created_at": 1516025475,
1446
+ "updated_at": 1516025475,
1447
+ "single_file_name": null
1448
+ },
1449
+ "repositories": [
1450
+ {
1451
+ "id": 117381220,
1452
+ "name": "status-github-bot",
1453
+ "full_name": "PombeirP/status-github-bot"
1454
+ }
1455
+ ],
1456
+ "sender": {
1457
+ "login": "PombeirP",
1458
+ "id": 138074,
1459
+ "avatar_url": "https://avatars1.githubusercontent.com/u/138074?v=4",
1460
+ "gravatar_id": "",
1461
+ "url": "https://api.github.com/users/PombeirP",
1462
+ "html_url": "https://github.com/PombeirP",
1463
+ "followers_url": "https://api.github.com/users/PombeirP/followers",
1464
+ "following_url": "https://api.github.com/users/PombeirP/following{/other_user}",
1465
+ "gists_url": "https://api.github.com/users/PombeirP/gists{/gist_id}",
1466
+ "starred_url": "https://api.github.com/users/PombeirP/starred{/owner}{/repo}",
1467
+ "subscriptions_url": "https://api.github.com/users/PombeirP/subscriptions",
1468
+ "organizations_url": "https://api.github.com/users/PombeirP/orgs",
1469
+ "repos_url": "https://api.github.com/users/PombeirP/repos",
1470
+ "events_url": "https://api.github.com/users/PombeirP/events{/privacy}",
1471
+ "received_events_url": "https://api.github.com/users/PombeirP/received_events",
1472
+ "type": "User",
1473
+ "site_admin": false
1474
+ }
1475
+ }
1476
+ `
1477
+
1478
+ req , err := http .NewRequest ("POST" , "http://127.0.0.1:3010/webhooks" , bytes .NewBuffer ([]byte (payload )))
1479
+ req .Header .Set ("Content-Type" , "application/json" )
1480
+ req .Header .Set ("X-Github-Event" , "integration_installation" )
1481
+ req .Header .Set ("X-Hub-Signature" , "sha1=987338c6e5c21794ab6c258abe51284f9b1df728" )
1482
+
1483
+ Equal (t , err , nil )
1484
+
1485
+ client := & http.Client {}
1486
+ resp , err := client .Do (req )
1487
+ Equal (t , err , nil )
1488
+
1489
+ defer resp .Body .Close ()
1490
+
1491
+ Equal (t , resp .StatusCode , http .StatusOK )
1492
+ }
1493
+
1312
1494
func TestIssueCommentEvent (t * testing.T ) {
1313
1495
1314
1496
payload := `{
0 commit comments