|
Server : Apache System : Linux ecngx264.inmotionhosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : lonias5 ( 3576) PHP Version : 7.3.33 Disable Function : NONE Directory : /usr/lib/imh-dnskeyapi/tests/ |
Upload File : |
"""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,
)