Fix bitbucket trigger validation for commits without authors
This commit is contained in:
parent
6e94f63a51
commit
85ed745433
4 changed files with 382 additions and 1 deletions
|
@ -92,7 +92,6 @@ BITBUCKET_WEBHOOK_PAYLOAD_SCHEMA = {
|
|||
'required': ['username'],
|
||||
},
|
||||
},
|
||||
'required': ['user'],
|
||||
},
|
||||
'links': {
|
||||
'type': 'object',
|
||||
|
|
|
@ -9,6 +9,56 @@ from buildtrigger.githubhandler import get_transformed_webhook_payload as gh_web
|
|||
from buildtrigger.gitlabhandler import get_transformed_webhook_payload as gl_webhook
|
||||
|
||||
class TestPrepareTrigger(unittest.TestCase):
|
||||
def test_bitbucket_customer_payload_noauthor(self):
|
||||
with open('test/triggerjson/bitbucket_customer_example_noauthor.json') as f:
|
||||
payload = json.loads(f.read())
|
||||
|
||||
expected = {
|
||||
"commit": "a0ec139843b2bb281ab21a433266ddc498e605dc",
|
||||
"ref": "refs/heads/master",
|
||||
"git_url": "git@bitbucket.org:lightsidelabs/svc-identity.git",
|
||||
"commit_info": {
|
||||
"url": "https://bitbucket.org/lightsidelabs/svc-identity/commits/a0ec139843b2bb281ab21a433266ddc498e605dc",
|
||||
"date": "2015-09-25T00:55:08+00:00",
|
||||
"message": "Update version.py to 0.1.2 [skip ci]\n\n(by utilitybelt/scripts/autotag_version.py)\n",
|
||||
"committer": {
|
||||
"username": "LightSide_CodeShip",
|
||||
"url": "https://bitbucket.org/LightSide_CodeShip/",
|
||||
"avatar_url": "https://bitbucket.org/account/LightSide_CodeShip/avatar/32/",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
created = bb_webhook(payload)
|
||||
self.assertEquals(expected, created)
|
||||
validate(created, METADATA_SCHEMA)
|
||||
|
||||
|
||||
def test_bitbucket_customer_payload_tag(self):
|
||||
with open('test/triggerjson/bitbucket_customer_example_tag.json') as f:
|
||||
payload = json.loads(f.read())
|
||||
|
||||
expected = {
|
||||
"commit": "a0ec139843b2bb281ab21a433266ddc498e605dc",
|
||||
"ref": "refs/tags/0.1.2",
|
||||
"git_url": "git@bitbucket.org:lightsidelabs/svc-identity.git",
|
||||
"commit_info": {
|
||||
"url": "https://bitbucket.org/lightsidelabs/svc-identity/commits/a0ec139843b2bb281ab21a433266ddc498e605dc",
|
||||
"date": "2015-09-25T00:55:08+00:00",
|
||||
"message": "Update version.py to 0.1.2 [skip ci]\n\n(by utilitybelt/scripts/autotag_version.py)\n",
|
||||
"committer": {
|
||||
"username": "LightSide_CodeShip",
|
||||
"url": "https://bitbucket.org/LightSide_CodeShip/",
|
||||
"avatar_url": "https://bitbucket.org/account/LightSide_CodeShip/avatar/32/",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
created = bb_webhook(payload)
|
||||
self.assertEquals(expected, created)
|
||||
validate(created, METADATA_SCHEMA)
|
||||
|
||||
|
||||
def test_bitbucket_commit(self):
|
||||
with open('test/triggerjson/bitbucket_commit.json') as f:
|
||||
commit = json.loads(f.read())
|
||||
|
|
215
test/triggerjson/bitbucket_customer_example_noauthor.json
Normal file
215
test/triggerjson/bitbucket_customer_example_noauthor.json
Normal file
|
@ -0,0 +1,215 @@
|
|||
{
|
||||
"actor": {
|
||||
"username": "LightSide_CodeShip",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/users/LightSide_CodeShip"
|
||||
},
|
||||
"avatar": {
|
||||
"href": "https://bitbucket.org/account/LightSide_CodeShip/avatar/32/"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/LightSide_CodeShip/"
|
||||
}
|
||||
},
|
||||
"uuid": "{d009ab20-b8b8-4840-9491-bfe72fbf666e}",
|
||||
"type": "user",
|
||||
"display_name": "CodeShip Tagging"
|
||||
},
|
||||
"repository": {
|
||||
"full_name": "lightsidelabs/svc-identity",
|
||||
"name": "svc-identity",
|
||||
"scm": "git",
|
||||
"type": "repository",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity"
|
||||
},
|
||||
"avatar": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/avatar/16/"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity"
|
||||
}
|
||||
},
|
||||
"is_private": true,
|
||||
"uuid": "{3400bed9-5cde-45b9-8d86-c1dac5d5e610}",
|
||||
"owner": {
|
||||
"username": "lightsidelabs",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/teams/lightsidelabs"
|
||||
},
|
||||
"avatar": {
|
||||
"href": "https://bitbucket.org/account/lightsidelabs/avatar/32/"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/"
|
||||
}
|
||||
},
|
||||
"uuid": "{456c5f28-7338-4d89-9506-c7b889ba2d11}",
|
||||
"type": "team",
|
||||
"display_name": "LightSIDE Labs"
|
||||
}
|
||||
},
|
||||
"push": {
|
||||
"changes": [
|
||||
{
|
||||
"commits": [
|
||||
{
|
||||
"hash": "a0ec139843b2bb281ab21a433266ddc498e605dc",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commit/a0ec139843b2bb281ab21a433266ddc498e605dc"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/commits/a0ec139843b2bb281ab21a433266ddc498e605dc"
|
||||
}
|
||||
},
|
||||
"author": {
|
||||
"raw": "scripts/autotag_version.py <utilitybelt@lightside>"
|
||||
},
|
||||
"type": "commit",
|
||||
"message": "Update version.py to 0.1.2 [skip ci]\n\n(by utilitybelt/scripts/autotag_version.py)\n"
|
||||
}
|
||||
],
|
||||
"created": false,
|
||||
"forced": false,
|
||||
"old": {
|
||||
"target": {
|
||||
"parents": [
|
||||
{
|
||||
"hash": "bd749165b0c50c65c15fc4df526b8e9df26eff10",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commit/bd749165b0c50c65c15fc4df526b8e9df26eff10"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/commits/bd749165b0c50c65c15fc4df526b8e9df26eff10"
|
||||
}
|
||||
},
|
||||
"type": "commit"
|
||||
},
|
||||
{
|
||||
"hash": "910b5624b74190dfaa51938d851563a4c5254926",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commit/910b5624b74190dfaa51938d851563a4c5254926"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/commits/910b5624b74190dfaa51938d851563a4c5254926"
|
||||
}
|
||||
},
|
||||
"type": "commit"
|
||||
}
|
||||
],
|
||||
"date": "2015-09-25T00:54:41+00:00",
|
||||
"type": "commit",
|
||||
"message": "Merged in create-update-user (pull request #3)\n\nCreate + update identity\n",
|
||||
"hash": "263736ecc250113fad56a93f83b712093554ad42",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commit/263736ecc250113fad56a93f83b712093554ad42"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/commits/263736ecc250113fad56a93f83b712093554ad42"
|
||||
}
|
||||
},
|
||||
"author": {
|
||||
"raw": "Chris Winters <chris@cwinters.com>",
|
||||
"user": {
|
||||
"username": "cwinters",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/users/cwinters"
|
||||
},
|
||||
"avatar": {
|
||||
"href": "https://bitbucket.org/account/cwinters/avatar/32/"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/cwinters/"
|
||||
}
|
||||
},
|
||||
"uuid": "{a6209615-6d75-4294-8181-dbf96d40fc6b}",
|
||||
"type": "user",
|
||||
"display_name": "Chris Winters"
|
||||
}
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/refs/branches/master"
|
||||
},
|
||||
"commits": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commits/master"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/branch/master"
|
||||
}
|
||||
},
|
||||
"name": "master",
|
||||
"type": "branch"
|
||||
},
|
||||
"links": {
|
||||
"diff": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/diff/a0ec139843b2bb281ab21a433266ddc498e605dc..263736ecc250113fad56a93f83b712093554ad42"
|
||||
},
|
||||
"commits": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commits?include=a0ec139843b2bb281ab21a433266ddc498e605dc&exclude=263736ecc250113fad56a93f83b712093554ad42"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/branches/compare/a0ec139843b2bb281ab21a433266ddc498e605dc..263736ecc250113fad56a93f83b712093554ad42"
|
||||
}
|
||||
},
|
||||
"new": {
|
||||
"target": {
|
||||
"parents": [
|
||||
{
|
||||
"hash": "263736ecc250113fad56a93f83b712093554ad42",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commit/263736ecc250113fad56a93f83b712093554ad42"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/commits/263736ecc250113fad56a93f83b712093554ad42"
|
||||
}
|
||||
},
|
||||
"type": "commit"
|
||||
}
|
||||
],
|
||||
"date": "2015-09-25T00:55:08+00:00",
|
||||
"type": "commit",
|
||||
"message": "Update version.py to 0.1.2 [skip ci]\n\n(by utilitybelt/scripts/autotag_version.py)\n",
|
||||
"hash": "a0ec139843b2bb281ab21a433266ddc498e605dc",
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commit/a0ec139843b2bb281ab21a433266ddc498e605dc"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/commits/a0ec139843b2bb281ab21a433266ddc498e605dc"
|
||||
}
|
||||
},
|
||||
"author": {
|
||||
"raw": "scripts/autotag_version.py <utilitybelt@lightside>"
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/refs/branches/master"
|
||||
},
|
||||
"commits": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commits/master"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/branch/master"
|
||||
}
|
||||
},
|
||||
"name": "master",
|
||||
"type": "branch"
|
||||
},
|
||||
"closed": false,
|
||||
"truncated": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
117
test/triggerjson/bitbucket_customer_example_tag.json
Normal file
117
test/triggerjson/bitbucket_customer_example_tag.json
Normal file
|
@ -0,0 +1,117 @@
|
|||
{
|
||||
"push": {
|
||||
"changes": [
|
||||
{
|
||||
"links": {
|
||||
"commits": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commits?include=a0ec139843b2bb281ab21a433266ddc498e605dc"
|
||||
}
|
||||
},
|
||||
"closed": false,
|
||||
"new": {
|
||||
"target": {
|
||||
"date": "2015-09-25T00:55:08+00:00",
|
||||
"links": {
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/commits/a0ec139843b2bb281ab21a433266ddc498e605dc"
|
||||
},
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commit/a0ec139843b2bb281ab21a433266ddc498e605dc"
|
||||
}
|
||||
},
|
||||
"message": "Update version.py to 0.1.2 [skip ci]\n\n(by utilitybelt/scripts/autotag_version.py)\n",
|
||||
"type": "commit",
|
||||
"parents": [
|
||||
{
|
||||
"links": {
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/commits/263736ecc250113fad56a93f83b712093554ad42"
|
||||
},
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commit/263736ecc250113fad56a93f83b712093554ad42"
|
||||
}
|
||||
},
|
||||
"hash": "263736ecc250113fad56a93f83b712093554ad42",
|
||||
"type": "commit"
|
||||
}
|
||||
],
|
||||
"hash": "a0ec139843b2bb281ab21a433266ddc498e605dc",
|
||||
"author": {
|
||||
"raw": "scripts/autotag_version.py <utilitybelt@lightside>"
|
||||
}
|
||||
},
|
||||
"name": "0.1.2",
|
||||
"links": {
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/commits/tag/0.1.2"
|
||||
},
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/refs/tags/0.1.2"
|
||||
},
|
||||
"commits": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity/commits/0.1.2"
|
||||
}
|
||||
},
|
||||
"type": "tag"
|
||||
},
|
||||
"truncated": false,
|
||||
"created": true,
|
||||
"old": null,
|
||||
"forced": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"name": "svc-identity",
|
||||
"links": {
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity"
|
||||
},
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/repositories/lightsidelabs/svc-identity"
|
||||
},
|
||||
"avatar": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/svc-identity/avatar/16/"
|
||||
}
|
||||
},
|
||||
"is_private": true,
|
||||
"type": "repository",
|
||||
"scm": "git",
|
||||
"owner": {
|
||||
"username": "lightsidelabs",
|
||||
"links": {
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/lightsidelabs/"
|
||||
},
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/teams/lightsidelabs"
|
||||
},
|
||||
"avatar": {
|
||||
"href": "https://bitbucket.org/account/lightsidelabs/avatar/32/"
|
||||
}
|
||||
},
|
||||
"display_name": "LightSIDE Labs",
|
||||
"uuid": "{456c5f28-7338-4d89-9506-c7b889ba2d11}",
|
||||
"type": "team"
|
||||
},
|
||||
"full_name": "lightsidelabs/svc-identity",
|
||||
"uuid": "{3400bed9-5cde-45b9-8d86-c1dac5d5e610}"
|
||||
},
|
||||
"actor": {
|
||||
"username": "LightSide_CodeShip",
|
||||
"links": {
|
||||
"html": {
|
||||
"href": "https://bitbucket.org/LightSide_CodeShip/"
|
||||
},
|
||||
"self": {
|
||||
"href": "https://api.bitbucket.org/2.0/users/LightSide_CodeShip"
|
||||
},
|
||||
"avatar": {
|
||||
"href": "https://bitbucket.org/account/LightSide_CodeShip/avatar/32/"
|
||||
}
|
||||
},
|
||||
"display_name": "CodeShip Tagging",
|
||||
"uuid": "{d009ab20-b8b8-4840-9491-bfe72fbf666e}",
|
||||
"type": "user"
|
||||
}
|
||||
}
|
Reference in a new issue