byssus 0.1.0

Live, read-only filesystem attachments between isolated workspaces
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
//! Opened runtime resources: root and membership directory descriptors.

use std::collections::{BTreeMap, BTreeSet};
use std::ffi::CStr;
use std::fmt;
use std::io;
use std::os::fd::{AsFd, BorrowedFd, OwnedFd};

use rustix::fs::{AtFlags, FileType, Mode, OFlags, StatxFlags};

use crate::config::{AbsPath, Config, GroupConfig, GroupSetConfig};
use crate::fsops;
use crate::membership::{EntryKind, RejectReason, Rejection};
use crate::name::{GroupId, Name, display_bytes};
use crate::reconcile::observe::Note;

/// Descriptors for one configured group.
#[derive(Debug)]
pub struct GroupRuntime {
    /// The group's configuration.
    pub config: GroupConfig,
    /// Membership directory, opened for reading.
    pub membership_dir: OwnedFd,
}

/// What an [`OpenGroupError`] concerns.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Subject {
    /// A statically configured group.
    Group(GroupId),
    /// A group set.
    Set(Name),
}

impl fmt::Display for Subject {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::Group(group) => write!(f, "group '{group}'"),
            Self::Set(set) => write!(f, "group set '{set}'"),
        }
    }
}

/// Why a group's or group set's directories could not be opened.
#[derive(Debug, thiserror::Error)]
#[error("{subject}: cannot open {field} {path}: {source}")]
pub struct OpenGroupError {
    /// The group or set.
    pub subject: Subject,
    /// Which configured directory.
    pub field: &'static str,
    /// Its path.
    pub path: AbsPath,
    /// Underlying error.
    pub source: io::Error,
}

/// Opens trusted roots by path, caching descriptors.
///
/// Configured roots are opened up front; roots recorded in state for groups
/// that have since been removed or relocated are opened on demand. Failed
/// opens are not cached, so a root that appears later is picked up.
#[derive(Debug, Default)]
pub struct Roots {
    fds: BTreeMap<AbsPath, OwnedFd>,
}

impl Roots {
    /// Returns a descriptor for `root`, opening it if necessary.
    pub fn get(&mut self, root: &AbsPath) -> Result<BorrowedFd<'_>, String> {
        if !self.fds.contains_key(root) {
            let fd = fsops::open_root(root.as_path()).map_err(|e| e.to_string())?;
            self.fds.insert(root.clone(), fd);
        }
        self.fds
            .get(root)
            .map(AsFd::as_fd)
            .ok_or_else(|| "root descriptor missing".to_owned())
    }

    /// Inserts an already-opened root.
    pub fn insert(&mut self, root: AbsPath, fd: OwnedFd) {
        self.fds.insert(root, fd);
    }
}

/// A group set: its configuration and its membership root, opened for
/// reading.
#[derive(Debug)]
pub struct SetRuntime {
    /// The set's configuration.
    pub config: GroupSetConfig,
    /// The membership root, whose subdirectories are the set's groups.
    pub root_dir: OwnedFd,
}

/// The outcome of discovering group sets' groups.
#[derive(Debug, Default)]
pub struct Discovery {
    /// Problems to report.
    pub notes: Vec<Note>,
    /// Groups, or intermediate directories (path prefixes of groups), that
    /// exist but could not be read this pass; records of every group at or
    /// beneath them must be left untouched.
    pub unavailable: BTreeSet<GroupId>,
    /// Sets whose membership root could not be read this pass; all their
    /// groups' records must be left untouched.
    pub unavailable_sets: BTreeSet<Name>,
    /// Sets whose membership root was scanned successfully.
    pub scanned_sets: BTreeSet<Name>,
}

/// All opened groups plus the root cache.
#[derive(Debug, Default)]
pub struct Runtime {
    /// Statically configured groups and the groups discovered in sets by the
    /// most recent [`Runtime::discover`].
    pub groups: BTreeMap<GroupId, GroupRuntime>,
    /// Group sets by name.
    pub sets: BTreeMap<Name, SetRuntime>,
    /// Intermediate directories of group sets with subgroups (for example an
    /// org directory holding subgroup directories), by the set and path
    /// prefix they represent, from the most recent [`Runtime::discover`].
    pub intermediates: BTreeMap<GroupId, AbsPath>,
    /// Root descriptors.
    pub roots: Roots,
}

