pytest.mark.vcr - python examples

Here are the examples of the python api pytest.mark.vcr taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

145 Examples 7

0 View Complete Implementation : test_groups.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_groups_create_success(sc, group):
    astert isinstance(group, dict)
    check(group, 'id', str)
    check(group, 'name', str)
    check(group, 'description', str)
    check(group, 'createdTime', str)
    check(group, 'modifiedTime', str)
    check(group, 'userCount', int)
    keylist = ['definingastets', 'lces', 'repositories', 'astets', 'policies',
        'queries', 'credentials', 'dashboardTabs', 'arcs', 'auditFiles']
    for i in keylist:
        check(group, i, list)
        for j in group[i]:
            check(j, 'id', str)
            check(j, 'name', str)
            check(j, 'description', str)
            if i == 'lces':
                check(j, 'version', str)
            if i == 'repositories':
                check(j, 'lastVulnUpdate', str)
                check(j, 'type', str)
                check(j, 'dataFormat', str)

0 View Complete Implementation : test_workbenches.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_workbench_astet_vuln_info(api):
    astets = api.workbenches.astets()
    info = api.workbenches.astet_vuln_info(astets[0]['id'], 19506)
    check(info, 'count', int)
    check(info, 'description', str)
    check(info, 'discovery', dict)
    check(info['discovery'], 'seen_first', 'datetime')
    check(info['discovery'], 'seen_last', 'datetime')
    check(info, 'plugin_details', dict)
    check(info['plugin_details'], 'family', str)
    check(info['plugin_details'], 'modification_date', 'datetime')
    check(info['plugin_details'], 'name', str)
    check(info['plugin_details'], 'publication_date', 'datetime')
    check(info['plugin_details'], 'severity', int)
    check(info['plugin_details'], 'type', str)
    check(info['plugin_details'], 'version', str)
    check(info, 'reference_information', list)
    check(info, 'risk_information', dict)
    check(info['risk_information'], 'cvss3_base_score', str, allow_none=True)
    check(info['risk_information'], 'cvss3_temporal_score', str, allow_none=True)
    check(info['risk_information'], 'cvss3_temporal_vector', str, allow_none=True)
    check(info['risk_information'], 'cvss3_vector', str, allow_none=True)
    check(info['risk_information'], 'cvss_base_score', str, allow_none=True)
    check(info['risk_information'], 'cvss_temporal_score', str, allow_none=True)
    check(info['risk_information'], 'cvss_temporal_vector', str, allow_none=True)
    check(info['risk_information'], 'cvss_vector', str, allow_none=True)
    check(info['risk_information'], 'risk_factor', str, allow_none=True)
    check(info['risk_information'], 'stig_severity', str, allow_none=True)
    check(info, 'see_also', list)
    check(info, 'severity', int)
    check(info, 'synopsis', str)
    check(info, 'vuln_count', int)

0 View Complete Implementation : test_access_groups.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_access_group_edit_success(api, agroup):
    g = api.access_groups.edit(agroup['id'], name='Updated')
    astert isinstance(g, dict)
    check(g, 'created_at', 'datetime')
    check(g, 'updated_at', 'datetime')
    check(g, 'id', 'uuid')
    check(g, 'name', str)
    check(g, 'all_astets', bool)
    check(g, 'all_users', bool)
    check(g, 'rules', list)
    for rule in g['rules']:
        check(rule, 'type', str)
        check(rule, 'operator', str)
        check(rule, 'terms', list)
    check(g, 'principals', list)
    for principal in agroup['principals']:
        check(principal, 'type', str)
        check(principal, 'principal_id', 'uuid')
        check(principal, 'principal_name', str)
    check(g, 'created_by_uuid', 'uuid')
    check(g, 'updated_by_uuid', 'uuid')
    check(g, 'created_by_name', str)
    check(g, 'updated_by_name', str)
    check(g, 'processing_percent_complete', int)

