File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -109,3 +109,23 @@ func TestTypes_isAllowedDirWithSymlink(t *testing.T) {
109109 require .False (t , result , "Symlink in allowed directory should return false" )
110110 })
111111}
112+
113+ func TestTypes_isSymlink (t * testing.T ) {
114+ // create temp dir
115+ tempDir := t .TempDir ()
116+ tempConf := tempDir + "test.conf"
117+ defer os .RemoveAll (tempDir )
118+
119+ t .Run ("Test 1: File is not a symlink" , func (t * testing.T ) {
120+ filePath := tempConf
121+ err := os .WriteFile (filePath , []byte ("test content" ), 0o600 )
122+ require .NoError (t , err )
123+ assert .False (t , isSymlink (filePath ), "File is not a symlink" )
124+ })
125+ t .Run ("Test 2: File is a symlink" , func (t * testing.T ) {
126+ filePath := tempDir + "test_conf_link"
127+ err := os .Symlink (tempConf , filePath )
128+ require .NoError (t , err )
129+ assert .True (t , isSymlink (filePath ), "File is a symlink" )
130+ })
131+ }
You can’t perform that action at this time.
0 commit comments