diff --git a/awx/api/urls/webhooks.py b/awx/api/urls/webhooks.py index 3523d8f04d..1a168d3baa 100644 --- a/awx/api/urls/webhooks.py +++ b/awx/api/urls/webhooks.py @@ -4,7 +4,6 @@ from awx.api.views import ( WebhookKeyView, GithubWebhookReceiver, GitlabWebhookReceiver, - BitbucketWebhookReceiver, ) @@ -12,5 +11,4 @@ urlpatterns = [ url(r'^webhook_key/$', WebhookKeyView.as_view(), name='webhook_key'), url(r'^github/$', GithubWebhookReceiver.as_view(), name='webhook_receiver_github'), url(r'^gitlab/$', GitlabWebhookReceiver.as_view(), name='webhook_receiver_gitlab'), - url(r'^bitbucket/$', BitbucketWebhookReceiver.as_view(), name='webhook_receiver_bitbucket'), ] diff --git a/awx/api/views/__init__.py b/awx/api/views/__init__.py index 2cfce6f9b0..4c4ff93cac 100644 --- a/awx/api/views/__init__.py +++ b/awx/api/views/__init__.py @@ -154,7 +154,6 @@ from awx.api.views.webhooks import ( # noqa WebhookKeyView, GithubWebhookReceiver, GitlabWebhookReceiver, - BitbucketWebhookReceiver, ) diff --git a/awx/api/views/webhooks.py b/awx/api/views/webhooks.py index bd05a55e3b..2ad9ecf840 100644 --- a/awx/api/views/webhooks.py +++ b/awx/api/views/webhooks.py @@ -240,52 +240,3 @@ class GitlabWebhookReceiver(WebhookReceiverBase): # analysis by attackers. if not hmac.compare_digest(force_bytes(obj.webhook_key), self.get_signature()): raise PermissionDenied - - -class BitbucketWebhookReceiver(WebhookReceiverBase): - service = 'bitbucket' - - ref_keys = { - # Bitbucket Server - 'repo:refs_changed': 'changes.0.toHash', - 'repo:comment:added': 'commit', - 'repo:comment:edited': 'commit', - 'repo:comment:deleted': 'commit', - 'pr:opened': 'pullRequest.fromRef.latestCommit', - 'pr:modified': 'pullRequest.fromRef.latestCommit', - 'pr:reviewer:updated': 'pullRequest.fromRef.latestCommit', - 'pr:reviewer:approved': 'pullRequest.fromRef.latestCommit', - 'pr:reviewer:unapproved': 'pullRequest.fromRef.latestCommit', - 'pr:reviewer:needs_work': 'pullRequest.fromRef.latestCommit', - 'pr:merged': 'pullRequest.fromRef.latestCommit', - 'pr:declined': 'pullRequest.fromRef.latestCommit', - 'pr:deleted': 'pullRequest.fromRef.latestCommit', - 'pr:comment:added': 'pullRequest.fromRef.latestCommit', - 'pr:comment:edited': 'pullRequest.fromRef.latestCommit', - 'pr:comment:deleted': 'pullRequest.fromRef.latestCommit', - - # Bitbucket Cloud, aka bitbucket.org - 'repo:push': 'push.changes.0.new.target.hash', - 'repo:commit_comment_created': 'commit.hash', - 'pullrequest:created': 'pullrequest.source.commit', - 'pullrequest:updated': 'pullrequest.source.commit', - 'pullrequest:approved': 'pullrequest.source.commit', - 'pullrequest:unapproved': 'pullrequest.source.commit', - 'pullrequest:fulfilled': 'pullrequest.source.commit', - 'pullrequest:rejected': 'pullrequest.source.commit', - 'pullrequest:comment_created': 'pullrequest.source.commit', - 'pullrequest:comment_updated': 'pullrequest.source.commit', - 'pullrequest:comment_deleted': 'pullrequest.source.commit', - } - - def get_event_type(self): - return self.request.META.get('HTTP_X_EVENT_KEY') - - def get_event_guid(self): - return self.request.META.get('HTTP_X_REQUEST_UUID') - - def get_signature(self): - header_sig = self.request.META.get('HTTP_X_HUB_SIGNATURE') - if not header_sig: - raise PermissionDenied - return force_bytes(header_sig) diff --git a/awx/main/migrations/0092_v360_webhook_mixin.py b/awx/main/migrations/0092_v360_webhook_mixin.py index f2cde2a47f..47308c5661 100644 --- a/awx/main/migrations/0092_v360_webhook_mixin.py +++ b/awx/main/migrations/0092_v360_webhook_mixin.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='jobtemplate', name='webhook_service', - field=models.CharField(blank=True, choices=[('github', 'Github'), ('gitlab', 'Gitlab'), ('bitbucket', 'Bitbucket')], max_length=16), + field=models.CharField(blank=True, choices=[('github', 'Github'), ('gitlab', 'Gitlab')], max_length=16), ), migrations.AddField( model_name='workflowjobtemplate', @@ -39,6 +39,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='workflowjobtemplate', name='webhook_service', - field=models.CharField(blank=True, choices=[('github', 'Github'), ('gitlab', 'Gitlab'), ('bitbucket', 'Bitbucket')], max_length=16), + field=models.CharField(blank=True, choices=[('github', 'Github'), ('gitlab', 'Gitlab')], max_length=16), ), ] diff --git a/awx/main/migrations/0094_v360_webhook_mixin2.py b/awx/main/migrations/0094_v360_webhook_mixin2.py index ff4eb7abc1..9e93d27e20 100644 --- a/awx/main/migrations/0094_v360_webhook_mixin2.py +++ b/awx/main/migrations/0094_v360_webhook_mixin2.py @@ -24,7 +24,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='job', name='webhook_service', - field=models.CharField(blank=True, choices=[('github', 'Github'), ('gitlab', 'Gitlab'), ('bitbucket', 'Bitbucket')], max_length=16), + field=models.CharField(blank=True, choices=[('github', 'Github'), ('gitlab', 'Gitlab')], max_length=16), ), migrations.AddField( model_name='workflowjob', @@ -39,6 +39,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='workflowjob', name='webhook_service', - field=models.CharField(blank=True, choices=[('github', 'Github'), ('gitlab', 'Gitlab'), ('bitbucket', 'Bitbucket')], max_length=16), + field=models.CharField(blank=True, choices=[('github', 'Github'), ('gitlab', 'Gitlab')], max_length=16), ), ] diff --git a/awx/main/models/credential/__init__.py b/awx/main/models/credential/__init__.py index 0091582252..939f824f25 100644 --- a/awx/main/models/credential/__init__.py +++ b/awx/main/models/credential/__init__.py @@ -1001,22 +1001,6 @@ ManagedCredentialType( }, ) -ManagedCredentialType( - namespace='bitbucket_token', - kind='token', - name=ugettext_noop('Bitbucket Personal Access Token'), - managed_by_tower=True, - inputs={ - 'fields': [{ - 'id': 'token', - 'label': ugettext_noop('Token'), - 'type': 'string', - 'secret': True, - }], - 'required': ['token'], - }, -) - ManagedCredentialType( namespace='insights', kind='insights', diff --git a/awx/main/models/mixins.py b/awx/main/models/mixins.py index 7cf5c9fb86..224d1ad930 100644 --- a/awx/main/models/mixins.py +++ b/awx/main/models/mixins.py @@ -498,7 +498,6 @@ class WebhookTemplateMixin(models.Model): SERVICES = [ ('github', "Github"), ('gitlab', "Gitlab"), - ('bitbucket', "Bitbucket"), ] webhook_service = models.CharField( diff --git a/awx/main/tests/functional/test_credential.py b/awx/main/tests/functional/test_credential.py index c241ea002b..c55d97d44e 100644 --- a/awx/main/tests/functional/test_credential.py +++ b/awx/main/tests/functional/test_credential.py @@ -79,7 +79,6 @@ def test_default_cred_types(): 'aws', 'azure_kv', 'azure_rm', - 'bitbucket_token', 'cloudforms', 'conjur', 'gce',