(t *testing.T)
| 1835 | } |
| 1836 | |
| 1837 | func TestValidateAttestationOutputPath(t *testing.T) { |
| 1838 | // Get current working directory for tests |
| 1839 | cwd, err := os.Getwd() |
| 1840 | require.NoError(t, err) |
| 1841 | |
| 1842 | tests := []struct { |
| 1843 | name string |
| 1844 | path string |
| 1845 | expected string |
| 1846 | shouldError bool |
| 1847 | errorMsg string |
| 1848 | }{ |
| 1849 | { |
| 1850 | name: "empty path defaults to vsa- prefix", |
| 1851 | path: "", |
| 1852 | expected: "vsa-", |
| 1853 | }, |
| 1854 | { |
| 1855 | name: "/tmp path is allowed", |
| 1856 | path: "/tmp/vsa-test", |
| 1857 | expected: "/tmp/vsa-test", |
| 1858 | }, |
| 1859 | { |
| 1860 | name: "/tmp itself is allowed", |
| 1861 | path: "/tmp", |
| 1862 | expected: "/tmp", |
| 1863 | }, |
| 1864 | { |
| 1865 | name: "relative path under cwd is allowed", |
| 1866 | path: "./vsa-output", |
| 1867 | expected: filepath.Join(cwd, "vsa-output"), |
| 1868 | }, |
| 1869 | { |
| 1870 | name: "subdirectory under cwd is allowed", |
| 1871 | path: "vsa-output", |
| 1872 | expected: filepath.Join(cwd, "vsa-output"), |
| 1873 | }, |
| 1874 | { |
| 1875 | name: "/etc path is rejected", |
| 1876 | path: "/etc/vsa", |
| 1877 | shouldError: true, |
| 1878 | errorMsg: "attestation output directory must be under /tmp or current working directory", |
| 1879 | }, |
| 1880 | { |
| 1881 | name: "/var path is rejected", |
| 1882 | path: "/var/vsa", |
| 1883 | shouldError: true, |
| 1884 | errorMsg: "attestation output directory must be under /tmp or current working directory", |
| 1885 | }, |
| 1886 | { |
| 1887 | name: "root path is rejected", |
| 1888 | path: "/", |
| 1889 | shouldError: true, |
| 1890 | errorMsg: "attestation output directory must be under /tmp or current working directory", |
| 1891 | }, |
| 1892 | { |
| 1893 | name: "path with .. under cwd is allowed after cleaning", |
| 1894 | path: "./foo/../vsa", |
nothing calls this directly
no test coverage detected