@@ -1832,6 +1832,39 @@ mod tests {
18321832 }
18331833 }
18341834
1835+ // #411: layers 1-3 of validated_repo_disk_path were only reachable through
1836+ // arguments, and layer 1 refused them all, so the Component walk ran on no
1837+ // test. Drive it through repos_dir: the allowlist never sees it, join does
1838+ // not normalize it, and the component-wise starts_with still matches the
1839+ // unnormalized prefix, so ParentDir/CurDir land on the walk itself.
1840+ #[ test]
1841+ fn component_walk_rejects_parent_dir_in_repos_dir ( ) {
1842+ let dir = TempDir :: new ( ) . unwrap ( ) ;
1843+ let repos_dir = dir. path ( ) . join ( "a" ) . join ( ".." ) ;
1844+ assert ! (
1845+ validated_repo_disk_path( & repos_dir, "did:key:z6MkAlice" , "hello" ) . is_err( ) ,
1846+ "repos_dir containing '..' must be rejected by the component walk"
1847+ ) ;
1848+ }
1849+
1850+ #[ test]
1851+ fn component_walk_rejects_cur_dir_in_repos_dir ( ) {
1852+ // Interior '.' segments never reach the walk: components() drops them.
1853+ // A leading '.' on a relative repos_dir is the one that survives.
1854+ let repos_dir = Path :: new ( "." ) . join ( "repos" ) ;
1855+ assert ! (
1856+ validated_repo_disk_path( & repos_dir, "did:key:z6MkAlice" , "hello" ) . is_err( ) ,
1857+ "relative repos_dir starting with '.' must be rejected by the component walk"
1858+ ) ;
1859+ }
1860+
1861+ #[ test]
1862+ fn component_walk_accepts_clean_repos_dir ( ) {
1863+ let dir = TempDir :: new ( ) . unwrap ( ) ;
1864+ let path = validated_repo_disk_path ( dir. path ( ) , "did:key:z6MkAlice" , "hello" ) . unwrap ( ) ;
1865+ assert ! ( path. ends_with( "hello.git" ) ) ;
1866+ }
1867+
18351868 // ── advisory_lock_key stability ─────────────────────────────────────────
18361869
18371870 #[ test]
0 commit comments