def test_main_create_signed_badkeysize(tmpdir): priv, pub = make_rsa_keypair(1024) tmpdir.join('hello.txt').write('hello world') tmpdir.join('key.pem').write(priv) with tmpdir.as_cwd(): with raises(SystemExit): cli.main(['--productversion', 'foo', '--channel', 'bar', '-k', 'key.pem', '-c', 'test.mar', 'hello.txt'])
def test_main_create_chdir(tmpdir): tmpdir.join('hello.txt').write('hello world') tmpmar = tmpdir.join('test.mar') cli.main(['-C', str(tmpdir), '-c', str(tmpmar), 'hello.txt']) with MarReader(tmpmar.open('rb')) as m: assert len(m.mardata.index.entries) == 1 assert m.mardata.index.entries[0].name == 'hello.txt'
def test_main_create_chdir(tmpdir): tmpdir.join('hello.txt').write('hello world') tmpmar = tmpdir.join('test.mar') cli.main(['-C', str(tmpdir), '-c', str(tmpmar), 'hello.txt']) with MarReader(tmpmar.open('rb')) as m: assert len(m.mardata.index.entries) == 1 assert m.mardata.index.entries[0].name == 'hello.txt'
def test_main_create_signed_v1(tmpdir, key_size, test_keys): priv, pub = test_keys[key_size] tmpdir.join('hello.txt').write('hello world') tmpdir.join('key.pem').write(priv) with tmpdir.as_cwd(): cli.main(['--productversion', 'foo', '--channel', 'bar', '-k', 'key.pem', '-c', 'test.mar', 'hello.txt']) cli.main(['-v', 'test.mar', '-k', 'key.pem'])
def test_main_create_signed_v1(tmpdir, key_size, test_keys): priv, pub = test_keys[key_size] tmpdir.join('hello.txt').write('hello world') tmpdir.join('key.pem').write(priv) with tmpdir.as_cwd(): cli.main(['--productversion', 'foo', '--channel', 'bar', '-k', 'key.pem', '-c', 'test.mar', 'hello.txt']) cli.main(['-v', 'test.mar', '-k', 'key.pem'])
def test_main_create_signed_badkeysize(tmpdir): priv, pub = make_rsa_keypair(1024) tmpdir.join('hello.txt').write('hello world') tmpdir.join('key.pem').write(priv) with tmpdir.as_cwd(): with raises(SystemExit): cli.main(['--productversion', 'foo', '--channel', 'bar', '-k', 'key.pem', '-c', 'test.mar', 'hello.txt'])
def test_main_verify(): args = ['-v', TEST_MAR_BZ2, '-k', ':mozilla-release'] assert cli.main(args) is None with raises(SystemExit): args = ['-v', TEST_MAR_BZ2, '-k', ':mozilla-nightly'] cli.main(args) args = ['-v', TEST_MAR_BZ2] assert cli.main(args) is None
def test_main_hash(): args = ['--hash', 'sha1', TEST_MAR_BZ2] assert cli.main(args) is None with raises(SystemExit): args = ['--hash', 'sha1'] cli.main(args) with raises(SystemExit): args = ['--hash', 'sha1', TEST_MAR_BZ2, TEST_MAR_XZ] cli.main(args)
def test_main_noaction(): with raises(SystemExit): cli.main([TEST_MAR_BZ2]) with raises(SystemExit): cli.main(['-c', 'test.mar']) with raises(SystemExit): cli.main(['-t', '-v', TEST_MAR_BZ2])
def test_main_noaction(): with raises(SystemExit): cli.main([TEST_MAR_BZ2]) with raises(SystemExit): cli.main(['-c', 'test.mar']) with raises(SystemExit): cli.main(['-t', '-v', TEST_MAR_BZ2])
def test_main_verify(): args = ['-v', TEST_MAR, '-k', ':mozilla-release'] cli.main(args) with raises(SystemExit): args = ['-v', TEST_MAR, '-k', ':mozilla-nightly'] cli.main(args) with raises(SystemExit): args = ['-v', TEST_MAR] cli.main(args)
def test_main_create(tmpdir): tmpdir.join('hello.txt').write('hello world') with tmpdir.as_cwd(): cli.main(['-c', 'test.mar', 'hello.txt'])
def test_main_extract_xz(tmpdir): with tmpdir.as_cwd(): cli.main(['-x', TEST_MAR_XZ, '-J']) assert (tmpdir.join('defaults/pref/channel-prefs.js').read('rb') == b'pref("app.update.channel", "release");\n')
def test_main_extract(tmpdir): with tmpdir.as_cwd(): cli.main(['-x', TEST_MAR_BZ2]) assert (tmpdir.join('defaults/pref/channel-prefs.js').read('rb') .startswith(b'BZh'))
def test_main_list_detailed(): cli.main(['-T', TEST_MAR_BZ2])
def test_main_list(): cli.main(['-t', TEST_MAR_BZ2])
def test_main_extract(tmpdir): with tmpdir.as_cwd(): cli.main(['-x', TEST_MAR_BZ2]) assert (tmpdir.join('defaults/pref/channel-prefs.js').read('rb') .startswith(b'BZh'))
def test_main_extract_chdir(tmpdir): cli.main(['-C', str(tmpdir), '-x', TEST_MAR_BZ2]) assert tmpdir.join('defaults/pref/channel-prefs.js').check()
def test_main_extract_xz(tmpdir): with tmpdir.as_cwd(): cli.main(['-x', TEST_MAR_XZ, '-J']) assert (tmpdir.join('defaults/pref/channel-prefs.js').read('rb') == b'pref("app.update.channel", "release");\n')
def test_main_create(tmpdir): tmpdir.join('hello.txt').write('hello world') with tmpdir.as_cwd(): cli.main(['-c', 'test.mar', 'hello.txt'])
def test_main_extract_chdir(tmpdir): cli.main(['-C', str(tmpdir), '-x', TEST_MAR_BZ2]) assert tmpdir.join('defaults/pref/channel-prefs.js').check()
def test_main_add_signature(tmpdir): tmpmar = str(tmpdir.join('output.mar')) sigfile = tmpdir.join('sig') sigfile.write(b'0' * 256) args = ['--add-signature', TEST_MAR_BZ2, tmpmar, str(sigfile)] assert cli.main(args) is None
def test_main_list_detailed(): cli.main(['-T', TEST_MAR_BZ2])
def test_main_list(): cli.main(['-t', TEST_MAR_BZ2])