impl Runtime {
    /// Opens every configured group's source root, target root and membership
    /// directory. Fails on the first error so a configuration is never
    /// partially applied.
    pub fn open(config: &Config) -> Result<Self, OpenGroupError> {
        let mut runtime = Self::default();
        for group in config.groups.values() {
            runtime.open_group(group)?;
        }
        for set in config.group_sets.values() {
            runtime.open_set(set)?;
        }
        Ok(runtime)
    }

    /// Opens every group it can, returning the errors for those it cannot.
    /// Used by read-only commands, which report unavailable groups instead of
    /// failing.
    #[must_use]
    pub fn open_lenient(config: &Config) -> (Self, Vec<OpenGroupError>) {
        let mut runtime = Self::default();
        let mut errors: Vec<OpenGroupError> = config
            .groups
            .values()
            .filter_map(|group| runtime.open_group(group).err())
            .collect();
        errors.extend(
            config
                .group_sets
                .values()
                .filter_map(|set| runtime.open_set(set).err()),
        );
        (runtime, errors)
    }

    fn open_set(&mut self, set: &GroupSetConfig) -> Result<(), OpenGroupError> {
        let err = |field, path: &AbsPath, source| OpenGroupError {
            subject: Subject::Set(set.name.clone()),
            field,
            path: path.clone(),
            source,
        };
        let source_root = fsops::open_root(set.source_root.as_path())
            .map_err(|e| err("source_root", &set.source_root, e))?;
        let target_root = fsops::open_root(set.target_root.as_path())
            .map_err(|e| err("target_root", &set.target_root, e))?;
        let root_dir = fsops::open_dir_for_reading(set.membership_root.as_path())
            .map_err(|e| err("membership_root", &set.membership_root, e))?;
        self.roots.insert(set.source_root.clone(), source_root);
        self.roots.insert(set.target_root.clone(), target_root);
        self.sets.insert(
            set.name.clone(),
            SetRuntime {
                config: set.clone(),
                root_dir,
            },
        );
        Ok(())
    }

    /// Replaces the set groups in [`Runtime::groups`] with the groups found
    /// in each set's membership root now. Sets in `skip` (degraded) are not
    /// scanned. Each group's membership directory is opened afresh, beneath
    /// the membership root, without following symlinks.
    pub fn discover(&mut self, skip: &BTreeSet<Name>) -> Discovery {
        self.groups.retain(|id, _| id.set().is_none());
        self.intermediates.clear();
        let mut discovery = Discovery::default();
        for (set_name, set) in &self.sets {
            if skip.contains(set_name) {
                continue;
            }
            match discover_set(set) {
                Ok(scan) => {
                    discovery.scanned_sets.insert(set_name.clone());
                    for group in scan.groups {
                        self.groups.insert(group.config.name.clone(), group);
                    }
                    self.intermediates.extend(scan.intermediates);
                    discovery.notes.extend(scan.notes);
                    discovery.unavailable.extend(scan.unavailable);
                }
                Err(note) => {
                    discovery.notes.push(note);
                    discovery.unavailable_sets.insert(set_name.clone());
                }
            }
        }
        discovery
    }

    fn open_group(&mut self, group: &GroupConfig) -> Result<(), OpenGroupError> {
        let err = |field, path: &AbsPath, source| OpenGroupError {
            subject: Subject::Group(group.name.clone()),
            field,
            path: path.clone(),
            source,
        };
        let source_root = fsops::open_root(group.source_root.as_path())
            .map_err(|e| err("source_root", &group.source_root, e))?;
        let target_root = fsops::open_root(group.target_root.as_path())
            .map_err(|e| err("target_root", &group.target_root, e))?;
        let membership_dir = fsops::open_dir_for_reading(group.membership.as_path())
            .map_err(|e| err("membership", &group.membership, e))?;
        self.roots.insert(group.source_root.clone(), source_root);
        self.roots.insert(group.target_root.clone(), target_root);
        self.groups.insert(
            group.name.clone(),
            GroupRuntime {
                config: group.clone(),
                membership_dir,
            },
        );
        Ok(())
    }
}

#[derive(Default)]
struct SetScan {
    groups: Vec<GroupRuntime>,
    intermediates: Vec<(GroupId, AbsPath)>,
    notes: Vec<Note>,
    unavailable: Vec<GroupId>,
}

fn discover_set(set: &SetRuntime) -> Result<SetScan, Note> {
    let set_name = &set.config.name;
    if fsops::is_deleted(set.root_dir.as_fd()).unwrap_or(false) {
        return Err(Note::SetRootDeleted {
            set: set_name.clone(),
        });
    }
    let mut scan = SetScan::default();
    scan_level(set, set.root_dir.as_fd(), &[], &mut scan).map_err(|e| Note::SetRootUnreadable {
        set: set_name.clone(),
        error: e.to_string(),
    })?;
    Ok(scan)
}

