(t *testing.T)
| 179 | } |
| 180 | |
| 181 | func TestGetTrustedRoot(t *testing.T) { |
| 182 | mirror := "https://tuf-repo.github.com" |
| 183 | root := test.NormalizeRelativePath("../verification/embed/tuf-repo.github.com/root.json") |
| 184 | |
| 185 | opts := &Options{ |
| 186 | TufUrl: mirror, |
| 187 | TufRootPath: root, |
| 188 | } |
| 189 | |
| 190 | reg := &httpmock.Registry{} |
| 191 | client := &http.Client{} |
| 192 | httpmock.ReplaceTripper(client, reg) |
| 193 | |
| 194 | t.Run("failed to create TUF root", func(t *testing.T) { |
| 195 | err := getTrustedRoot(newTUFErrClient, opts, client) |
| 196 | require.Error(t, err) |
| 197 | require.ErrorContains(t, err, "failed to create TUF client") |
| 198 | }) |
| 199 | |
| 200 | t.Run("fails because the root cannot be found", func(t *testing.T) { |
| 201 | opts.TufRootPath = test.NormalizeRelativePath("./does/not/exist/root.json") |
| 202 | err := getTrustedRoot(tuf.New, opts, client) |
| 203 | require.Error(t, err) |
| 204 | require.ErrorContains(t, err, "failed to read root file") |
| 205 | }) |
| 206 | |
| 207 | } |
| 208 | |
| 209 | type stubAuthConfig struct { |
| 210 | config.AuthConfig |
nothing calls this directly
no test coverage detected