Fix GH schema for missing usernames and add test
This commit is contained in:
parent
1bba472c14
commit
18cfe676ee
3 changed files with 164 additions and 2 deletions
|
@ -56,7 +56,6 @@ GITHUB_WEBHOOK_PAYLOAD_SCHEMA = {
|
|||
'type': 'string'
|
||||
},
|
||||
},
|
||||
'required': ['username'],
|
||||
},
|
||||
'committer': {
|
||||
'type': 'object',
|
||||
|
@ -71,7 +70,6 @@ GITHUB_WEBHOOK_PAYLOAD_SCHEMA = {
|
|||
'type': 'string'
|
||||
},
|
||||
},
|
||||
'required': ['username'],
|
||||
},
|
||||
},
|
||||
'required': ['id', 'url', 'message', 'timestamp'],
|
||||
|
|
|
@ -186,6 +186,21 @@ class TestPrepareTrigger(unittest.TestCase):
|
|||
self.assertSchema('gitlab_webhook', expected, gl_webhook)
|
||||
|
||||
|
||||
def test_github_webhook_payload_known_issue(self):
|
||||
expected = {
|
||||
"commit": "118b07121695d9f2e40a5ff264fdcc2917680870",
|
||||
"ref": "refs/heads/master",
|
||||
"git_url": "git@github.com:silas/docker-test.git",
|
||||
"commit_info": {
|
||||
"url": "https://github.com/silas/docker-test/commit/118b07121695d9f2e40a5ff264fdcc2917680870",
|
||||
"date": "2015-09-25T14:55:11-04:00",
|
||||
"message": "Fail",
|
||||
},
|
||||
}
|
||||
|
||||
self.assertSchema('github_webhook_noname', expected, gh_webhook)
|
||||
|
||||
|
||||
def test_github_webhook_payload_missing_fields(self):
|
||||
expected = {
|
||||
'commit': u'410f4cdf8ff09b87f245b13845e8497f90b90a4c',
|
||||
|
|
149
test/triggerjson/github_webhook_noname.json
Normal file
149
test/triggerjson/github_webhook_noname.json
Normal file
|
@ -0,0 +1,149 @@
|
|||
{
|
||||
"ref": "refs/heads/master",
|
||||
"before": "9716b516939221dc754a056e0f9ddf599e71d4b8",
|
||||
"after": "118b07121695d9f2e40a5ff264fdcc2917680870",
|
||||
"created": false,
|
||||
"deleted": false,
|
||||
"forced": false,
|
||||
"base_ref": null,
|
||||
"compare": "https://github.com/silas/docker-test/compare/9716b5169392...118b07121695",
|
||||
"commits": [
|
||||
{
|
||||
"id": "118b07121695d9f2e40a5ff264fdcc2917680870",
|
||||
"distinct": true,
|
||||
"message": "Fail",
|
||||
"timestamp": "2015-09-25T14:55:11-04:00",
|
||||
"url": "https://github.com/silas/docker-test/commit/118b07121695d9f2e40a5ff264fdcc2917680870",
|
||||
"author": {
|
||||
"name": "Silas Sewell",
|
||||
"email": "silas@sewell-fail.org"
|
||||
},
|
||||
"committer": {
|
||||
"name": "Silas Sewell",
|
||||
"email": "silas@sewell-fail.org"
|
||||
},
|
||||
"added": [],
|
||||
"removed": [],
|
||||
"modified": [
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
],
|
||||
"head_commit": {
|
||||
"id": "118b07121695d9f2e40a5ff264fdcc2917680870",
|
||||
"distinct": true,
|
||||
"message": "Fail",
|
||||
"timestamp": "2015-09-25T14:55:11-04:00",
|
||||
"url": "https://github.com/silas/docker-test/commit/118b07121695d9f2e40a5ff264fdcc2917680870",
|
||||
"author": {
|
||||
"name": "Silas Sewell",
|
||||
"email": "silas@sewell-fail.org"
|
||||
},
|
||||
"committer": {
|
||||
"name": "Silas Sewell",
|
||||
"email": "silas@sewell-fail.org"
|
||||
},
|
||||
"added": [],
|
||||
"removed": [],
|
||||
"modified": [
|
||||
"README.md"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"id": 42467431,
|
||||
"name": "docker-test",
|
||||
"full_name": "silas/docker-test",
|
||||
"owner": {
|
||||
"name": "silas",
|
||||
"email": "silas@sewell.org"
|
||||
},
|
||||
"private": false,
|
||||
"html_url": "https://github.com/silas/docker-test",
|
||||
"description": "",
|
||||
"fork": false,
|
||||
"url": "https://github.com/silas/docker-test",
|
||||
"forks_url": "https://api.github.com/repos/silas/docker-test/forks",
|
||||
"keys_url": "https://api.github.com/repos/silas/docker-test/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/silas/docker-test/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/silas/docker-test/teams",
|
||||
"hooks_url": "https://api.github.com/repos/silas/docker-test/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/silas/docker-test/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/silas/docker-test/events",
|
||||
"assignees_url": "https://api.github.com/repos/silas/docker-test/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/silas/docker-test/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/silas/docker-test/tags",
|
||||
"blobs_url": "https://api.github.com/repos/silas/docker-test/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/silas/docker-test/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/silas/docker-test/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/silas/docker-test/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/silas/docker-test/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/silas/docker-test/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/silas/docker-test/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/silas/docker-test/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/silas/docker-test/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/silas/docker-test/subscription",
|
||||
"commits_url": "https://api.github.com/repos/silas/docker-test/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/silas/docker-test/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/silas/docker-test/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/silas/docker-test/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/silas/docker-test/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/silas/docker-test/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/silas/docker-test/merges",
|
||||
"archive_url": "https://api.github.com/repos/silas/docker-test/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/silas/docker-test/downloads",
|
||||
"issues_url": "https://api.github.com/repos/silas/docker-test/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/silas/docker-test/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/silas/docker-test/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/silas/docker-test/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/silas/docker-test/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/silas/docker-test/releases{/id}",
|
||||
"created_at": 1442254053,
|
||||
"updated_at": "2015-09-14T18:07:33Z",
|
||||
"pushed_at": 1443207315,
|
||||
"git_url": "git://github.com/silas/docker-test.git",
|
||||
"ssh_url": "git@github.com:silas/docker-test.git",
|
||||
"clone_url": "https://github.com/silas/docker-test.git",
|
||||
"svn_url": "https://github.com/silas/docker-test",
|
||||
"homepage": null,
|
||||
"size": 108,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": null,
|
||||
"has_issues": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"open_issues_count": 0,
|
||||
"forks": 0,
|
||||
"open_issues": 0,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"stargazers": 0,
|
||||
"master_branch": "master"
|
||||
},
|
||||
"pusher": {
|
||||
"name": "silas",
|
||||
"email": "silas@sewell.org"
|
||||
},
|
||||
"sender": {
|
||||
"login": "silas",
|
||||
"id": 18528,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/18528?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/silas",
|
||||
"html_url": "https://github.com/silas",
|
||||
"followers_url": "https://api.github.com/users/silas/followers",
|
||||
"following_url": "https://api.github.com/users/silas/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/silas/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/silas/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/silas/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/silas/orgs",
|
||||
"repos_url": "https://api.github.com/users/silas/repos",
|
||||
"events_url": "https://api.github.com/users/silas/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/silas/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
}
|
||||
}
|
Reference in a new issue