Exemple #1
0
def test_dont_provide_auth_info_to_update_command(run_command_params):
    _init_data()
    bigmac = model.get_project(macgyver, macgyver, 'bigmac', create=True)
    bigmac.save_file(".hg/hgrc", "# test rc file\n")
    keychain = vcs.KeyChain(macgyver, "foobar")
    keychain.set_ssh_for_project(bigmac, vcs.AUTH_BOTH)
    
    cmd = ["update"]
    try:
        output = vcs.run_command(macgyver, bigmac, cmd)
        assert False, "Expected authorization problem for project requiring auth"
    except model.NotAuthorized:
        pass
Exemple #2
0
def test_run_a_diff(run_command_params):
    _init_data()
    bigmac = model.get_project(macgyver, macgyver, 'bigmac', create=True)
    bigmac.save_file(".hg/hgrc", "# test rc file\n")
    cmd = ["diff"]
    output = vcs.run_command(macgyver, bigmac, cmd)
    command, context = run_command_params
    
    working_dir = context.working_dir
    
    assert isinstance(command, hg.diff)
    assert working_dir == bigmac.location
    assert output == diff_output
Exemple #3
0
def test_dont_provide_auth_info_to_update_command(run_command_params):
    _init_data()
    bigmac = get_project(macgyver, macgyver, 'bigmac', create=True)
    bigmac.save_file(".hg/hgrc", "# test rc file\n")
    keychain = vcs.KeyChain(macgyver, "foobar")
    keychain.set_ssh_for_project(bigmac, vcs.AUTH_BOTH)
    
    cmd = ["update"]
    output = vcs.run_command(macgyver, bigmac, cmd)
    
    resp = app.post("/messages/")
    messages = simplejson.loads(resp.body)
    assert len(messages) == 1
    output = messages[0]
    assert 'output' in output
    assert output['output'] == 'Keychain password is required for this command.'
Exemple #4
0
def test_dont_provide_auth_info_to_update_command(run_command_params):
    _init_data()
    bigmac = get_project(macgyver, macgyver, 'bigmac', create=True)
    bigmac.save_file(".hg/hgrc", "# test rc file\n")
    keychain = vcs.KeyChain(macgyver, "foobar")
    keychain.set_ssh_for_project(bigmac, vcs.AUTH_BOTH)
    
    cmd = ["update"]
    output = vcs.run_command(macgyver, bigmac, cmd)
    
    resp = app.post("/messages/")
    messages = simplejson.loads(resp.body)
    assert len(messages) == 1
    output = messages[0]
    assert 'output' in output
    assert output['output'] == 'Keychain password is required for this command.'
Exemple #5
0
def vcs_command(request, response):
    user = request.user
    project_name = request.kwargs['project_name']
    request_info = simplejson.loads(request.body)
    args = request_info['command']
    kcpass = request_info.get('kcpass')
    
    # special support for clone/checkout
    if vcs.is_new_project_command(args):
        raise BadRequest("Use /vcs/clone/ to create a new project")
    else:
        project = model.get_project(user, user, project_name)
        output = vcs.run_command(user, project, args, kcpass)
    
    response.content_type = "application/json"
    response.body = simplejson.dumps({'output' : output})
    return response()
Exemple #6
0
def test_provide_auth_info_to_update_command(run_command_params):
    _init_data()
    bigmac = model.get_project(macgyver, macgyver, 'bigmac', create=True)
    bigmac.save_file(".hg/hgrc", "# test rc file\n")
    metadata = bigmac.metadata
    metadata['remote_url'] = 'http://hg.mozilla.org/labs/bespin'
    metadata.close()
    keychain = vcs.KeyChain(macgyver, "foobar")
    keychain.set_ssh_for_project(bigmac, vcs.AUTH_BOTH)
    
    cmd = ["update", "_BESPIN_REMOTE_URL"]
    output = vcs.run_command(macgyver, bigmac, cmd, "foobar")
    
    command, context = run_command_params
    command_line = command.get_command_line()
    assert command_line[:3] == ["hg", "fetch", "-e"]
    assert command_line[3].startswith("ssh -i")
    assert command_line[4] == "http://hg.mozilla.org/labs/bespin"
    # make sure it's not unicode
    assert isinstance(command_line[4], str)
    assert len(command_line) == 5
Exemple #7
0
def test_provide_auth_info_to_update_command(run_command_params):
    _init_data()
    bigmac = get_project(macgyver, macgyver, 'bigmac', create=True)
    bigmac.save_file(".hg/hgrc", "# test rc file\n")
    metadata = bigmac.metadata
    metadata['remote_url'] = 'http://hg.mozilla.org/labs/bespin'
    metadata.close()
    keychain = vcs.KeyChain(macgyver, "foobar")
    keychain.set_ssh_for_project(bigmac, vcs.AUTH_BOTH)
    
    cmd = ["update", "_BESPIN_REMOTE_URL"]
    output = vcs.run_command(macgyver, bigmac, cmd, "foobar")
    
    command, context = run_command_params
    command_line = command.get_command_line()
    assert command_line[:3] == ["hg", "fetch", "-e"]
    assert command_line[3].startswith("ssh -i")
    assert command_line[4] == "http://hg.mozilla.org/labs/bespin"
    # make sure it's not unicode
    assert isinstance(command_line[4], str)
    assert len(command_line) == 5
def vcs_command(request, response):
    user = request.user
    project_name = request.kwargs['project_name']
    request_info = simplejson.loads(request.body)
    args = request_info['command']
    kcpass = request_info.get('kcpass')
    
    try:
        taskname = "vcs %s command" % (args[0])
    except IndexError:
        taskname = "vcs command"
    
    # special support for clone/checkout
    if vcs.is_new_project_command(args):
        raise BadRequest("Use /vcs/clone/ to create a new project")
    else:
        project = get_project(user, user, project_name)
        jobid = vcs.run_command(user, project, args, kcpass)
    
    response.content_type = "application/json"
    response.body = simplejson.dumps(dict(jobid=jobid, taskname=taskname))
    return response()
Exemple #9
0
def vcs_command(request, response):
    user = request.user
    project_name = request.kwargs['project_name']
    request_info = simplejson.loads(request.body)
    args = request_info['command']
    log.debug("VCS command: %s", args)
    kcpass = request_info.get('kcpass')

    try:
        taskname = "vcs %s command" % (args[0])
    except IndexError:
        taskname = "vcs command"

    # special support for clone/checkout
    if vcs.is_new_project_command(args):
        raise BadRequest("Use /vcs/clone/ to create a new project")
    else:
        project = get_project(user, user, project_name)
        jobid = vcs.run_command(user, project, args, kcpass)

    response.content_type = "application/json"
    response.body = simplejson.dumps(dict(jobid=jobid, taskname=taskname))
    return response()