Esempio n. 1
0
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'])
Esempio n. 2
0
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'
Esempio n. 3
0
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'
Esempio n. 4
0
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'])
Esempio n. 5
0
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'])
Esempio n. 6
0
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'])
Esempio n. 7
0
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
Esempio n. 8
0
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)
Esempio n. 9
0
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])
Esempio n. 10
0
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])
Esempio n. 11
0
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)
Esempio n. 12
0
def test_main_create(tmpdir):
    tmpdir.join('hello.txt').write('hello world')
    with tmpdir.as_cwd():
        cli.main(['-c', 'test.mar', 'hello.txt'])
Esempio n. 13
0
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')
Esempio n. 14
0
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'))
Esempio n. 15
0
def test_main_list_detailed():
    cli.main(['-T', TEST_MAR_BZ2])
Esempio n. 16
0
def test_main_list():
    cli.main(['-t', TEST_MAR_BZ2])
Esempio n. 17
0
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'))
Esempio n. 18
0
def test_main_extract_chdir(tmpdir):
    cli.main(['-C', str(tmpdir), '-x', TEST_MAR_BZ2])
    assert tmpdir.join('defaults/pref/channel-prefs.js').check()
Esempio n. 19
0
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')
Esempio n. 20
0
def test_main_create(tmpdir):
    tmpdir.join('hello.txt').write('hello world')
    with tmpdir.as_cwd():
        cli.main(['-c', 'test.mar', 'hello.txt'])
Esempio n. 21
0
def test_main_extract_chdir(tmpdir):
    cli.main(['-C', str(tmpdir), '-x', TEST_MAR_BZ2])
    assert tmpdir.join('defaults/pref/channel-prefs.js').check()
Esempio n. 22
0
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
Esempio n. 23
0
def test_main_list_detailed():
    cli.main(['-T', TEST_MAR_BZ2])
Esempio n. 24
0
def test_main_list():
    cli.main(['-t', TEST_MAR_BZ2])