do not assume any formatting in curl function for tests
This commit is contained in:
parent
4c4b0c2e61
commit
b64c1bf982
2 changed files with 13 additions and 12 deletions
|
@ -45,8 +45,6 @@
|
||||||
client.copy_from_host(str(pathlib.Path(os.environ.get("out", os.getcwd())) / "ca-certificates.crt"), "/etc/ssl/certs/ca-certificates.crt")
|
client.copy_from_host(str(pathlib.Path(os.environ.get("out", os.getcwd())) / "ca-certificates.crt"), "/etc/ssl/certs/ca-certificates.crt")
|
||||||
|
|
||||||
def curl(target, format, endpoint, data="", extra=""):
|
def curl(target, format, endpoint, data="", extra=""):
|
||||||
data = ' '.join(data.replace("\n", "").split())
|
|
||||||
extra = ' '.join(extra.replace("\n", "").split())
|
|
||||||
cmd = ("curl --show-error --location"
|
cmd = ("curl --show-error --location"
|
||||||
+ " --cookie-jar cookie.txt"
|
+ " --cookie-jar cookie.txt"
|
||||||
+ " --cookie cookie.txt"
|
+ " --cookie cookie.txt"
|
||||||
|
@ -63,6 +61,9 @@
|
||||||
# print(r)
|
# print(r)
|
||||||
return json.loads(r)
|
return json.loads(r)
|
||||||
|
|
||||||
|
def unline_with(j, s):
|
||||||
|
return j.join((x.strip() for x in s.split("\n")))
|
||||||
|
|
||||||
''
|
''
|
||||||
+ (if (! redirectSSO) then ''
|
+ (if (! redirectSSO) then ''
|
||||||
with subtest("access"):
|
with subtest("access"):
|
||||||
|
@ -84,7 +85,7 @@
|
||||||
)
|
)
|
||||||
+ (let
|
+ (let
|
||||||
script = extraScript args;
|
script = extraScript args;
|
||||||
indent = indent: str: lib.concatMapStringsSep "\n" (x: (lib. replicate indent " ") + x) (lib.splitString "\n" script);
|
indent = i: str: lib.concatMapStringsSep "\n" (x: (lib.strings.replicate i " ") + x) (lib.splitString "\n" script);
|
||||||
in
|
in
|
||||||
lib.optionalString (script != "") ''
|
lib.optionalString (script != "") ''
|
||||||
with subtest("extraScript"):
|
with subtest("extraScript"):
|
||||||
|
|
|
@ -27,35 +27,35 @@ let
|
||||||
with subtest("web connect"):
|
with subtest("web connect"):
|
||||||
print(server.succeed("cat ${node.config.services.deluge.dataDir}/.config/deluge/auth"))
|
print(server.succeed("cat ${node.config.services.deluge.dataDir}/.config/deluge/auth"))
|
||||||
|
|
||||||
response = curl(client, "", "${proto_fqdn}/json", extra = """
|
response = curl(client, "", "${proto_fqdn}/json", extra = unline_with(" ", """
|
||||||
-H "Content-Type: application/json"
|
-H "Content-Type: application/json"
|
||||||
-H "Accept: application/json"
|
-H "Accept: application/json"
|
||||||
""", data = """
|
"""), data = unline_with(" ", """
|
||||||
{"method": "auth.login", "params": ["deluge"], "id": 1}
|
{"method": "auth.login", "params": ["deluge"], "id": 1}
|
||||||
""")
|
"""))
|
||||||
print(response)
|
print(response)
|
||||||
if response['error']:
|
if response['error']:
|
||||||
raise Exception(f"error is {response['error']}")
|
raise Exception(f"error is {response['error']}")
|
||||||
if not response['result']:
|
if not response['result']:
|
||||||
raise Exception(f"response is {response}")
|
raise Exception(f"response is {response}")
|
||||||
|
|
||||||
response = curl(client, "", "${proto_fqdn}/json", extra = """
|
response = curl(client, "", "${proto_fqdn}/json", extra = unline_with(" ", """
|
||||||
-H "Content-Type: application/json"
|
-H "Content-Type: application/json"
|
||||||
-H "Accept: application/json"
|
-H "Accept: application/json"
|
||||||
""", data = """
|
"""), data = unline_with(" ", """
|
||||||
{"method": "web.get_hosts", "params": [], "id": 1}
|
{"method": "web.get_hosts", "params": [], "id": 1}
|
||||||
""")
|
"""))
|
||||||
print(response)
|
print(response)
|
||||||
if response['error']:
|
if response['error']:
|
||||||
raise Exception(f"error is {response['error']}")
|
raise Exception(f"error is {response['error']}")
|
||||||
|
|
||||||
hostID = response['result'][0][0]
|
hostID = response['result'][0][0]
|
||||||
response = curl(client, "", "${proto_fqdn}/json", extra = """
|
response = curl(client, "", "${proto_fqdn}/json", extra = unline_with(" ", """
|
||||||
-H "Content-Type: application/json"
|
-H "Content-Type: application/json"
|
||||||
-H "Accept: application/json"
|
-H "Accept: application/json"
|
||||||
""", data = f"""
|
"""), data = unline_with(" ", f"""
|
||||||
{{"method": "web.connect", "params": ["{hostID}"], "id": 1}}
|
{{"method": "web.connect", "params": ["{hostID}"], "id": 1}}
|
||||||
""")
|
"""))
|
||||||
print(response)
|
print(response)
|
||||||
if response['error']:
|
if response['error']:
|
||||||
raise Exception(f"result had an error {response['error']}")
|
raise Exception(f"result had an error {response['error']}")
|
||||||
|
|
Loading…
Reference in a new issue