mirror of
https://github.com/tauri-apps/tauri-plugin-http.git
synced 2026-01-31 00:45:17 +01:00
feat: use tauri next branch, fix tests, MSRV 1.65 (#354)
Committed via a GitHub action: https://github.com/tauri-apps/plugins-workspace/actions/runs/4962685314 Co-authored-by: lucasfernog <lucasfernog@users.noreply.github.com>
This commit is contained in:
committed by
tauri-bot
parent
3038911991
commit
57b3c3f7d1
21
Cargo.toml
21
Cargo.toml
@@ -1,22 +1,15 @@
|
||||
[package]
|
||||
name = "tauri-plugin-http"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
#edition.workspace = true
|
||||
#authors.workspace = true
|
||||
#license.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
#serde.workspace = true
|
||||
#serde_json.workspace = true
|
||||
#tauri.workspace = true
|
||||
#log.workspace = true
|
||||
#thiserror.workspace = true
|
||||
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "next" }
|
||||
serde = "1"
|
||||
serde_json = "1"
|
||||
thiserror = "1"
|
||||
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
tauri.workspace = true
|
||||
thiserror.workspace = true
|
||||
glob = "0.3"
|
||||
rand = "0.8"
|
||||
bytes = { version = "1", features = [ "serde" ] }
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Install
|
||||
|
||||
_This plugin requires a Rust version of at least **1.64**_
|
||||
_This plugin requires a Rust version of at least **1.65**_
|
||||
|
||||
There are three general methods of installation that we can recommend.
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
use tauri::{path::SafePathBuf, AppHandle, Runtime, State};
|
||||
|
||||
use crate::{
|
||||
|
||||
ClientId, Http,
|
||||
};
|
||||
use crate::{ClientId, Http};
|
||||
|
||||
mod client;
|
||||
use client::{Body, ClientBuilder, FilePart, FormPart, HttpRequestBuilder, ResponseData};
|
||||
|
||||
24
src/scope.rs
24
src/scope.rs
@@ -38,12 +38,12 @@ impl Scope {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use tauri_utils::config::HttpAllowlistScope;
|
||||
use tauri::utils::config::HttpAllowlistScope;
|
||||
|
||||
#[test]
|
||||
fn is_allowed() {
|
||||
// plain URL
|
||||
let scope = super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://localhost:8080"
|
||||
let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080"
|
||||
.parse()
|
||||
.unwrap()]));
|
||||
assert!(scope.is_allowed(&"http://localhost:8080".parse().unwrap()));
|
||||
@@ -56,10 +56,9 @@ mod tests {
|
||||
assert!(!scope.is_allowed(&"http://local:8080".parse().unwrap()));
|
||||
|
||||
// URL with fixed path
|
||||
let scope =
|
||||
super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://localhost:8080/file.png"
|
||||
.parse()
|
||||
.unwrap()]));
|
||||
let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080/file.png"
|
||||
.parse()
|
||||
.unwrap()]));
|
||||
|
||||
assert!(scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap()));
|
||||
|
||||
@@ -68,25 +67,22 @@ mod tests {
|
||||
assert!(!scope.is_allowed(&"http://localhost:8080/file.png/other.jpg".parse().unwrap()));
|
||||
|
||||
// URL with glob pattern
|
||||
let scope =
|
||||
super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://localhost:8080/*.png"
|
||||
.parse()
|
||||
.unwrap()]));
|
||||
let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://localhost:8080/*.png"
|
||||
.parse()
|
||||
.unwrap()]));
|
||||
|
||||
assert!(scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap()));
|
||||
assert!(scope.is_allowed(&"http://localhost:8080/assets/file.png".parse().unwrap()));
|
||||
|
||||
assert!(!scope.is_allowed(&"http://localhost:8080/file.jpeg".parse().unwrap()));
|
||||
|
||||
let scope =
|
||||
super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://*".parse().unwrap()]));
|
||||
let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://*".parse().unwrap()]));
|
||||
|
||||
assert!(scope.is_allowed(&"http://something.else".parse().unwrap()));
|
||||
assert!(!scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap()));
|
||||
assert!(!scope.is_allowed(&"https://something.else".parse().unwrap()));
|
||||
|
||||
let scope =
|
||||
super::Scope::for_http_api(&HttpAllowlistScope(vec!["http://**".parse().unwrap()]));
|
||||
let scope = super::Scope::new(&HttpAllowlistScope(vec!["http://**".parse().unwrap()]));
|
||||
|
||||
assert!(scope.is_allowed(&"http://something.else".parse().unwrap()));
|
||||
assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap()));
|
||||
|
||||
Reference in New Issue
Block a user