Merge pull request #33888 from jfindlay/random_check

random.org checks
This commit is contained in:
Mike Place 2016-06-10 08:45:07 -07:00 committed by GitHub
commit 378dd7ca06
3 changed files with 16 additions and 1 deletions

View file

@ -120,7 +120,7 @@ def _query(api_version=None, data=None):
elif result.get('status', None) == salt.ext.six.moves.http_client.NO_CONTENT:
return False
else:
ret['message'] = result.text
ret['message'] = result.text if hasattr(result, 'text') else ''
return ret

View file

@ -500,6 +500,11 @@ def query(url,
ret['status'] = exc.code
ret['error'] = str(exc)
return ret
except socket.gaierror as exc:
if status is True:
ret['status'] = 0
ret['error'] = str(exc)
return ret
if stream is True or handle is True:
return {

View file

@ -18,11 +18,21 @@ from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import Salt Libs
import salt.utils.http
from salt.modules import random_org
random_org.__opts__ = {}
def check_status():
'''
Check the status of random.org
'''
ret = salt.utils.http.query('https://api.random.org/', status=True)
return ret['status'] == 200
@skipIf(not check_status(), 'random.org is not available')
@skipIf(NO_MOCK, NO_MOCK_REASON)
class RandomOrgTestCase(TestCase):
'''