def test_start_deployment(self, mocked): self._set_body_json({ 'target': { 'cluster': None, 'server': None }, 'branch': 'master', 'commit': 'abcde' }) api.environments_start_deployment(1, self.session)
def test_start_deployment_non_admin(self, mocked): request.account = self.session.query(m.User).filter(m.User.username == 'username').one() self._set_body_json({ 'target': { 'cluster': None, 'server': None }, 'branch': 'master', 'commit': 'abcde' }) api.environments_start_deployment(1, self.session)
def test_start_deployment_with_impersonating(self, mocked): request.account = self.session.query(m.User).filter(m.User.username == 'impersonator').one() request.environ['HTTP_X_IMPERSONATE_USERNAME'] = '******' self._set_body_json({ 'target': { 'cluster': None, 'server': None }, 'branch': 'master', 'commit': 'abcde' }) api.environments_start_deployment(1, self.session)
def test_start_deployment_with_impersonating_unprivilegied_user(self, mocked): request.account = self.session.query(m.User).filter(m.User.username == 'impersonator').one() request.environ['HTTP_X_IMPERSONATE_USERNAME'] = '******' self._set_body_json({ 'target': { 'cluster': None, 'server': None }, 'branch': 'master', 'commit': 'abcde' }) with self.assertRaises(HTTPError) as cm: api.environments_start_deployment(2, self.session) self.assertEquals(403, cm.exception.code)