Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if OAUTH:
self.jira_sysadmin = JIRA(oauth={
'access_token': '4ul1ETSFo7ybbIxAxzyRal39cTrwEGFv',
'access_token_secret':
'K83jBZnjnuVRcfjBflrKyThJa0KSjSs2',
'consumer_key': CONSUMER_KEY,
'key_cert': KEY_CERT_DATA}, logging=False, max_retries=self.max_retries)
else:
if self.CI_JIRA_ADMIN:
self.jira_sysadmin = JIRA(self.CI_JIRA_URL,
basic_auth=(self.CI_JIRA_ADMIN,
self.CI_JIRA_ADMIN_PASSWORD),
logging=False, validate=True, max_retries=self.max_retries)
else:
self.jira_sysadmin = JIRA(self.CI_JIRA_URL,
logging=False, max_retries=self.max_retries)
if OAUTH:
self.jira_normal = JIRA(oauth={
'access_token': 'ZVDgYDyIQqJY8IFlQ446jZaURIz5ECiB',
'access_token_secret':
'5WbLBybPDg1lqqyFjyXSCsCtAWTwz1eD',
'consumer_key': CONSUMER_KEY,
'key_cert': KEY_CERT_DATA})
else:
if self.CI_JIRA_ADMIN:
self.jira_normal = JIRA(self.CI_JIRA_URL,
basic_auth=(self.CI_JIRA_USER,
self.CI_JIRA_USER_PASSWORD),
validate=True, logging=False, max_retries=self.max_retries)
else:
def test_session_with_no_logged_in_user_raises(self):
anon_jira = JIRA("https://jira.atlassian.com", logging=False)
self.assertRaises(JIRAError, anon_jira.session)
def test_remove_user_from_group(self):
if self._should_skip_for_pycontribs_instance():
self._skip_pycontribs_instance()
try:
self.jira.add_user(
self.test_username, self.test_email, password=self.test_password
)
except JIRAError:
pass
try:
self.jira.add_group(self.test_groupname)
except JIRAError:
pass
try:
self.jira.add_user_to_group(self.test_username, self.test_groupname)
except JIRAError:
pass
result = self.jira.remove_user_from_group(
self.test_username, self.test_groupname
)
assert result, True
sleep(2)
x = self.jira.group_members(self.test_groupname)
self.assertNotIn(
self.test_username,
def test_session_invalid_login(self):
try:
JIRA(
"https://jira.atlassian.com",
basic_auth=("xxx", "xxx"),
validate=True,
logging=False,
)
except Exception as e:
self.assertIsInstance(e, JIRAError)
# 20161010: jira cloud returns 500
assert e.status_code in (401, 500, 403)
str(JIRAError) # to see that this does not raise an exception
return
assert False
def test_assign_to_bad_issue_raises(self):
self.assertRaises(JIRAError, self.jira.assign_issue, 'NOPE-1',
'notauser')
def test_cls_for_resource(self):
self.assertEqual(cls_for_resource('https://jira.atlassian.com/rest/\
api/latest/issue/JRA-1330'), Issue)
self.assertEqual(cls_for_resource('http://localhost:2990/jira/rest/\
api/latest/project/BULK'), Project)
self.assertEqual(cls_for_resource('http://imaginary-jira.com/rest/\
api/latest/project/IMG/role/10002'), Role)
self.assertEqual(cls_for_resource('http://customized-jira.com/rest/\
plugin-resource/4.5/json/getMyObject'), Resource)
def test_result_list():
iterable = [2, 3]
startAt = 0
maxResults = 50
total = 2
results = jira.client.ResultList(iterable, startAt, maxResults, total)
for idx, result in enumerate(results):
assert results[idx] == iterable[idx]
assert next(results) == iterable[0]
assert next(results) == iterable[1]
with pytest.raises(StopIteration):
next(results)
def test_cls_for_resource(self):
self.assertEqual(
cls_for_resource(
"https://jira.atlassian.com/rest/\
api/latest/issue/JRA-1330"
),
Issue,
)
self.assertEqual(
cls_for_resource(
"http://localhost:2990/jira/rest/\
api/latest/project/BULK"
),
Project,
)
self.assertEqual(
cls_for_resource(
"http://imaginary-jira.com/rest/\
api/latest/project/IMG/role/10002"
),
Role,
)
self.assertEqual(
cls_for_resource(
"http://customized-jira.com/rest/\
plugin-resource/4.5/json/getMyObject"
def test_cls_for_resource(self):
self.assertEqual(cls_for_resource('https://jira.atlassian.com/rest/\
api/latest/issue/JRA-1330'), Issue)
self.assertEqual(cls_for_resource('http://localhost:2990/jira/rest/\
api/latest/project/BULK'), Project)
self.assertEqual(cls_for_resource('http://imaginary-jira.com/rest/\
api/latest/project/IMG/role/10002'), Role)
self.assertEqual(cls_for_resource('http://customized-jira.com/rest/\
plugin-resource/4.5/json/getMyObject'), Resource)
self.assertEqual(
cls_for_resource(
"http://imaginary-jira.com/rest/\
api/latest/project/IMG/role/10002"
),
Role,
)
self.assertEqual(
cls_for_resource(
"http://customized-jira.com/rest/\
plugin-resource/4.5/json/getMyObject"
),
UnknownResource,
)
self.assertEqual(
cls_for_resource(
"http://customized-jira.com/rest/\
group?groupname=bla"
),
Group,
)