Per collection/folder auth
This commit is contained in:
1 parent
d5e7b484fc
commit
47ee07d9ff
16 files changed
+1569
-58
No files matched your search
@@ -84,6 +84,33 @@ async fn run_uses_env_files_cookies_and_names() {
|
||||
assert!(String::from_utf8_lossy(&out.stderr).contains("unknown variable `base_url`"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folder_auth_is_inherited() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
std::fs::write(root.join("http-client.env.json"), r#"{ "dev": { "token": "t0k" } }"#).unwrap();
|
||||
std::fs::create_dir_all(root.join(".reqlite")).unwrap();
|
||||
std::fs::write(root.join(".reqlite/folder.json"), r#"{ "auth": "Bearer {{token}}" }"#).unwrap();
|
||||
std::fs::create_dir_all(root.join("api")).unwrap();
|
||||
let file = root.join("api/x.http");
|
||||
std::fs::write(
|
||||
&file,
|
||||
"### Inherits\nGET http://h/a\n\n### Own\nGET http://h/b\nAuthorization: Basic u p\n\n### None\n# @no-auth\nGET http://h/c\n",
|
||||
)
|
||||
.unwrap();
|
||||
let out = reqlite()
|
||||
.args(["curl", file.to_str().unwrap(), "--env", "dev"])
|
||||
.output()
|
||||
.unwrap();
|
||||
let stdout = String::from_utf8_lossy(&out.stdout);
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
let lines: Vec<&str> = stdout.lines().collect();
|
||||
assert_eq!(lines.len(), 3, "{stdout}");
|
||||
assert!(lines[0].contains("Authorization: Bearer t0k"), "{stdout}");
|
||||
assert!(lines[1].contains("Authorization: Basic dTpw"), "{stdout}");
|
||||
assert!(!lines[2].contains("Authorization"), "{stdout}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn import_curl_prints_http() {
|
||||
let out = reqlite()
|
||||
|
||||
Reference in new issue
Block a user