D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
3
/
task
/
3
/
root
/
lib
/
imh-dnskeyapi
/
tests
/
Filename :
test_api.py
back
Copy
"""Tests the WHM plugin by performing a request to it""" import requests import urllib3 # pylint:disable=unused-argument def test_acl(access_hash): """Tests that the authorized_ips setting works by making a request from 127.0.0.1 without allowing it""" req = _request(access_hash) assert req.status_code == 200 data = req.json() # status 2 comes from sanity_check() failing assert data['status'] == 2 def test_mising_args(access_hash, allow_local): """Test handling for when a required argument is missing""" req = _request(access_hash) assert req.status_code == 200 data = req.json() assert data['status'] == 4 assert data['message'] == 'You must specify user, pp_user, and key' def _request(access_hash, **data): urllib3.disable_warnings() return requests.post( 'https://127.0.0.1:2087/cgi/imhapi/set-dns-key.cgi', headers={'Authorization': f'WHM root:{access_hash}'}, data=data, verify=False, timeout=10.0, )