/// Checks that a group set entry is a directory with a valid name. Returns
/// `Ok(None)` if it vanished since being listed.
fn classify_set_entry(dir: BorrowedFd<'_>, file_name: &CStr) -> Result<Option<Name>, RejectReason> {
    let name = Name::from_bytes(file_name.to_bytes()).map_err(RejectReason::InvalidName)?;
    let kind = rustix::fs::statx(dir, file_name, AtFlags::SYMLINK_NOFOLLOW, StatxFlags::TYPE)
        .map(|st| FileType::from_raw_mode(u32::from(st.stx_mode)));
    match kind {
        Ok(FileType::Directory) => Ok(Some(name)),
        Err(rustix::io::Errno::NOENT) => Ok(None),
        Ok(other) => Err(RejectReason::NotDirectory(match other {
            FileType::RegularFile => EntryKind::Regular { size: 0 },
            FileType::Symlink => EntryKind::Symlink,
            FileType::Fifo => EntryKind::Fifo,
            FileType::Socket => EntryKind::Socket,
            FileType::CharacterDevice => EntryKind::CharDevice,
            FileType::BlockDevice => EntryKind::BlockDevice,
            FileType::Directory | FileType::Unknown => EntryKind::Unknown,
        })),
        Err(e) => Err(RejectReason::Inaccessible(e.to_string())),
    }
}

/// Scans one directory level of a group set. `prefix` holds the level names
/// above `dir` (empty for the membership root). Errors reading `dir` itself
/// are returned; problems with individual entries are recorded in `scan`.
fn scan_level(
    set: &SetRuntime,
    dir: BorrowedFd<'_>,
    prefix: &[Name],
    scan: &mut SetScan,
) -> io::Result<()> {
    let set_name = &set.config.name;
    let mut reader = rustix::fs::Dir::read_from(dir)?;
    while let Some(entry) = reader.read() {
        let entry = entry?;
        let file_name: &CStr = entry.file_name();
        let bytes = file_name.to_bytes();
        if bytes.starts_with(b".") {
            continue;
        }
        let display_name = prefix
            .iter()
            .map(|n| n.as_str().to_owned())
            .chain(std::iter::once(display_bytes(bytes)))
            .collect::<Vec<_>>()
            .join("/");
        let reject = |reason| Note::SetEntryRejected {
            set: set_name.clone(),
            rejection: Rejection {
                display_name: display_name.clone(),
                reason,
            },
        };
        let name = match classify_set_entry(dir, file_name) {
            Ok(Some(name)) => name,
            // Vanished since listing.
            Ok(None) => continue,
            Err(reason) => {
                scan.notes.push(reject(reason));
                continue;
            }
        };

        let mut path = prefix.to_vec();
        path.push(name);
        let id = GroupId::in_set(set_name.clone(), path.clone());
        let opened = match rustix::fs::openat2(
            dir,
            file_name,
            OFlags::RDONLY | OFlags::DIRECTORY | OFlags::CLOEXEC,
            Mode::empty(),
            fsops::CONFINED,
        ) {
            Ok(fd) => fd,
            Err(rustix::io::Errno::NOENT) => continue,
            Err(e) => {
                scan.notes.push(Note::MembershipUnreadable {
                    group: id.clone(),
                    error: e.to_string(),
                });
                scan.unavailable.push(id);
                continue;
            }
        };

        if path.len() < set.config.depth {
            let dir_path = path
                .iter()
                .fold(set.config.membership_root.clone(), |d, level| {
                    d.join_name(level)
                });
            if let Err(e) = scan_level(set, opened.as_fd(), &path, scan) {
                scan.notes.push(Note::MembershipUnreadable {
                    group: id.clone(),
                    error: e.to_string(),
                });
                scan.unavailable.push(id);
                continue;
            }
            scan.intermediates.push((id, dir_path));
            continue;
        }

        match set.config.group(&path) {
            Ok(config) => scan.groups.push(GroupRuntime {
                config,
                membership_dir: opened,
            }),
            Err(e) => scan
                .notes
                .push(reject(RejectReason::Inaccessible(format!("template: {e}")))),
        }
    }
    Ok(())
}

#[cfg(test)]
mod tests {
    use std::path::Path;

    use super::*;
    use crate::config::load_from_strs;

