"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/test_api_events.py" between
privacyidea-3.5.2.tar.gz and privacyidea-3.6.tar.gz

About: privacyIDEA is a flexible two factor authentication server that can be used to enhance the security of existing applications like local login, VPN, remote access, SSH connections or access to web sites.

test_api_events.py  (privacyidea-3.5.2):test_api_events.py  (privacyidea-3.6)
skipping to change at line 197 skipping to change at line 197
"option.2": "value2" "option.2": "value2"
} }
with self.app.test_request_context('/event', with self.app.test_request_context('/event',
data=param, data=param,
method='POST', method='POST',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), 1) self.assertGreaterEqual(result.get("value"), 1, result)
ev1_id = result.get('value')
# list event with options # list event with options
with self.app.test_request_context('/event/', with self.app.test_request_context('/event/',
method='GET', method='GET',
headers={ headers={
'Authorization': self.at}): 'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
event_list = result.get("value") event_list = result.get("value")
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
self.assertEqual(event_list[0].get("action"), "sendmail") self.assertEqual(event_list[0].get("action"), "sendmail")
self.assertEqual(event_list[0].get("event"), ["token_init"]) self.assertEqual(event_list[0].get("event"), ["token_init"])
self.assertEqual(event_list[0].get("options").get("2"), "value2") self.assertEqual(event_list[0].get("options").get("2"), "value2")
self.assertEqual(event_list[0].get("options").get("emailconfig"), self.assertEqual(event_list[0].get("options").get("emailconfig"),
"themis") "themis")
# delete event # delete event
with self.app.test_request_context('/event/1', with self.app.test_request_context('/event/{0!s}'.format(ev1_id),
method='DELETE', method='DELETE',
headers={ headers={
'Authorization': self.at}): 'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), 1) self.assertEqual(result.get("value"), ev1_id)
# list empty events # list empty events
with self.app.test_request_context('/event/', with self.app.test_request_context('/event/',
method='GET', method='GET',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), []) self.assertEqual(result.get("value"), [])
skipping to change at line 312 skipping to change at line 313
"option.2": "value2" "option.2": "value2"
} }
with self.app.test_request_context('/event', with self.app.test_request_context('/event',
data=param, data=param,
method='POST', method='POST',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), 1) self.assertGreaterEqual(result.get("value"), 1, result)
ev1_id = result.get('value')
# list event with options # list event with options
with self.app.test_request_context('/event/', with self.app.test_request_context('/event/',
method='GET', method='GET',
headers={ headers={
'Authorization': self.at}): 'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
event_list = result.get("value") event_list = result.get("value")
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
self.assertEqual(event_list[0].get("active"), True) self.assertEqual(event_list[0].get("active"), True)
# disable event # disable event
with self.app.test_request_context('/event/disable/1', with self.app.test_request_context('/event/disable/{0!s}'.format(ev1_id) ,
method='POST', method='POST',
headers={ headers={
'Authorization': self.at}): 'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
with self.app.test_request_context('/event/', with self.app.test_request_context('/event/',
method='GET', method='GET',
headers={ headers={
'Authorization': self.at}): 'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
event_list = result.get("value") event_list = result.get("value")
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
self.assertEqual(event_list[0].get("active"), False) self.assertEqual(event_list[0].get("active"), False)
# Enable event # Enable event
with self.app.test_request_context('/event/enable/1', with self.app.test_request_context('/event/enable/{0!s}'.format(ev1_id),
method='POST', method='POST',
headers={ headers={
'Authorization': self.at}): 'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
with self.app.test_request_context('/event/', with self.app.test_request_context('/event/',
method='GET', method='GET',
headers={ headers={
'Authorization': self.at}): 'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
event_list = result.get("value") event_list = result.get("value")
self.assertEqual(len(event_list), 1) self.assertEqual(len(event_list), 1)
self.assertEqual(event_list[0].get("active"), True) self.assertEqual(event_list[0].get("active"), True)
# delete event # delete event
with self.app.test_request_context('/event/1', with self.app.test_request_context('/event/{0!s}'.format(ev1_id),
method='DELETE', method='DELETE',
headers={ headers={
'Authorization': self.at}): 'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), 1) self.assertEqual(result.get("value"), ev1_id, result)
# list empty events # list empty events
with self.app.test_request_context('/event/', with self.app.test_request_context('/event/',
method='GET', method='GET',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), []) self.assertEqual(result.get("value"), [])
skipping to change at line 414 skipping to change at line 416
"position": "post" "position": "post"
} }
with self.app.test_request_context('/event', with self.app.test_request_context('/event',
data=param, data=param,
method='POST', method='POST',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), 1) self.assertGreaterEqual(result.get("value"), 1, result)
ev1_id = result.get('value')
# check the event # check the event
with self.app.test_request_context('/event/1', with self.app.test_request_context('/event/{0!s}'.format(ev1_id),
method='GET', method='GET',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value")[0].get("position"), "post") self.assertEqual(result.get("value")[0].get("position"), "post")
# Update event with the position=pre # Update event with the position=pre
param["id"] = 1 param["id"] = ev1_id
param["position"] = "pre" param["position"] = "pre"
with self.app.test_request_context('/event', with self.app.test_request_context('/event',
data=param, data=param,
method='POST', method='POST',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), 1) self.assertEqual(result.get("value"), ev1_id, result)
# check the event # check the event
with self.app.test_request_context('/event/1', with self.app.test_request_context('/event/{0!s}'.format(ev1_id),
method='GET', method='GET',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value")[0].get("position"), "pre") self.assertEqual(result.get("value")[0].get("position"), "pre")
# delete event # delete event
with self.app.test_request_context('/event/1', with self.app.test_request_context('/event/{0!s}'.format(ev1_id),
method='DELETE', method='DELETE',
headers={ headers={
'Authorization': self.at}): 'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), 1) self.assertEqual(result.get("value"), ev1_id, result)
# list empty events # list empty events
with self.app.test_request_context('/event/', with self.app.test_request_context('/event/',
method='GET', method='GET',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), []) self.assertEqual(result.get("value"), [])
skipping to change at line 501 skipping to change at line 504
"option.additional_params": "{'pin':'1234'}" "option.additional_params": "{'pin':'1234'}"
} }
with self.app.test_request_context('/event', with self.app.test_request_context('/event',
data=param, data=param,
method='POST', method='POST',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
self.assertTrue(res.status_code == 200, res) self.assertTrue(res.status_code == 200, res)
result = res.json.get("result") result = res.json.get("result")
detail = res.json.get("detail") detail = res.json.get("detail")
self.assertEqual(result.get("value"), 1) self.assertGreaterEqual(result.get("value"), 1, result)
self.setUp_user_realm2() self.setUp_user_realm2()
# usernotoken, self.realm2 # usernotoken, self.realm2
# check that the user has no tokens # check that the user has no tokens
with self.app.test_request_context('/token/', with self.app.test_request_context('/token/',
data={"user": "usernotoken", data={"user": "usernotoken",
"realm": self.realm2}, "realm": self.realm2},
method='GET', method='GET',
headers={'Authorization': self.at}): headers={'Authorization': self.at}):
res = self.app.full_dispatch_request() res = self.app.full_dispatch_request()
 End of changes. 16 change blocks. 
16 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)