Example #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'])
Example #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'
Example #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'
Example #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'])
Example #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'])
Example #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'])
Example #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
Example #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)
Example #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])
Example #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])
Example #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)
Example #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'])
Example #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')
Example #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'))
Example #15
0
def test_main_list_detailed():
    cli.main(['-T', TEST_MAR_BZ2])
Example #16
0
def test_main_list():
    cli.main(['-t', TEST_MAR_BZ2])
Example #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'))
Example #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()
Example #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')
Example #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'])
Example #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()
Example #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
Example #23
0
def test_main_list_detailed():
    cli.main(['-T', TEST_MAR_BZ2])
Example #24
0
def test_main_list():
    cli.main(['-t', TEST_MAR_BZ2])