Skip to content

Commit 78eaeaf

Browse files
ci: fix and run acl-tests (#15746)
* ci: fix and run acl-tests * Simplify `CommandScope::from_command`
1 parent df10bb0 commit 78eaeaf

4 files changed

Lines changed: 30 additions & 28 deletions

File tree

.github/workflows/test-core.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ jobs:
103103
# Using --lib --bins --tests to skip doc tests
104104
run: ${{ matrix.platform.cargo }} ${{ matrix.platform.command }} --target ${{ matrix.platform.target }} ${{ matrix.features.args }} --lib --bins --tests --manifest-path crates/tauri-utils/Cargo.toml
105105

106+
- name: run acl-tests
107+
if: ${{ matrix.features.key != 'no-default' && matrix.platform.command == 'test' }}
108+
run: ${{ matrix.platform.cargo }} test --target ${{ matrix.platform.target }} ${{ matrix.features.args }} --manifest-path crates/tests/acl/Cargo.toml
109+
106110
- name: test tauri
107111
run: ${{ matrix.platform.cargo }} ${{ matrix.features.key == 'no-default' && 'check' || matrix.platform.command }} --target ${{ matrix.platform.target }} ${{ matrix.features.args }} --manifest-path crates/tauri/Cargo.toml
108112

crates/tauri-utils/src/acl/resolved.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl Resolved {
152152
}| {
153153
if commands.allow.is_empty() && commands.deny.is_empty() {
154154
// global scope
155-
global_scope.entry(key.to_string()).or_default().push(scope);
155+
global_scope.entry(key).or_default().push(scope);
156156
} else {
157157
let scope_id = if scope.allow.is_some() || scope.deny.is_some() {
158158
current_scope_id += 1;
@@ -181,7 +181,7 @@ impl Resolved {
181181
capability,
182182
scope_id,
183183
#[cfg(debug_assertions)]
184-
permission_name.to_string(),
184+
permission_name,
185185
)?;
186186
}
187187

@@ -198,7 +198,7 @@ impl Resolved {
198198
capability,
199199
scope_id,
200200
#[cfg(debug_assertions)]
201-
permission_name.to_string(),
201+
permission_name,
202202
)?;
203203
}
204204
}
@@ -255,7 +255,7 @@ fn resolve_command(
255255
command: String,
256256
capability: &Capability,
257257
scope_id: Option<ScopeKey>,
258-
#[cfg(debug_assertions)] referenced_by_permission_identifier: String,
258+
#[cfg(debug_assertions)] referenced_by_permission_identifier: &str,
259259
) -> Result<(), Error> {
260260
let mut contexts = Vec::new();
261261
if capability.local {
@@ -279,7 +279,7 @@ fn resolve_command(
279279
#[cfg(debug_assertions)]
280280
referenced_by: ResolvedCommandReference {
281281
capability: capability.identifier.clone(),
282-
permission: referenced_by_permission_identifier.clone(),
282+
permission: referenced_by_permission_identifier.to_owned(),
283283
},
284284
windows: parse_glob_patterns(capability.windows.clone())?,
285285
webviews: parse_glob_patterns(capability.webviews.clone())?,
@@ -291,7 +291,7 @@ fn resolve_command(
291291
}
292292

293293
struct ResolvedPermission<'a> {
294-
key: &'a str,
294+
key: String,
295295
permission_name: &'a str,
296296
commands: Commands,
297297
scope: Scopes,
@@ -357,7 +357,7 @@ fn with_resolved_permissions<F: FnMut(ResolvedPermission<'_>) -> Result<(), Erro
357357
commands.deny.extend(permission.commands.deny.clone());
358358

359359
f(ResolvedPermission {
360-
key: &key,
360+
key,
361361
permission_name: &permission_name,
362362
commands,
363363
scope: resolved_scope,

crates/tauri/src/ipc/authority.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,11 @@ impl<T: ScopeObjectMatch> CommandScope<T> {
609609
impl<'a, R: Runtime, T: ScopeObject> CommandArg<'a, R> for CommandScope<T> {
610610
/// Grabs the [`ResolvedScope`] from the [`CommandItem`] and returns the associated [`CommandScope`].
611611
fn from_command(command: CommandItem<'a, R>) -> Result<Self, InvokeError> {
612-
let scope_ids = command.acl.as_ref().map(|resolved| {
613-
resolved
612+
if let Some(resolved) = &command.acl {
613+
let scope_ids = resolved
614614
.iter()
615615
.filter_map(|cmd| cmd.scope_id)
616-
.collect::<Vec<_>>()
617-
});
618-
if let Some(scope_ids) = scope_ids {
616+
.collect::<Vec<_>>();
619617
CommandScope::resolve(&command.message.webview, scope_ids).map_err(Into::into)
620618
} else {
621619
Ok(CommandScope {

crates/tests/acl/fixtures/snapshots/acl_tests__tests__file-explorer-remote.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Resolved {
1414
pattern_string: "https",
1515
regexp: Ok(
1616
Regex(
17-
"(?u)^https$",
17+
"^https$",
1818
),
1919
),
2020
group_name_list: [],
@@ -32,7 +32,7 @@ Resolved {
3232
pattern_string: "*",
3333
regexp: Ok(
3434
Regex(
35-
"(?u)^(.*)$",
35+
"^(.*)$",
3636
),
3737
),
3838
group_name_list: [
@@ -53,7 +53,7 @@ Resolved {
5353
pattern_string: "*",
5454
regexp: Ok(
5555
Regex(
56-
"(?u)^(.*)$",
56+
"^(.*)$",
5757
),
5858
),
5959
group_name_list: [
@@ -74,7 +74,7 @@ Resolved {
7474
pattern_string: "tauri.app",
7575
regexp: Ok(
7676
Regex(
77-
"(?u)^tauri\\.app$",
77+
"^tauri\\.app$",
7878
),
7979
),
8080
group_name_list: [],
@@ -92,7 +92,7 @@ Resolved {
9292
pattern_string: "",
9393
regexp: Ok(
9494
Regex(
95-
"(?u)^$",
95+
"^$",
9696
),
9797
),
9898
group_name_list: [],
@@ -110,7 +110,7 @@ Resolved {
110110
pattern_string: "*",
111111
regexp: Ok(
112112
Regex(
113-
"(?u)^(.*)$",
113+
"^(.*)$",
114114
),
115115
),
116116
group_name_list: [
@@ -131,7 +131,7 @@ Resolved {
131131
pattern_string: "*",
132132
regexp: Ok(
133133
Regex(
134-
"(?u)^(.*)$",
134+
"^(.*)$",
135135
),
136136
),
137137
group_name_list: [
@@ -152,7 +152,7 @@ Resolved {
152152
pattern_string: "*",
153153
regexp: Ok(
154154
Regex(
155-
"(?u)^(.*)$",
155+
"^(.*)$",
156156
),
157157
),
158158
group_name_list: [
@@ -206,7 +206,7 @@ Resolved {
206206
pattern_string: "https",
207207
regexp: Ok(
208208
Regex(
209-
"(?u)^https$",
209+
"^https$",
210210
),
211211
),
212212
group_name_list: [],
@@ -224,7 +224,7 @@ Resolved {
224224
pattern_string: "*",
225225
regexp: Ok(
226226
Regex(
227-
"(?u)^(.*)$",
227+
"^(.*)$",
228228
),
229229
),
230230
group_name_list: [
@@ -245,7 +245,7 @@ Resolved {
245245
pattern_string: "*",
246246
regexp: Ok(
247247
Regex(
248-
"(?u)^(.*)$",
248+
"^(.*)$",
249249
),
250250
),
251251
group_name_list: [
@@ -266,7 +266,7 @@ Resolved {
266266
pattern_string: "tauri.app",
267267
regexp: Ok(
268268
Regex(
269-
"(?u)^tauri\\.app$",
269+
"^tauri\\.app$",
270270
),
271271
),
272272
group_name_list: [],
@@ -284,7 +284,7 @@ Resolved {
284284
pattern_string: "",
285285
regexp: Ok(
286286
Regex(
287-
"(?u)^$",
287+
"^$",
288288
),
289289
),
290290
group_name_list: [],
@@ -302,7 +302,7 @@ Resolved {
302302
pattern_string: "*",
303303
regexp: Ok(
304304
Regex(
305-
"(?u)^(.*)$",
305+
"^(.*)$",
306306
),
307307
),
308308
group_name_list: [
@@ -323,7 +323,7 @@ Resolved {
323323
pattern_string: "*",
324324
regexp: Ok(
325325
Regex(
326-
"(?u)^(.*)$",
326+
"^(.*)$",
327327
),
328328
),
329329
group_name_list: [
@@ -344,7 +344,7 @@ Resolved {
344344
pattern_string: "*",
345345
regexp: Ok(
346346
Regex(
347-
"(?u)^(.*)$",
347+
"^(.*)$",
348348
),
349349
),
350350
group_name_list: [

0 commit comments

Comments
 (0)