コード例 #1
0
def test_cisco_stealthwatch_get_tag_command(requests_mock):
    from cisco_stealthwatch import Client, cisco_stealthwatch_get_tag_command
    mock_response = util_load_json('test_data/get_tag.json')
    requests_mock.post('https://token/v2/authenticate', cookies={'cookies': 'jar'})
    requests_mock.get('https://smc-configuration/rest/v1/tenants//tags/',
                      json=mock_response)
    client = Client(base_url='https://', auth=('', ''), verify=False, proxy=False)
    response = cisco_stealthwatch_get_tag_command(client, '', '')

    assert response.outputs_prefix == 'CiscoStealthwatch.Tag'
    assert response.outputs_key_field == 'id'
    assert response.outputs == response.raw_response.get('data')
コード例 #2
0
def test_cisco_stealthwatch_query_flows_initialize_command(requests_mock):
    from cisco_stealthwatch import Client, cisco_stealthwatch_query_flows_initialize_command
    mock_response = util_load_json('test_data/query_flow_initialize.json')
    requests_mock.post('https://token/v2/authenticate', cookies={'cookies': 'jar'})
    requests_mock.post('https://sw-reporting/v2/tenants//flows/queries', json=mock_response)
    client = Client(base_url='https://', auth=('', ''), verify=False, proxy=False)
    response = cisco_stealthwatch_query_flows_initialize_command(client, '', time_range='1 week')
    outputs = response.raw_response['data']['query']

    assert response.outputs_prefix == 'CiscoStealthwatch.FlowStatus'
    assert response.outputs_key_field == 'id'
    assert response.outputs == outputs
コード例 #3
0
def test_cisco_stealthwatch_list_tags_command(requests_mock):
    from cisco_stealthwatch import Client, cisco_stealthwatch_list_tags_command
    mock_response = util_load_json('test_data/list_tags.json')
    requests_mock.post('https://token/v2/authenticate', cookies={'cookies': 'jar'})
    requests_mock.get('https://sw-reporting/v1/tenants//internalHosts/tags',
                      json=mock_response)
    client = Client(base_url='https://', auth=('', ''), verify=False, proxy=False)
    response = cisco_stealthwatch_list_tags_command(client, '')

    assert response.outputs_prefix == 'CiscoStealthwatch.Tag'
    assert response.outputs_key_field == 'id'
    assert response.outputs[0].get('id') == 1
コード例 #4
0
def test_cisco_stealthwatch_query_flows_status_command(requests_mock):
    from cisco_stealthwatch import Client, cisco_stealthwatch_query_flows_status_command
    mock_response = util_load_json('test_data/query_flow_status.json')
    requests_mock.post('https://token/v2/authenticate', cookies={'cookies': 'jar'})
    requests_mock.get('https://sw-reporting/v2/tenants//flows/queries/602a96e7e4b0d6d2a200ea94',
                      json=mock_response)
    client = Client(base_url='https://', auth=('', ''), verify=False, proxy=False)
    response = cisco_stealthwatch_query_flows_status_command(client, '', '602a96e7e4b0d6d2a200ea94')

    assert response.outputs_prefix == 'CiscoStealthwatch.FlowStatus'
    assert response.outputs_key_field == 'id'
    assert response.outputs.get('id') == '602a96e7e4b0d6d2a200ea94'
コード例 #5
0
def test_cisco_stealthwatch_list_security_events_status_command(requests_mock):
    from cisco_stealthwatch import Client, cisco_stealthwatch_list_security_events_status_command
    mock_response = util_load_json('test_data/list_security_events_status.json')
    requests_mock.post('https://token/v2/authenticate', cookies={'cookies': 'jar'})
    requests_mock.get('https://sw-reporting/v1/tenants//security-events/queries/x',
                      json=mock_response)
    client = Client(base_url='https://', auth=('', ''), verify=False, proxy=False)
    response = cisco_stealthwatch_list_security_events_status_command(client, '', 'x')

    assert response.outputs_prefix == 'CiscoStealthwatch.SecurityEventStatus'
    assert response.outputs_key_field == 'id'
    assert response.outputs.get('id') == 'x'
コード例 #6
0
def test_cisco_stealthwatch_list_tenants_one_command(requests_mock):
    from cisco_stealthwatch import Client, cisco_stealthwatch_list_tenants_command
    mock_response = util_load_json('test_data/get_tenant.json')
    requests_mock.post('https://token/v2/authenticate', cookies={'cookies': 'jar'})
    requests_mock.get('https://sw-reporting/v1/tenants/x',
                      json=mock_response)
    client = Client(base_url='https://', auth=('', ''), verify=False, proxy=False)
    response = cisco_stealthwatch_list_tenants_command(client, 'x')

    assert response.outputs_prefix == 'CiscoStealthwatch.Tenant'
    assert response.outputs_key_field == 'id'
    assert response.outputs.get('id') == 102
    assert response.outputs.get('displayName') == 'companyname'
コード例 #7
0
def test_cisco_stealthwatch_get_tag_hourly_traffic_report_command(requests_mock):
    from cisco_stealthwatch import Client, cisco_stealthwatch_get_tag_hourly_traffic_report_command
    mock_response = util_load_json('test_data/get_tag_hourly_traffic_report.json')
    requests_mock.post('https://token/v2/authenticate', cookies={'cookies': 'jar'})
    requests_mock.get('https://sw-reporting/v1/tenants/x/internalHosts/tags/y/traffic/hourly',
                      json=mock_response)
    client = Client(base_url='https://', auth=('', ''), verify=False, proxy=False)
    response = cisco_stealthwatch_get_tag_hourly_traffic_report_command(client, 'x', 'y')

    assert response.outputs_prefix == 'CiscoStealthwatch.TagHourlyTraffic'
    assert response.outputs_key_field == ['tag_id', 'tenant_id', 'timestamp']
    assert response.outputs[0].get('tenant_id') == 'x'
    assert response.outputs[0].get('tag_id') == 'y'
コード例 #8
0
def test_cisco_stealthwatch_list_security_events_initialize_command(requests_mock):
    from cisco_stealthwatch import Client, \
        cisco_stealthwatch_list_security_events_initialize_command
    mock_response = util_load_json('test_data/list_security_events_initialize.json')
    requests_mock.post('https://token/v2/authenticate', cookies={'cookies': 'jar'})
    requests_mock.post('https://sw-reporting/v1/tenants/x/security-events/queries',
                       json=mock_response)
    client = Client(base_url='https://', auth=('', ''), verify=False, proxy=False)
    response = cisco_stealthwatch_list_security_events_initialize_command(client, 'x',
                                                                          time_range='1 day')

    assert response.outputs_prefix == 'CiscoStealthwatch.SecurityEventStatus'
    assert response.outputs_key_field == 'id'
    assert response.outputs.get('id') == '6029011fe4b0d6d2a1ffd2d7'
    assert response.outputs.get('searchJobStatus') == 'IN_PROGRESS'
    assert response.outputs.get('percentComplete') == 0