    fn config_for(dir: &Path, membership: &str) -> Config {
        let p = |s: &str| dir.join(s).display().to_string();
        let text = format!(
            "[groups.g]\nsource_root = \"{}\"\nsource = \"{{name}}\"\ntarget_root = \"{}\"\ntarget = \"{{name}}\"\nmembership = \"{}\"\n",
            p("src"),
            p("view"),
            p(membership)
        );
        load_from_strs(&[(Path::new("/x.toml"), &text, true)])
            .unwrap()
            .config
    }

    #[test]
    fn opens_groups_and_caches_roots() {
        let dir = tempfile::tempdir().unwrap();
        for d in ["src", "view", "members"] {
            std::fs::create_dir(dir.path().join(d)).unwrap();
        }
        let config = config_for(dir.path(), "members");
        let mut rt = Runtime::open(&config).unwrap();
        assert_eq!(rt.groups.len(), 1);
        let src = AbsPath::new(&dir.path().join("src").display().to_string()).unwrap();
        assert!(rt.roots.get(&src).is_ok());

        let later = AbsPath::new(&dir.path().join("later").display().to_string()).unwrap();
        assert!(rt.roots.get(&later).is_err());
        // Failures are not cached: once the directory exists it opens.
        std::fs::create_dir(dir.path().join("later")).unwrap();
        assert!(rt.roots.get(&later).is_ok());
    }

    #[test]
    fn open_fails_on_missing_membership_dir() {
        let dir = tempfile::tempdir().unwrap();
        for d in ["src", "view"] {
            std::fs::create_dir(dir.path().join(d)).unwrap();
        }
        let config = config_for(dir.path(), "absent");
        let err = Runtime::open(&config).unwrap_err();
        assert_eq!(err.field, "membership");
        let (rt, errors) = Runtime::open_lenient(&config);
        assert!(rt.groups.is_empty());
        assert_eq!(errors.len(), 1);
    }

    fn set_config(dir: &Path) -> Config {
        for d in ["orgs", "membership/research"] {
            std::fs::create_dir_all(dir.join(d)).unwrap();
        }
        let p = |s: &str| dir.join(s).display().to_string();
        let text = format!(
            "[group_sets.research]\nmembership_root = \"{}\"\nsource_root = \"{}\"\nsource = \"{{group}}/projects/{{name}}\"\ntarget_root = \"{}\"\ntarget = \"{{group}}/view/{{name}}\"\n",
            p("membership/research"),
            p("orgs"),
            p("orgs")
        );
        load_from_strs(&[(Path::new("/x.toml"), &text, true)])
            .unwrap()
            .config
    }

    fn ids(rt: &Runtime) -> Vec<String> {
        rt.groups.keys().map(ToString::to_string).collect()
    }

    #[test]
    fn discovers_set_groups_and_rejects_other_entries() {
        let dir = tempfile::tempdir().unwrap();
        let config = set_config(dir.path());
        let root = dir.path().join("membership/research");
        for g in ["acme", "beta", "bad:name"] {
            std::fs::create_dir(root.join(g)).unwrap();
        }
        std::fs::create_dir(root.join(".hidden")).unwrap();
        std::fs::write(root.join("file"), "").unwrap();
        std::os::unix::fs::symlink(root.join("acme"), root.join("link")).unwrap();

        let mut rt = Runtime::open(&config).unwrap();
        assert!(rt.groups.is_empty(), "no groups before discovery");
        let discovery = rt.discover(&BTreeSet::new());
        assert_eq!(ids(&rt), ["research/acme", "research/beta"]);
        assert!(discovery.unavailable.is_empty() && discovery.unavailable_sets.is_empty());
        assert_eq!(discovery.scanned_sets.len(), 1);
        let rejected: BTreeSet<String> = discovery
            .notes
            .iter()
            .filter_map(|n| match n {
                Note::SetEntryRejected { rejection, .. } => Some(rejection.display_name.clone()),
                _ => None,
            })
            .collect();
        assert_eq!(
            rejected,
            ["bad:name", "file", "link"]
                .iter()
                .map(|s| (*s).to_owned())
                .collect()
        );

        let acme = &rt.groups[&GroupId::parse("research/acme").unwrap()];
        assert_eq!(acme.config.source.as_str(), "acme/projects/{name}");
        assert_eq!(acme.config.membership.as_path(), root.join("acme"));

        // Groups follow the directory: removal and addition.
        std::fs::remove_dir(root.join("beta")).unwrap();
        std::fs::create_dir(root.join("gamma")).unwrap();
        rt.discover(&BTreeSet::new());
        assert_eq!(ids(&rt), ["research/acme", "research/gamma"]);

        // Skipped (degraded) sets contribute no groups.
        let mut skip = BTreeSet::new();
        skip.insert(Name::new("research").unwrap());
        let discovery = rt.discover(&skip);
        assert!(rt.groups.is_empty());
        assert!(discovery.scanned_sets.is_empty());
    }

