aboutsummaryrefslogtreecommitdiff
path: root/contrib/libarchive/unzip/test/test_P_encryption.c
blob: ed08a068811bf1579b39d446fb5c496316c96a14 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * SPDX-License-Identifier: BSD-2-Clause
 *
 * Copyright (c) 2023 Adrian Vovk
 * All rights reserved.
 */
#include "test.h"

/* Test P arg - password protected */
DEFINE_TEST(test_P_encryption)
{
	const char *reffile = "test_encrypted.zip";
	int r;

	extract_reference_file(reffile);
	r = systemf("%s -P password %s >test.out 2>test.err", testprog, reffile);
	if (r == 256) {
		assertTextFileContents("unzip: Decryption is unsupported due to lack of crypto library\n", "test.err");
	} else {
		assertEqualInt(0, r);
		assertNonEmptyFile("test.out");
		assertEmptyFile("test.err");

		assertTextFileContents("plaintext\n", "encrypted/file.txt");
	}
}