def step_impl(context):
    d = context.good_login
    assert context.good_login['source']['username'] == 'ValidUser'
    assert 'somethingicantaccess' not in context.good_build_url
    httpretty.enable()
    httpretty.register_uri(httpretty.POST, context.good_build_url, status=204)
    from scripts.bitbucket import post_result, err
    result = post_result(context.good_build_url, d['source']['username'],
                         d['source']['password'], False, good_status_dict(),
                         True)
    assert result.status_code == 204
    context.goodresult = result
def step_impl(context):
    d = context.good_login
    assert context.good_login['source']['username'] == 'ValidUser'
    assert 'somethingicantaccess' not in context.good_build_url
    httpretty.enable()
    httpretty.register_uri(
            httpretty.POST,
            context.good_build_url,
            status=204
    )
    from scripts.bitbucket import post_result, err
    result = post_result(context.good_build_url, d['source']['username'], d['source']['password'], False, good_status_dict(), True)
    assert result.status_code == 204
    context.goodresult = result
def step_impl(context):
    d = context.good_login
    assert context.good_login['source']['username'] == 'ValidUser'
    httpretty.enable()
    httpretty.register_uri(
            httpretty.POST,
            context.bad_build_url,
            body='{"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}',
            status=403
    )
    from scripts.bitbucket import post_result, err
    result = post_result(context.bad_build_url, d['source']['username'], d['source']['password'], False, good_status_dict(), True)
    assert result.status_code == 403
    httpretty.disable()
    httpretty.reset()
def step_impl(context):
    d = context.bad_login
    assert d['source']['username'] != 'ValidUser'
    httpretty.enable()
    httpretty.register_uri(
            httpretty.POST,
            context.good_build_url,
            body='{"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]}',
            status=401
    )
    from scripts.bitbucket import post_result, err
    result = post_result(context.good_build_url, d['source']['username'], d['source']['password'], False, good_status_dict(), True)
    assert result.status_code == 401
    httpretty.disable()
    httpretty.reset()
def step_impl(context):
    d = context.good_login
    assert context.good_login['source']['username'] == 'ValidUser'
    httpretty.enable()
    httpretty.register_uri(
            httpretty.POST,
            context.bad_build_url,
            body='{"errors":[{"context":null,"message":"You are not permitted to access this resource","exceptionName":"com.atlassian.bitbucket.AuthorisationException"}]}',
            status=403
    )
    from scripts.bitbucket import post_result, print_error
    result = post_result(context.bad_build_url, d['source']['username'], d['source']['password'], False, good_status_dict(), True)
    assert result.status_code == 403
    httpretty.disable()
    httpretty.reset()
def step_impl(context):
    d = context.bad_login
    assert d['source']['username'] != 'ValidUser'
    httpretty.enable()
    httpretty.register_uri(
        httpretty.POST,
        context.good_build_url,
        body=
        '{"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]}',
        status=401)
    from scripts.bitbucket import post_result, err
    result = post_result(context.good_build_url, d['source']['username'],
                         d['source']['password'], False, good_status_dict(),
                         True)
    assert result.status_code == 401
    httpretty.disable()
    httpretty.reset()