Add tests with filname in token data

This commit is contained in:
Ch3LL 2018-08-27 13:36:34 -04:00
parent d45f6c7866
commit d520f9acc1
No known key found for this signature in database
GPG key ID: 132B55A7C13EFA73
2 changed files with 28 additions and 1 deletions

View file

@ -2089,7 +2089,7 @@ class Events(object):
# than hex, this will raise a ValueError.
try:
int(auth_token, 16)
except ValueError:
except (TypeError, ValueError):
return False
# First check if the given token is in our session table; if so it's a

View file

@ -2,6 +2,7 @@
# Import python libs
from __future__ import absolute_import
import os
import json
# Import salt libs
@ -163,6 +164,32 @@ class TestRun(cptc.BaseRestCherryPyTest):
})
assert response.status == '401 Unauthorized'
def test_run_pathname_token(self):
'''
Test the run URL with path that exists in token
'''
cmd = dict(self.low, **{'token': os.path.join('etc', 'passwd')})
body = urlencode(cmd)
request, response = self.request('/run', method='POST', body=body,
headers={
'content-type': 'application/x-www-form-urlencoded'
})
assert response.status == '401 Unauthorized'
def test_run_pathname_not_exists_token(self):
'''
Test the run URL with path that does not exist in token
'''
cmd = dict(self.low, **{'token': os.path.join('tmp', 'doesnotexist')})
body = urlencode(cmd)
request, response = self.request('/run', method='POST', body=body,
headers={
'content-type': 'application/x-www-form-urlencoded'
})
assert response.status == '401 Unauthorized'
class TestWebhookDisableAuth(cptc.BaseRestCherryPyTest):