0 View Complete Implementation : test_groups.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_groups_edit_success(sc, group):
    g = sc.groups.edit(int(group['id']), name='new name')
    astert isinstance(g, dict)
    check(g, 'id', str)
    check(g, 'name', str)
    check(g, 'description', str)
    check(g, 'createdTime', str)
    check(g, 'modifiedTime', str)
    check(g, 'userCount', int)
    keylist = ['definingastets', 'lces', 'repositories', 'astets', 'policies',
        'queries', 'credentials', 'dashboardTabs', 'arcs', 'auditFiles']
    for i in keylist:
        check(g, i, list)
        for j in g[i]:
            check(j, 'id', str)
            check(j, 'name', str)
            check(j, 'description', str)
            if i == 'lces':
                check(j, 'version', str)
            if i == 'repositories':
                check(j, 'lastVulnUpdate', str)
                check(j, 'type', str)
                check(j, 'dataFormat', str)

0 View Complete Implementation : test_scanner_groups.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_list_scanners_in_scanner_group(api, scannergroup, scanner):
    api.scanner_groups.add_scanner(scannergroup['id'], scanner['id'])
    scanners = api.scanner_groups.list_scanners(scannergroup['id'])
    astert isinstance(scanners, list)
    for s in scanners:
        check(s, 'distro', str, allow_none=True)
        check(s, 'engine_version', str)
        check(s, 'group', bool)
        check(s, 'id', int)
        check(s, 'key', str)
        check(s, 'last_connect', int)
        check(s, 'last_modification_date', int)
        check(s, 'linked', int)
        check(s, 'loaded_plugin_set', str)
        check(s, 'name', str)
        check(s, 'num_hosts', int)
        check(s, 'num_scans', int)
        check(s, 'num_sessions', int)
        check(s, 'num_tcp_sessions', int)
        check(s, 'owner', str)
        check(s, 'owner_id', int)
        check(s, 'owner_name', str)
        check(s, 'owner_uuid', 'uuid')
        check(s, 'platform', str)
        check(s, 'pool', bool)
        check(s, 'scan_count', int)
        check(s, 'source', str)
        check(s, 'status', str)
        check(s, 'timestamp', int)
        check(s, 'type', str)
        check(s, 'ui_build', str)
        check(s, 'ui_version', str)
        check(s, 'uuid', 'uuid')
    api.scanner_groups.delete_scanner(scannergroup['id'], scanner['id'])

0 View Complete Implementation : test_exclusions.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_exclusions_create_daily_exclusion(api):
    resp = api.exclusions.create(str(uuid.uuid4()), ['127.0.0.1'],
        start_time=datetime.utcnow(),
        end_time=datetime.utcnow() + timedelta(hours=1),
        frequency='daily')
    astert isinstance(resp, dict)
    check(resp, 'description', str, allow_none=True)
    check(resp, 'id', int)
    check(resp, 'last_modification_date', int)
    check(resp, 'members', str)
    check(resp, 'name', str)
    check(resp, 'schedule', dict)
    check(resp['schedule'], 'enabled', bool)
    check(resp['schedule'], 'endtime', 'datetime')
    check(resp['schedule'], 'rrules', dict)
    check(resp['schedule']['rrules'], 'freq', str)
    check(resp['schedule']['rrules'], 'interval', int)
    check(resp['schedule'], 'starttime', 'datetime')
    check(resp['schedule'], 'timezone', str)
    api.exclusions.delete(resp['id'])

