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")
|
||||
|
||||
def curl(target, format, endpoint, data="", extra=""):
|
||||
data = ' '.join(data.replace("\n", "").split())
|
||||
extra = ' '.join(extra.replace("\n", "").split())
|
||||
cmd = ("curl --show-error --location"
|
||||
+ " --cookie-jar cookie.txt"
|
||||
+ " --cookie cookie.txt"
|
||||
|
@ -63,6 +61,9 @@
|
|||
# print(r)
|
||||
return json.loads(r)
|
||||
|
||||
def unline_with(j, s):
|
||||
return j.join((x.strip() for x in s.split("\n")))
|
||||
|
||||
''
|
||||
+ (if (! redirectSSO) then ''
|
||||
with subtest("access"):
|
||||
|
@ -84,7 +85,7 @@
|
|||
)
|
||||
+ (let
|
||||
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
|
||||
lib.optionalString (script != "") ''
|
||||
with subtest("extraScript"):
|
||||
|
|
|
@ -27,35 +27,35 @@ let
|
|||
with subtest("web connect"):
|
||||
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 "Accept: application/json"
|
||||
""", data = """
|
||||
"""), data = unline_with(" ", """
|
||||
{"method": "auth.login", "params": ["deluge"], "id": 1}
|
||||
""")
|
||||
"""))
|
||||
print(response)
|
||||
if response['error']:
|
||||
raise Exception(f"error is {response['error']}")
|
||||
if not response['result']:
|
||||
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 "Accept: application/json"
|
||||
""", data = """
|
||||
"""), data = unline_with(" ", """
|
||||
{"method": "web.get_hosts", "params": [], "id": 1}
|
||||
""")
|
||||
"""))
|
||||
print(response)
|
||||
if response['error']:
|
||||
raise Exception(f"error is {response['error']}")
|
||||
|
||||
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 "Accept: application/json"
|
||||
""", data = f"""
|
||||
"""), data = unline_with(" ", f"""
|
||||
{{"method": "web.connect", "params": ["{hostID}"], "id": 1}}
|
||||
""")
|
||||
"""))
|
||||
print(response)
|
||||
if response['error']:
|
||||
raise Exception(f"result had an error {response['error']}")
|
||||
|
|
Loading…
Reference in a new issue