def check_allowed_origins(self, commit): """Check if the origin is allowed. Return True on success, False on failure.""" if not utils.is_origin_allowed(commit['origin'], self.config['general']['allowed_origins']): self.log.warning('Commit {id} does not match any allowed origins (origin: {origin}).'.format(**commit)) return False self.log.info('Commit {id} matches allowed origin: {origin}.'.format(**commit)) return True
def test_partial_origin(self): self.assertFalse(utils.is_origin_allowed('mast', self.allowed_origins))
def test_empty_origin(self): self.assertFalse(utils.is_origin_allowed('', self.allowed_origins))
def test_very_short_allowed_origin(self): self.assertFalse(utils.is_origin_allowed('x/no', self.allowed_origins))
def test_nested_without_match_on_first_level(self): self.assertFalse(utils.is_origin_allowed('feature/blub', self.allowed_origins))
def test_nested_with_match_in_subgroup(self): self.assertTrue(utils.is_origin_allowed('feature/foo/bar', self.allowed_origins))
def test_nested_with_single_origin_in_group(self): self.assertTrue(utils.is_origin_allowed('feature/foo', self.allowed_origins))
def test_origin_nested(self): self.assertTrue(utils.is_origin_allowed('bugfix/1/2/3', self.allowed_origins))
def test_origin_same_as_group(self): self.assertFalse(utils.is_origin_allowed('bugfix', self.allowed_origins))
def test_origin_in_group(self): self.assertTrue(utils.is_origin_allowed('bugfix/id2', self.allowed_origins))
def test_origin_allowed(self): self.assertTrue(utils.is_origin_allowed('master', self.allowed_origins))