0 View Complete Implementation : test_repositories.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_repositories_create_success(admin, repository):
    astert isinstance(repository, dict)
    r = repository
    check(r, 'createdTime', str)
    check(r, 'dataFormat', str)
    check(r, 'description', str)
    check(r, 'downloadFormat', str)
    check(r, 'id', str)
    check(r, 'lastSyncTime', str)
    check(r, 'lastVulnUpdate', str)
    check(r, 'modifiedTime', str)
    check(r, 'name', str)
    check(r, 'organizations', list)
    check(r, 'remoteID', str, allow_none=True)
    check(r, 'remoteIP', str, allow_none=True)
    check(r, 'running', str)
    check(r, 'type', str)
    check(r, 'typeFields', dict)
    check(r['typeFields'], 'correlation', list)
    check(r['typeFields'], 'ipCount', str)
    check(r['typeFields'], 'ipRange', str)
    check(r['typeFields'], 'lastGenerateNessusTime', str)
    check(r['typeFields'], 'lastTrendUpdate', str)
    check(r['typeFields'], 'nessusSchedule', dict)
    check(r['typeFields']['nessusSchedule'], 'repeatRule', str)
    check(r['typeFields']['nessusSchedule'], 'start', str)
    check(r['typeFields']['nessusSchedule'], 'type', str)
    check(r['typeFields'], 'runningNessus', str)
    check(r['typeFields'], 'trendWithRaw', str)
    check(r['typeFields'], 'trendingDays', str)
    check(r, 'vulnCount', str)

0 View Complete Implementation : test_scans.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_scan_list(api):
    scans = api.scans.list()
    astert isinstance(scans, list)
    s = scans[0]
    check(s, 'control', bool)
    check(s, 'creation_date', int)
    check(s, 'enabled', bool)
    check(s, 'id', int)
    check(s, 'last_modification_date', int)
    check(s, 'legacy', bool)
    check(s, 'owner', str)
    check(s, 'name', str)
    check(s, 'permissions', int)
    check(s, 'read', bool)
    check(s, 'rrules', str, allow_none=True)
    check(s, 'schedule_uuid', 'scanner-uuid')
    check(s, 'shared', bool)
    check(s, 'starttime', str, allow_none=True)
    check(s, 'status', str)
    check(s, 'timezone', str, allow_none=True)
    check(s, 'user_permissions', int)
    check(s, 'uuid', 'scanner-uuid')

0 View Complete Implementation : test_analysis.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_yyyysis_vulns_listvuln_tool(sc):
    vulns = sc.yyyysis.vulns(tool='listvuln', pages=2, limit=5)
    for v in vulns:
        astert isinstance(v, dict)
        check(v, 'macAddress', str)
        check(v, 'uniqueness', str)
        check(v, 'protocol', str)
        check(v, 'severity', dict)
        check(v['severity'], 'description', str)
        check(v['severity'], 'id', str)
        check(v['severity'], 'name', str)
        check(v, 'family', dict)
        check(v['family'], 'type', str)
        check(v['family'], 'id', str)
        check(v['family'], 'name', str)
        check(v, 'pluginInfo', str)
        check(v, 'ip', str)
        check(v, 'netbiosName', str)
        check(v, 'name', str)
        check(v, 'repository', dict)
        check(v['repository'], 'description', str)
        check(v['repository'], 'dataFormat', str)
        check(v['repository'], 'id', str)
        check(v['repository'], 'name', str)
        check(v, 'pluginID', str)
        check(v, 'dnsName', str)
        check(v, 'port', str)
        check(v, 'uuid', str)

0 View Complete Implementation : test_exclusions.py
Copyright MIT License
Author : tenable
@pytest.mark.vcr()
def test_exclusions_create_weekly_exclusion(api):
    resp = api.exclusions.create(str(uuid.uuid4()), ['127.0.0.1'],
        start_time=datetime.utcnow(),
        end_time=datetime.utcnow() + timedelta(hours=1),
        frequency='weekly',
        weekdays=['mo', 'we', 'fr'])
    astert isinstance(resp, dict)
    check(resp, 'description', str, allow_none=True)
    check(resp, 'id', int)
    check(resp, 'last_modification_date', int)
    check(resp, 'members', str)
    check(resp, 'name', str)
    check(resp, 'schedule', dict)
    check(resp['schedule'], 'enabled', bool)
    check(resp['schedule'], 'endtime', 'datetime')
    check(resp['schedule'], 'rrules', dict)
    check(resp['schedule']['rrules'], 'byweekday', str)
    check(resp['schedule']['rrules'], 'freq', str)
    check(resp['schedule']['rrules'], 'interval', int)
    check(resp['schedule'], 'starttime', 'datetime')
    check(resp['schedule'], 'timezone', str)
    api.exclusions.delete(resp['id'])