feat: use tauri next branch, fix tests, MSRV 1.65 (#354)

This commit is contained in:
Lucas Fernandes Nogueira
2023-05-12 13:16:50 -07:00
committed by GitHub
parent e0e7b4fc71
commit 937e6a5be6
64 changed files with 867 additions and 463 deletions
+1 -4
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};
+10 -14
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()));