createTempDirWithFiles creates a temporary directory under the system default tempDir with the given dirSuffix. It also reads from certSrc, keySrc and rootSrc files are creates appropriate files under the newly create tempDir. Returns the name of the created tempDir.
(t *testing.T, dirSuffix, certSrc, keySrc, rootSrc, spiffeBundleSrc string)
| 190 | // rootSrc files are creates appropriate files under the newly create tempDir. |
| 191 | // Returns the name of the created tempDir. |
| 192 | func createTmpDirWithFiles(t *testing.T, dirSuffix, certSrc, keySrc, rootSrc, spiffeBundleSrc string) string { |
| 193 | t.Helper() |
| 194 | |
| 195 | // Create a temp directory. Passing an empty string for the first argument |
| 196 | // uses the system temp directory. |
| 197 | dir, err := os.MkdirTemp("", dirSuffix) |
| 198 | if err != nil { |
| 199 | t.Fatalf("os.MkdirTemp() failed: %v", err) |
| 200 | } |
| 201 | t.Logf("Using tmpdir: %s", dir) |
| 202 | |
| 203 | createTmpFile(t, testdata.Path(certSrc), path.Join(dir, certFile)) |
| 204 | createTmpFile(t, testdata.Path(keySrc), path.Join(dir, keyFile)) |
| 205 | createTmpFile(t, testdata.Path(rootSrc), path.Join(dir, rootFile)) |
| 206 | createTmpFile(t, testdata.Path(spiffeBundleSrc), path.Join(dir, spiffeBundleFile)) |
| 207 | return dir |
| 208 | } |
| 209 | |
| 210 | // initializeProvider performs setup steps common to all tests (except the one |
| 211 | // which uses symlinks). |
no test coverage detected