refactor grocy tests
This commit is contained in:
parent
bcd844f7cc
commit
d0d9010a30
1 changed files with 4 additions and 4 deletions
|
@ -10,7 +10,7 @@ let
|
||||||
commonTestScript = { nodes, ... }:
|
commonTestScript = { nodes, ... }:
|
||||||
let
|
let
|
||||||
hasSSL = !(isNull nodes.server.shb.grocy.ssl);
|
hasSSL = !(isNull nodes.server.shb.grocy.ssl);
|
||||||
fqdn = if hasSSL then "https://g.example.com" else "http://g.example.com";
|
proto_fqdn = if hasSSL then "https://${fqdn}" else "http://${fqdn}";
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
import json
|
import json
|
||||||
|
@ -30,14 +30,14 @@ let
|
||||||
def curl(target, format, endpoint, succeed=True):
|
def curl(target, format, endpoint, succeed=True):
|
||||||
return json.loads(target.succeed(
|
return json.loads(target.succeed(
|
||||||
"curl --fail-with-body --silent --show-error --output /dev/null --location"
|
"curl --fail-with-body --silent --show-error --output /dev/null --location"
|
||||||
+ " --connect-to g.example.com:443:server:443"
|
+ " --connect-to ${fqdn}:443:server:443"
|
||||||
+ " --connect-to g.example.com:80:server:80"
|
+ " --connect-to ${fqdn}:80:server:80"
|
||||||
+ f" --write-out '{format}'"
|
+ f" --write-out '{format}'"
|
||||||
+ " " + endpoint
|
+ " " + endpoint
|
||||||
))
|
))
|
||||||
|
|
||||||
with subtest("access"):
|
with subtest("access"):
|
||||||
response = curl(client, """{"code":%{response_code}}""", "${fqdn}")
|
response = curl(client, """{"code":%{response_code}}""", "${proto_fqdn}")
|
||||||
|
|
||||||
if response['code'] != 200:
|
if response['code'] != 200:
|
||||||
raise Exception(f"Code is {response['code']}")
|
raise Exception(f"Code is {response['code']}")
|
||||||
|
|
Loading…
Reference in a new issue