MCPcopy Create free account
hub / github.com/bodgit/sevenzip / TestOpenReaderWithPassword

Function TestOpenReaderWithPassword

reader_test.go:255–308  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

253}
254
255func TestOpenReaderWithPassword(t *testing.T) {
256 t.Parallel()
257
258 tables := []struct {
259 name, file, password string
260 }{
261 {
262 name: testNoHeaderCompression,
263 file: "t2.7z",
264 password: testPassword,
265 },
266 {
267 name: "with header compression",
268 file: "t3.7z",
269 password: testPassword,
270 },
271 {
272 name: "unencrypted headers compressed files",
273 file: "t4.7z",
274 password: testPassword,
275 },
276 {
277 name: "unencrypted headers uncompressed files",
278 file: "t5.7z",
279 password: testPassword,
280 },
281 {
282 name: "issue 75",
283 file: "7zcracker.7z",
284 password: "876",
285 },
286 }
287
288 for _, table := range tables {
289 t.Run(table.name, func(t *testing.T) {
290 t.Parallel()
291
292 r, err := sevenzip.OpenReaderWithPassword(filepath.Join("testdata", table.file), table.password)
293 if err != nil {
294 t.Fatal(err)
295 }
296
297 defer func() {
298 if err := r.Close(); err != nil {
299 t.Fatal(err)
300 }
301 }()
302
303 if err := extractArchive(t, &r.Reader, -1, crc32.NewIEEE(), iotest.OneByteReader, true); err != nil {
304 t.Fatal(err)
305 }
306 })
307 }
308}
309
310func TestOpenReaderWithWrongPassword(t *testing.T) {
311 t.Parallel()

Callers

nothing calls this directly

Calls 3

OpenReaderWithPasswordFunction · 0.92
extractArchiveFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…