コード例 #1
0
ファイル: test_cli.py プロジェクト: jomarquez/poseidon
def test_get_role_confidence():
    endpoint = Endpoint('foo')
    endpoint.endpoint_data = {
        'tenant': 'foo',
        'mac': '00:00:00:00:00:00',
        'segment': 'foo',
        'port': '1'
    }
    endpoint.metadata = {'mac_addresses': {}}
    confidence = GetData._get_role_confidence(endpoint)
    assert confidence == NO_DATA
    endpoint.metadata = {
        'mac_addresses': {
            '00:00:00:00:00:00': {
                '1551711125': {
                    'confidences': [10.0]
                }
            }
        }
    }
    confidence = GetData._get_role_confidence(endpoint)
    assert confidence == '10.0'
コード例 #2
0
def test_get_behavior():
    endpoint = Endpoint('foo')
    endpoint.endpoint_data = {
        'tenant': 'foo',
        'mac': '00:00:00:00:00:00',
        'segment': 'foo',
        'port': '1'
    }
    endpoint.metadata = {'mac_addresses': {}}
    behavior = GetData._get_behavior(endpoint)
    assert behavior == 'NO DATA'
    endpoint.metadata = {
        'mac_addresses': {
            '00:00:00:00:00:00': {
                '1551711125': {
                    'behavior': 'abnormal'
                }
            }
        }
    }
    behavior = GetData._get_behavior(endpoint)
    assert behavior == 'abnormal'
コード例 #3
0
ファイル: test_cli.py プロジェクト: jomarquez/poseidon
def test_get_role():
    endpoint = Endpoint('foo')
    endpoint.endpoint_data = {
        'tenant': 'foo',
        'mac': '00:00:00:00:00:00',
        'segment': 'foo',
        'port': '1'
    }
    endpoint.metadata = {'mac_addresses': {}}
    role = GetData._get_role(endpoint)
    assert role == NO_DATA
    endpoint.metadata = {
        'mac_addresses': {
            '00:00:00:00:00:00': {
                '1551711125': {
                    'labels': ['foo']
                }
            }
        }
    }
    role = GetData._get_role(endpoint)
    assert role == 'foo'
コード例 #4
0
def test_show_endpoints():
    endpoint = Endpoint('foo')
    endpoint.endpoint_data = {
        'tenant': 'foo', 'mac': '00:00:00:00:00:00', 'segment': 'foo', 'port': '1', 'ipv4': '0.0.0.0', 'ipv6': '1212::1'}
    endpoint.metadata = {'mac_addresses': {'00:00:00:00:00:00': {'1551805502': {'labels': ['developer workstation'], 'behavior': 'normal'}}}, 'ipv4_addresses': {
        '0.0.0.0': {'os': 'windows'}}, 'ipv6_addresses': {'1212::1': {'os': 'windows'}}}
    s = SDNConnect()
    s.endpoints.append(endpoint)
    s.show_endpoints('all')
    s.show_endpoints('state active')
    s.show_endpoints('state ignored')
    s.show_endpoints('state unknown')
    s.show_endpoints('os windows')
    s.show_endpoints('role developer-workstation')
    s.show_endpoints('behavior normal')