def test_sc_containers_list(client):
    image = upload_image('test_sc_containers_list', 'test_sc_containers_list')
    containers = client.sc_containers_api.list()

    assert len(containers) > 0, u'Expected at least one image to exist.'
    assert isinstance(containers[0], ScContainer), u'The method returns container list.'

    match = [c for c in containers if image['name'].endswith(c.name) and c.digest == u'sha256:%s' % image['digest']]
    assert len(match) == 1, u'The test image exists.'
def test_sc_containers_delete(client):
    image = upload_image('test_sc_containers_delete', 'test_sc_containers_delete')

    response = client.sc_containers_api.delete(image['name'], image['digest'])

    assert response[u'status'] == u'deleted', u'The container was not deleted.'

    containers = client.sc_containers_api.list()
    match = [c for c in containers if image['name'].endswith(c.name) and c.digest == u'sha256:%s' % image['digest']]
    assert len(match) == 0, u'The image still exists.'
def test_sc_test_jobs_status(client):
    _ = upload_image('test_sc_test_jobs_status', 'test_sc_test_jobs_status')
    jobs = client.sc_test_jobs_api.list()
    assert len(jobs) > 0, u'At least one job exists.'
    test_job = client.sc_test_jobs_api.status(jobs[0].job_id)
    assert isinstance(test_job, ScTestJob), u'The method returns type.'
def test_sc_test_jobs_list(client):
    _ = upload_image('test_sc_test_jobs_list', 'test_sc_test_jobs_list')
    jobs = client.sc_test_jobs_api.list()
    assert len(jobs) > 0, u'At least one job exists.'
    assert isinstance(jobs[0], ScTestJob), u'The method returns job list.'
def test_sc_test_jobs_by_image_digest(client):
    image = upload_image('test_sc_test_jobs_by_image_digest',
                         'test_sc_test_jobs_by_image_digest')
    job = client.sc_test_jobs_api.by_image_digest(image['digest'])
    assert isinstance(job, ScTestJob), u'The method returns type.'
Exemplo n.º 6
0
def test_sc_policy_compliance(client):
    image = upload_image('test_sc_policy_compliance', 'test_sc_policy_compliance')
    policy = wait_until(lambda: client.sc_policy_api.compliance(image['id']),
                        lambda response: response[u'status'] != u'error')
    assert policy[u'status'] in [u'pass', u'fail'], \
        u'Status should be either pass or fail based on the policy'
def test_sc_reports_by_image_digest(client):
    image = upload_image('test_sc_reports_image_digest',
                         'test_sc_reports_image_digest')
    report = client.sc_reports_api.by_image_digest(image['digest'])
    assert isinstance(report, ScReport), u'The method returns type.'