Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@unittest.expectedFailure
def test_l10nbot_allowed_in_gate_and_submit(self):
gate = self.getPipeline('gate-and-submit').manager
change = zuul.model.Change('mediawiki/core')
l10n_event = zuul.model.TriggerEvent()
l10n_event.type = 'comment-added'
l10n_event.account = {'email': 'l10n-bot@translatewiki.net'}
l10n_event.approvals = [{'type': 'Code-Review',
'description': 'Code Review',
'value': '2',
'by': {'email': 'l10n-bot@translatewiki.net'},
}]
self.assertTrue(gate.eventMatches(l10n_event, change))
def test_recheck_comment_trusted_user(self):
test_manager = self.getPipeline('test').manager
change = zuul.model.Change('mediawiki/core')
change.branch = 'master'
event = zuul.model.TriggerEvent()
event.type = 'comment-added'
event.comment = 'Patch Set 1:\n\nrecheck'
event.account = {'email': 'jdoe@wikimedia.org'}
event.branch = change.branch
self.assertTrue(test_manager.eventMatches(event, change))
def test_recheck_comment_trusted_user_recheck_buried_in_comment_1(self):
test_manager = self.getPipeline('test').manager
change = zuul.model.Change('mediawiki/core')
change.branch = 'master'
event = zuul.model.TriggerEvent()
event.type = 'comment-added'
extra_comment = "let's wait a bit before recheck, Zuul looks busy"
event.comment = 'Patch Set 1:\n\n' + extra_comment
event.account = {'email': 'jdoe@wikimedia.org'}
event.branch = change.branch
self.assertFalse(test_manager.eventMatches(event, change))
def test_recheck_comment_trusted_user_extra_comment_2(self):
test_manager = self.getPipeline('test').manager
change = zuul.model.Change('mediawiki/core')
change.branch = 'master'
event = zuul.model.TriggerEvent()
event.type = 'comment-added'
extra_comment = 'recheck \u2013 Jenkins failure looks unrelated'
event.comment = 'Patch Set 1:\n\n' + extra_comment
event.account = {'email': 'jdoe@wikimedia.org'}
event.branch = change.branch
self.assertTrue(test_manager.eventMatches(event, change))
def test_recheck_with_verified_vote_plus_2(self):
test_manager = self.getPipeline('test').manager
change = zuul.model.Change('mediawiki/core')
change.branch = 'master'
event = zuul.model.TriggerEvent()
event.type = 'comment-added'
event.comment = 'Patch Set 1: Verified+2\n\nrecheck'
event.account = {'email': 'jdoe@wikimedia.org'}
event.branch = change.branch
self.assertFalse(test_manager.eventMatches(event, change))
def test_pipelines_trustiness(self):
test_manager = self.getPipeline('test').manager
change = zuul.model.Change('mediawiki/core')
change.branch = 'master'
# Untrusted user
untrusted_event = zuul.model.TriggerEvent()
untrusted_event.type = 'patchset-created'
untrusted_event.account = {'email': 'untrusted@example.org'}
untrusted_event.branch = change.branch
self.assertFalse(test_manager.eventMatches(untrusted_event, change))
# Trusted user
trusted_event = zuul.model.TriggerEvent()
trusted_event.type = 'patchset-created'
trusted_event.account = {'email': 'jdoe@wikimedia.org'}
trusted_event.branch = change.branch
self.assertTrue(test_manager.eventMatches(trusted_event, change))
def test_donationinterface_deployment_branch_filters(self):
test_manager = self.getPipeline('test').manager
change = zuul.model.Change('mediawiki/extensions/DonationInterface')
change.branch = 'deployment'
event = zuul.model.TriggerEvent()
event.type = 'patchset-created'
event.branch = change.branch
jobs_tree = [t for (p, t) in
self.getPipeline('test').job_trees.iteritems()
if p.name == 'mediawiki/extensions/DonationInterface'][0]
for job in jobs_tree.getJobs():
if job.name.startswith('mwext-'):
self.assertFalse(
job.changeMatches(change),
msg='%s should not trigger for branch %s' % (
job.name, change.branch)
)
self.assertTrue(test_manager.eventMatches(event, change))
def test_recheck_comment_untrusted_user_with_code_review(self):
test_manager = self.getPipeline('test').manager
change = zuul.model.Change('mediawiki/core')
change.branch = 'master'
event = zuul.model.TriggerEvent()
event.type = 'comment-added'
event.comment = 'Patch Set 1: -Code-Review\n\nrecheck'
event.account = {'email': 'untrusted@example.org'}
event.branch = change.branch
self.assertFalse(test_manager.eventMatches(event, change))
def test_recheck_with_code_review_vote_removed(self):
test_manager = self.getPipeline('test').manager
change = zuul.model.Change('mediawiki/core')
change.branch = 'master'
event = zuul.model.TriggerEvent()
event.type = 'comment-added'
event.comment = 'Patch Set 1: -Code-Review\n\nrecheck'
event.account = {'email': 'jdoe@wikimedia.org'}
event.branch = change.branch
self.assertTrue(test_manager.eventMatches(event, change))
def test_recheck_comment_trusted_user_extra_comment_1(self):
test_manager = self.getPipeline('test').manager
change = zuul.model.Change('mediawiki/core')
change.branch = 'master'
event = zuul.model.TriggerEvent()
event.type = 'comment-added'
extra_comment = 'recheck because CI failed due to Txxxxxx'
event.comment = 'Patch Set 1:\n\n' + extra_comment
event.account = {'email': 'jdoe@wikimedia.org'}
event.branch = change.branch
self.assertTrue(test_manager.eventMatches(event, change))