Skip to content

Commit efeb47b

Browse files
committed
fix: more tests, and many fixes, some small feats (used for debug)
* fix: configuration better tokenization management * fix: CBOR config incorrect map length * fix: reintroducing unprivileged github action coverage (better coverage) * tests: file conversion fully tested * feat: capabilities optimized for CBOR * feat: more flexibility on capabilities parsing * chore: refactor testing chsr, clearer tests * feat: parametrized timeout
1 parent 0f85c27 commit efeb47b

File tree

22 files changed

+2069
-3679
lines changed

22 files changed

+2069
-3679
lines changed

.cargo/config.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ coverage = [
2626
"tarpaulin",
2727
"--workspace",
2828
"--all-features",
29-
"--all-targets",
29+
"--bin", "dosr",
30+
"--bin", "chsr",
31+
"--lib",
3032
"--timeout",
3133
"120",
3234
"--exclude-files",
@@ -60,4 +62,7 @@ RAR_ENV_OVERRIDE_BEHAVIOR = "false"
6062
RAR_AUTHENTICATION = "perform"
6163
RAR_EXEC_INFO_DISPLAY = "hide"
6264
RAR_USER_CONSIDERED = "user"
63-
RAR_BOUNDING = "strict"
65+
RAR_BOUNDING = "strict"
66+
RAR_MAX_LOCKFILE_RETRIES = "10"
67+
RAR_LOCKFILE_RETRY_INTERVAL = "1"
68+
RAR_TIMEOUT_STORAGE = "/var/run/rar/ts"

.github/workflows/tests.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,31 @@ jobs:
4040
4141
- name: Install Dependencies
4242
run: cargo xtask dependencies -dip sudo
43-
43+
4444
- name: run integration coverage
45-
run: sudo -E /usr/local/cargo/bin/cargo +nightly coverage
45+
run: cargo +nightly coverage
46+
env:
47+
RAR_AUTHENTICATION: skip
48+
RAR_CFG_PATH: target/rootasrole.json
49+
RAR_MAX_LOCKFILE_RETRIES: 2
50+
RAR_LOCKFILE_RETRY_INTERVAL: 300
51+
SKIP_BUILD: true
52+
53+
- name: Upload coverage reports to Codecov
54+
uses: codecov/codecov-action@v3
55+
env:
56+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
57+
with:
58+
file: cobertura.xml
59+
flags: unittests
60+
61+
- name: run integration coverage as Root
62+
run: sudo -E /usr/local/cargo/bin/cargo +nightly coverage --tests
4663
env:
4764
RAR_AUTHENTICATION: skip
4865
RAR_CFG_PATH: target/rootasrole.json
66+
RAR_MAX_LOCKFILE_RETRIES: 2
67+
RAR_LOCKFILE_RETRY_INTERVAL: 300
4968
SKIP_BUILD: true
5069

5170
- name: Upload coverage reports to Codecov
@@ -54,4 +73,4 @@ jobs:
5473
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5574
with:
5675
file: cobertura.xml
57-
flags: unittests
76+
flags: admin-unittests

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rar-common/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ libc = { version= "0.2", default-features = false, features = ["std"] }
1414
strum = { version = "0.26", default-features = false, features = ["derive", "std"] }
1515
semver = { version = "1.0", default-features = false, features = ["std", "serde"] }
1616
nix = { version = "0.29", features = ["user","process", "signal", "fs", "hostname"] }
17-
capctl = { version= "0.2", default-features = false, features = ["std"] }
17+
capctl = { version= "0.2", default-features = false, features = ["std", "serde"] }
1818
pcre2 = { version = "0.2", default-features = false, optional = true }
1919
serde = { version = "1.0", default-features = false, features=["std", "rc", "derive"] }
2020
serde_json = { version= "1.0", default-features = false, features = ["std"] }
@@ -33,6 +33,7 @@ konst = { version= "0.3", default-features = false }
3333
[dev-dependencies]
3434
log = { version= "0.4", default-features = false }
3535
test-log = { version = "0.2", default-features = false }
36+
serde_test = "1.0"
3637

3738
[build-dependencies]
3839
serde = { version = "1.0", default-features = false, features= ["rc", "derive"] }

rar-common/src/database/actor.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::{
44
};
55

66
use bon::bon;
7+
use log::debug;
78
use nix::unistd::{Group, User};
89
use serde::{Deserialize, Serialize};
910
use serde_json::{Map, Value};
@@ -315,10 +316,17 @@ impl<'de> Deserialize<'de> for SGroups {
315316
formatter.write_str("a string or a number")
316317
}
317318

319+
fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
320+
where
321+
D: serde::Deserializer<'de>, {
322+
deserializer.deserialize_any(self)
323+
}
324+
318325
fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
319326
where
320327
E: serde::de::Error,
321328
{
329+
debug!("SGroups: visit_borrowed_str: {}", v);
322330
if let Ok(group) = v.parse() {
323331
Ok(SGroups::Single(SGroupType(SGenericActorType::Id(group))))
324332
} else {
@@ -332,6 +340,7 @@ impl<'de> Deserialize<'de> for SGroups {
332340
where
333341
E: serde::de::Error,
334342
{
343+
debug!("SGroups: visit_str: {}", v);
335344
if let Ok(group) = v.parse() {
336345
Ok(SGroups::Single(SGroupType(SGenericActorType::Id(group))))
337346
} else {
@@ -345,6 +354,7 @@ impl<'de> Deserialize<'de> for SGroups {
345354
where
346355
E: serde::de::Error,
347356
{
357+
debug!("SGroups: visit_string: {}", v);
348358
if let Ok(group) = v.parse() {
349359
Ok(SGroups::Single(SGroupType(SGenericActorType::Id(group))))
350360
} else {
@@ -356,6 +366,7 @@ impl<'de> Deserialize<'de> for SGroups {
356366
where
357367
E: serde::de::Error,
358368
{
369+
debug!("SGroups: visit_u64: {}", value);
359370
if value > u32::MAX as u64 {
360371
return Err(E::custom("value is too large"));
361372
}
@@ -368,6 +379,7 @@ impl<'de> Deserialize<'de> for SGroups {
368379
where
369380
A: serde::de::SeqAccess<'de>,
370381
{
382+
debug!("SGroups: visit_seq");
371383
let mut groups = Vec::new();
372384
while let Some(group) = seq.next_element::<SGroupType>()? {
373385
groups.push(group);

0 commit comments

Comments
 (0)