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:
Lucas Fernandes Nogueira
2023-05-12 20:19:06 +00:00
committed by tauri-bot
parent 3038911991
commit 57b3c3f7d1
4 changed files with 19 additions and 33 deletions

View File

@@ -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" ] }

View File

@@ -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.

View File

@@ -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};

View File

@@ -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()));