    #[test]
    fn static_groups_survive_discovery() {
        let dir = tempfile::tempdir().unwrap();
        for d in ["src", "view", "members"] {
            std::fs::create_dir(dir.path().join(d)).unwrap();
        }
        let mut config = config_for(dir.path(), "members");
        config.group_sets = set_config(dir.path()).group_sets;
        std::fs::create_dir(dir.path().join("membership/research/acme")).unwrap();
        let mut rt = Runtime::open(&config).unwrap();
        rt.discover(&BTreeSet::new());
        assert_eq!(ids(&rt), ["g", "research/acme"]);
        rt.discover(&BTreeSet::new());
        assert_eq!(ids(&rt), ["g", "research/acme"]);
    }

    #[test]
    fn deleted_set_root_is_reported() {
        let dir = tempfile::tempdir().unwrap();
        let config = set_config(dir.path());
        let mut rt = Runtime::open(&config).unwrap();
        std::fs::remove_dir(dir.path().join("membership/research")).unwrap();
        let discovery = rt.discover(&BTreeSet::new());
        assert!(matches!(discovery.notes[..], [Note::SetRootDeleted { .. }]));
        assert_eq!(discovery.unavailable_sets.len(), 1);
    }

    #[test]
    fn open_lenient_reports_set_subject() {
        let dir = tempfile::tempdir().unwrap();
        let config = set_config(dir.path());
        std::fs::remove_dir(dir.path().join("membership/research")).unwrap();
        let (rt, errors) = Runtime::open_lenient(&config);
        assert!(rt.sets.is_empty());
        assert_eq!(
            errors[0].subject,
            Subject::Set(Name::new("research").unwrap())
        );
        assert!(errors[0].to_string().starts_with("group set 'research'"));
    }

    fn subgroup_config(dir: &Path) -> Config {
        for d in ["orgs", "membership"] {
            std::fs::create_dir_all(dir.join(d)).unwrap();
        }
        let p = |s: &str| dir.join(s).display().to_string();
        let text = format!(
            "[group_sets.projects]\nmembership_root = \"{}\"\nsource_root = \"{}\"\nsource = \"{{group}}/projects/{{name}}\"\ntarget_root = \"{}\"\ntarget = \"{{group}}/groups/{{subgroup}}/view/{{name}}\"\n",
            p("membership"),
            p("orgs"),
            p("orgs")
        );
        load_from_strs(&[(Path::new("/x.toml"), &text, true)])
            .unwrap()
            .config
    }

    #[test]
    fn discovers_subgroups_two_levels_deep() {
        let dir = tempfile::tempdir().unwrap();
        let config = subgroup_config(dir.path());
        let root = dir.path().join("membership");
        for d in [
            "acme/research",
            "acme/monitoring",
            "beta/research",
            "empty-org",
        ] {
            std::fs::create_dir_all(root.join(d)).unwrap();
        }
        std::fs::write(root.join("stray-file"), "").unwrap();
        std::fs::write(root.join("acme/member-at-org-level"), "").unwrap();
        std::fs::create_dir(root.join("acme/.tmp")).unwrap();

        let mut rt = Runtime::open(&config).unwrap();
        let discovery = rt.discover(&BTreeSet::new());
        assert_eq!(
            ids(&rt),
            [
                "projects/acme/monitoring",
                "projects/acme/research",
                "projects/beta/research"
            ]
        );
        let intermediates: Vec<String> = rt.intermediates.keys().map(ToString::to_string).collect();
        assert_eq!(
            intermediates,
            ["projects/acme", "projects/beta", "projects/empty-org"]
        );
        let rejected: BTreeSet<String> = discovery
            .notes
            .iter()
            .filter_map(|n| match n {
                Note::SetEntryRejected { rejection, .. } => Some(rejection.display_name.clone()),
                _ => None,
            })
            .collect();
        assert_eq!(
            rejected,
            ["acme/member-at-org-level", "stray-file"]
                .iter()
                .map(|s| (*s).to_owned())
                .collect()
        );
        let research = &rt.groups[&GroupId::parse("projects/acme/research").unwrap()];
        assert_eq!(
            research.config.target.as_str(),
            "acme/groups/research/view/{name}"
        );
        assert_eq!(
            research.config.membership.as_path(),
            root.join("acme/research")
        );
    }
}