Accept units from configured source roots
This commit is contained in:
@@ -24,16 +24,8 @@ DValue resp = http_request(req);
|
||||
print("HTTP ", resp["status"].to_u64(), ", ", resp["body"].to_string().length(), " bytes returned\n");
|
||||
|
||||
:example
|
||||
// GitHub token exchange: client_secret stays in stdin body, not argv.
|
||||
DValue token; token["method"]="POST"; token["url"]="https://github.com/login/oauth/access_token";
|
||||
token["headers"]["Accept"]="application/json"; token["headers"]["Content-Type"]="application/x-www-form-urlencoded";
|
||||
token["body"]="client_id="+uri_encode(client_id)+"&client_secret="+uri_encode(client_secret)+"&code="+uri_encode(code);
|
||||
for(String key:{"https_only","public_dns_only","pin_dns","isolated_curl","no_redirects"}) token["security"][key].set_bool(true);
|
||||
DValue token_response=http_request(token);
|
||||
|
||||
:example
|
||||
// ATProto metadata discovery uses the same generic policy; no provider operation name.
|
||||
DValue meta; meta["method"]="GET"; meta["url"]="https://"+issuer_host+"/.well-known/oauth-authorization-server";
|
||||
meta["headers"]["Accept"]="application/json";
|
||||
for(String key:{"https_only","public_dns_only","pin_dns","isolated_curl","no_redirects"}) meta["security"][key].set_bool(true);
|
||||
DValue metadata=http_request(meta);
|
||||
// Hardened requests reject IP-literal hosts before they start curl.
|
||||
DValue hardened; hardened["method"]="GET"; hardened["url"]="https://127.0.0.1/";
|
||||
for(String key:{"https_only","public_dns_only","pin_dns","isolated_curl","no_redirects"}) hardened["security"][key].set_bool(true);
|
||||
DValue rejected=http_request(hardened);
|
||||
print(rejected["error"].to_string(), "\n");
|
||||
|
||||
@@ -22,6 +22,12 @@ RENDER(Request& context)
|
||||
file_put_contents(outside_unit, "RENDER(Request& context) {}");
|
||||
DValue outside_info = unit_info(outside_unit);
|
||||
file_unlink(outside_unit);
|
||||
String generated_dir = path_join(context.params["UCE_BIN_DIRECTORY"], "site-tests-generated");
|
||||
mkdir(generated_dir);
|
||||
String generated_unit = path_join(generated_dir, "generated.uce");
|
||||
file_put_contents(generated_unit, "RENDER(Request& context) {}");
|
||||
DValue generated_info = unit_info(generated_unit);
|
||||
file_unlink(generated_unit);
|
||||
|
||||
ob_start();
|
||||
unit_call("call_helpers.uce", "emit_marker");
|
||||
@@ -37,6 +43,7 @@ RENDER(Request& context)
|
||||
check("unit_info()", info["path"].to_string() != "", json_encode(info));
|
||||
check("compiler canonicalizes relative unit paths", relative_info["path"].to_string().find("/../") == String::npos && str_ends_with(relative_info["path"].to_string(), "/site/tests/relative-child.uce"), json_encode(relative_info));
|
||||
check("compiler rejects units outside document root", outside_info["path"].to_string() == "", json_encode(outside_info));
|
||||
check("compiler accepts generated units in BIN_DIRECTORY", generated_info["path"].to_string() == generated_unit, json_encode(generated_info));
|
||||
check("unit_compile()", unit_compile("call_helpers.uce"), "call_helpers.uce");
|
||||
check("unit_call()", call_output.find("UNIT_CALL_EXPORT_OK") != String::npos, call_output);
|
||||
check("unit_render()", render_output.find("data-unit-render=\"ok\"") != String::npos, render_output);
|
||||
|
||||
Reference in New Issue
Block a user