Example #1
0
def test_ssl_4550_error():
    result_string = '{"dnserr":"non-recoverable failure in name resolution","dst_name":"pretical.ee","dst_port":"443","from":"77.95.64.18","fw":4550,"msm_id":1006864,"msm_name":"SSLCert","prb_id":517,"timestamp":1380791230,"type":"sslcert"}'
    result = Result.get(result_string)
    assert(isinstance(result, SslResult))
    assert(result.af is None)
    assert(result.firmware == 4550)
    assert(result.destination_address is None)
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address is None)
    assert(result.port == 443)
    assert(result.origin == "77.95.64.18")
    assert(result.method is None)
    assert(result.version is None)
    assert(result.response_time is None)
    assert(result.time_to_connect is None)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 517)
    assert(result.created.isoformat() == "2013-10-03T09:07:10+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 0)
    assert(result.is_error is True)
    try:
        result = Result.get(result_string, on_error=Result.ACTION_FAIL)
        assert False
    except ResultError:
        pass
Example #2
0
def test_error_timeout():
    broken_result = {
        u'from': u'84.132.219.105',
        u'msm_id': 1666006,
        u'timestamp': 1400570732,
        u'fw': 4610,
        u'proto': u'UDP',
        u'af': 4,
        u'msm_name': u'Tdig',
        u'prb_id': 2960,
        u'error': {
            u'timeout': 5000
        },
        u'src_addr': u'192.168.179.20',
        u'group_id': 1666005,
        u'type': u'dns',
        u'dst_addr': u'194.0.25.16'
    }
    result = Result.get(broken_result)
    assert (result.is_error is True)
    try:
        result = Result.get(broken_result, on_error=Result.ACTION_FAIL)
        assert (False)
    except ResultError as e:
        assert (str(e) == "Timeout: 5000")
Example #3
0
def test_ssl_4550_error():
    result_string = '{"dnserr":"non-recoverable failure in name resolution","dst_name":"pretical.ee","dst_port":"443","from":"77.95.64.18","fw":4550,"msm_id":1006864,"msm_name":"SSLCert","prb_id":517,"timestamp":1380791230,"type":"sslcert"}'
    result = Result.get(result_string)
    assert(isinstance(result, SslResult))
    assert(result.af is None)
    assert(result.firmware == 4550)
    assert(result.destination_address is None)
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address is None)
    assert(result.port == 443)
    assert(result.origin == "77.95.64.18")
    assert(result.method is None)
    assert(result.version is None)
    assert(result.response_time is None)
    assert(result.time_to_connect is None)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 517)
    assert(result.created.isoformat() == "2013-10-03T09:07:10+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 0)
    assert(result.is_error is True)
    try:
        result = Result.get(result_string, on_error=Result.ERROR_FAIL)
        assert False
    except ResultParseError:
        pass
Example #4
0
 def __init__(self, *args, **kwargs):
     unittest.TestCase.__init__(self, *args, **kwargs)
     self.basic = Result.get(
         '{"af":4,"prb_id":1,"result":[{"rtt":10.001},{"rtt":10.002},{"rtt":10.003}],"ttl":20,"avg":10.002,"size":20,"from":"1.2.3.4","proto":"ICMP","timestamp":1440000000,"dup":0,"type":"ping","sent":3,"msm_id":1000001,"fw":4700,"max":10.003,"step":360,"src_addr":"2.3.4.5","rcvd":3,"msm_name":"Ping","lts":40,"dst_name":"my.name.ca","min":10.001,"dst_addr":"3.4.5.6"}'
     )
     self.no_packets = Result.get(
         '{"af":4,"prb_id":2,"result":[],"ttl":20,"avg":10.002,"size":20,"from":"1.2.3.4","proto":"ICMP","timestamp":1440000000,"dup":0,"type":"ping","sent":3,"msm_id":1000001,"fw":4700,"max":null,"step":360,"src_addr":"2.3.4.5","rcvd":0,"msm_name":"Ping","lts":40,"dst_name":"my.name.ca","min":null,"dst_addr":"3.4.5.6"}'
     )
Example #5
0
 def __init__(self, *args, **kwargs):
     unittest.TestCase.__init__(self, *args, **kwargs)
     self.basic = Result.get(
         '{"lts":64,"from":"217.13.64.36","msm_id":2841267,"fw":4720,"timestamp":1450185727,"uri":"http://at-vie-as1120.anchors.atlas.ripe.net:80/4096","prb_id":1,"result":[{"rt":45.953289,"src_addr":"217.13.64.36","hsize":131,"af":4,"bsize":1668618,"res":200,"method":"GET","ver":"1.1","dst_addr":"193.171.255.2"}],"group_id":2841267,"type":"http","msm_name":"HTTPGet"}'
     )
     self.multiple = Result.get(
         '{"lts":64,"from":"217.13.64.36","msm_id":2841267,"fw":4720,"timestamp":1450185727,"uri":"http://at-vie-as1120.anchors.atlas.ripe.net:80/4096","prb_id":1,"result":[{"rt":45.953289,"src_addr":"217.13.64.36","hsize":131,"af":4,"bsize":1668618,"res":200,"method":"GET","ver":"1.1","dst_addr":"193.171.255.2"},{"rt":45.953289,"src_addr":"217.13.64.36","hsize":131,"af":4,"bsize":1668618,"res":200,"method":"GET","ver":"1.1","dst_addr":"193.171.255.2"}],"group_id":2841267,"type":"http","msm_name":"HTTPGet"}'
     )
Example #6
0
def average_hope(list):
    hop_avg = []
    for k in list:
        if (Result.get(k).is_success):
            hop_avg.append(Result.get(k).total_hops)
    if (len(hop_avg) == 0):
        hop_avg.append(0)
    return mean(hop_avg)
Example #7
0
 def __init__(self, *args, **kwargs):
     unittest.TestCase.__init__(self, *args, **kwargs)
     self.basic = Result.get(
         '{"af":4,"prb_id":1,"result":[{"rtt":10.001},{"rtt":10.002},{"rtt":10.003}],"ttl":20,"avg":10.002,"size":20,"from":"1.2.3.4","proto":"ICMP","timestamp":1440000000,"dup":0,"type":"ping","sent":3,"msm_id":1000001,"fw":4700,"max":10.003,"step":360,"src_addr":"2.3.4.5","rcvd":3,"msm_name":"Ping","lts":40,"dst_name":"my.name.ca","min":10.001,"dst_addr":"3.4.5.6"}'
     )
     self.no_packets = Result.get(
         '{"af":4,"prb_id":2,"result":[],"ttl":20,"avg":10.002,"size":20,"from":"1.2.3.4","proto":"ICMP","timestamp":1440000000,"dup":0,"type":"ping","sent":3,"msm_id":1000001,"fw":4700,"max":null,"step":360,"src_addr":"2.3.4.5","rcvd":0,"msm_name":"Ping","lts":40,"dst_name":"my.name.ca","min":null,"dst_addr":"3.4.5.6"}'
     )
Example #8
0
def average_rtt(list):
    rtt_avg = []
    for k in list:
        if (Result.get(k).is_success):
            rtt_avg.append(Result.get(k).last_median_rtt)
    if (len(rtt_avg) == 0):
        rtt_avg.append(0)
    return mean(rtt_avg)
Example #9
0
def test_http_0_error():
    data = '{"fw":0,"msm_id":12023,"prb_id":1,"src_addr":"connect error 4","timestamp":1323118908,"type":"http"}'
    result = Result.get(data)
    assert (result.is_error is True)
    try:
        Result.get(data, on_error=Result.ERROR_FAIL)
        assert False
    except ResultParseError:
        pass
Example #10
0
def test_error_timeout():
    broken_result = {u'from': u'84.132.219.105', u'msm_id': 1666006, u'timestamp':1400570732, u'fw': 4610, u'proto': u'UDP', u'af': 4, u'msm_name':u'Tdig', u'prb_id': 2960, u'error': {u'timeout': 5000}, u'src_addr':u'192.168.179.20', u'group_id': 1666005, u'type': u'dns', u'dst_addr':u'194.0.25.16'}
    result = Result.get(broken_result)
    assert(result.is_error is True)
    try:
        result = Result.get(broken_result, on_error=Result.ACTION_FAIL)
        assert(False)
    except ResultError as e:
        assert(str(e) == "Timeout: 5000")
Example #11
0
def test_http_0():
    data = '{"fw":0,"msm_id":12023,"prb_id":1,"src_addr":"GET4 193.0.6.139 0.042268 200 263 1406","timestamp":1319704299,"type":"http"}'
    result = Result.get(data)
    assert result.is_malformed is True
    try:
        Result.get(data, on_malformation=Result.ACTION_FAIL)
        assert False
    except ResultParseError:
        pass
Example #12
0
def test_http_0_error():
    data = '{"fw":0,"msm_id":12023,"prb_id":1,"src_addr":"connect error 4","timestamp":1323118908,"type":"http"}'
    result = Result.get(data)
    assert(result.is_error is True)
    try:
        Result.get(data, on_error=Result.ERROR_FAIL)
        assert False
    except ResultParseError:
        pass
Example #13
0
def test_http_1_error():
    data = '{"fw":1,"msm_id":12023,"prb_id":1,"src_addr":"connect error 4","timestamp":1323118908,"type":"http"}'
    result = Result.get(data)
    assert(result.is_malformed is True)
    try:
        Result.get(data, on_malformation=Result.ACTION_FAIL)
        assert False
    except ResultParseError:
        pass
Example #14
0
def test_self_signed():
    ca_signed = Result.get(
        '{"lts":663,"rt":27.807,"from":"2001:67c:2e8:13:220:4aff:fec6:cc6e","dst_name":"2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ZXBvc2l0b3J5MA0GCSqGSIb3DQEBBQUAA4GB\\nAHbhEm5OSxYShjAGsoEIz\/AIx8dxfmbuwu3UOx\/\/8PDITtZDOLC5MH0Y0FWDomrL\\nNhGc6Ehmo21\/uBPUR\/6LWlxz\/K7ZGzIZOKuXNBSqltLroxwUCEm2u+WR74M26x1W\\nb8ravHNjkOR\/ez4iyz0H7V84dJzjA1BOoa+Y7mHyhD8S\\n-----END CERTIFICATE-----"],"dst_port":"443","ttc":11.956,"src_addr":"2001:67c:2e8:13:220:4aff:fec6:cc6e","group_id":1012449,"type":"sslcert","dst_addr":"2a00:1450:4005:809::1010","ver":"3.0","msm_id":1012449}'
    )
    self_signed = Result.get(
        '{"af":4,"cert":["-----BEGIN CERTIFICATE-----\\nMIIDEDCCAfgCCQCKlfFLvltvwjANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQGEwJI\\nVTEaMBgGA1UEAwwRa2FkYXJrYS5raXN0ZWwuaHUxHzAdBgkqhkiG9w0BCQEWEGtp\\nc3RlbEBraXN0ZWwuaHUwHhcNMTIxMDA0MDg1NTAzWhcNMjIxMDAyMDg1NTAzWjBK\\nMQswCQYDVQQGEwJIVTEaMBgGA1UEAwwRa2FkYXJrYS5raXN0ZWwuaHUxHzAdBgkq\\nhkiG9w0BCQEWEGtpc3RlbEBraXN0ZWwuaHUwggEiMA0GCSqGSIb3DQEBAQUAA4IB\\nDwAwggEKAoIBAQC7rhzio/gldiYiNjAANOgE6s1fns6BQ+yWvwXdEwm05+xwf+iD\\nP4LDzMrjsWDwyw61vdNr/HQ5nCnDvM+M3nRMX0NiOvvufm8X1js4SdrX2c+gSjkD\\n5z42gnGhgMYrcxsDPpJYwmeD3mWI/2a+BSviszWZUevMbAOMQLVLnnNR6mVUbanS\\nNXDQdT3As3yQx6J1OoLECDbuSms883dLqh2oi/C7U/DDzPBTn8rMZPzFw7SrehiM\\ntkvSn0Ge7ptRhBUYxGCObYVdakq+GU6giObsauz0FREMoef1YTlgnKHgkBjGJgQc\\nteiSFQzzP+TKfhY8qKI20AhmN4BP/TgbJcUDAgMBAAEwDQYJKoZIhvcNAQEFBQAD\\nggEBAG1szxqtff2XlRT7G5CMA5dH0o3hXUQQtRXQt3EeOzxcS0mQcLwN353uzCQp\\noOSXMF0ZD5kONZqkxZNYjwVWnyBH1d/A3bRvVNw9X038GecvzUX/VF8/PnzGYxyb\\ndPM3wCjRpaod2vpr/WwfOxWIG+Ie0u4Gzht/1UHEW1XGtOLJ8ee/SY95E/FXOTzc\\n9KtVC6lT8B+cpp3goEk4yGTdl3Uq6wnWrkK/OLg91x0/ZMK+0dIzuO1tFC5A5EH4\\ntZLxwscfsxFoV2geZGB21qKDcf1fKlBcsTIt9SiWg37rYSEmrc5hIkrQJ9mGM1+4\\nyruypEG+EAtzD9O3GrvNdgcZ0ps=\\n-----END CERTIFICATE-----"],"dst_addr":"85.10.198.82","dst_name":"85.10.198.82","dst_port":"443","from":"109.201.224.30","fw":4660,"group_id":1766133,"lts":178,"method":"SSL","msm_id":1766133,"msm_name":"SSLCert","prb_id":2965,"rt":3103.552,"src_addr":"10.119.35.124","timestamp":1410960180,"ttc":3046.154,"type":"sslcert","ver":"3.0"}'
    )
    assert (ca_signed.is_self_signed == False)
    assert (self_signed.is_self_signed == True)
Example #15
0
def test_http_0():
    data = '{"fw":0,"msm_id":12023,"prb_id":1,"src_addr":"GET4 193.0.6.139 0.042268 200 263 1406","timestamp":1319704299,"type":"http"}'
    result = Result.get(data)
    assert(result.is_error is True)
    try:
        Result.get(data, on_error=Result.ERROR_FAIL)
        assert False
    except ResultParseError:
        pass
Example #16
0
def test_http_1_error():
    data = '{"fw":1,"msm_id":12023,"prb_id":1,"src_addr":"connect error 4","timestamp":1323118908,"type":"http"}'
    result = Result.get(data)
    assert result.is_malformed is True
    try:
        Result.get(data, on_malformation=Result.ACTION_FAIL)
        assert False
    except ResultParseError:
        pass
Example #17
0
def test_http_0():
    data = '{"fw":0,"msm_id":12023,"prb_id":1,"src_addr":"GET4 193.0.6.139 0.042268 200 263 1406","timestamp":1319704299,"type":"http"}'
    result = Result.get(data)
    assert (result.is_error is True)
    try:
        Result.get(data, on_error=Result.ERROR_FAIL)
        assert False
    except ResultParseError:
        pass
Example #18
0
 def __init__(self, *args, **kwargs):
     unittest.TestCase.__init__(self, *args, **kwargs)
     self.basic = Result.get(
         '{"lts":92,"from":"195.113.83.16","msm_id":9211416,"fw":4790,"timestamp":1503927916,"resultset":[{"lts":92,"src_addr":"195.113.83.16","af":4,"submax":3,"proto":"UDP","subid":1,"result":{"abuf":"fViBgAABAAIAAgAEBTF4YmV0A2NvbQAAAQABwAwAAQABAAAAGQAEvmnCOsAMAAEAAQAAABkABL550oXADAACAAEAAVUJABUEZGFuYQJucwpjbG91ZGZsYXJlwBLADAACAAEAAVUJAAcEcGV0ZcBMwEcAAQABAAFVCQAErfU6acBHABwAAQABVQkAECQAywAgSQABAAAAAK31OmnAaAABAAEAAVUJAASt9TuIwGgAHAABAAFVCQAQJADLACBJAAEAAAAArfU7iA==","rt":6.45,"NSCOUNT":2,"QDCOUNT":1,"ANCOUNT":2,"ARCOUNT":4,"ID":32088,"size":199},"time":1503927916,"dst_addr":"195.113.83.55"},{"lts":93,"src_addr":"195.113.83.16","af":4,"submax":3,"proto":"UDP","subid":2,"result":{"abuf":"D/uBBQABAAAAAAAABTF4YmV0A2NvbQAAAQAB","rt":5.798,"NSCOUNT":0,"QDCOUNT":1,"ANCOUNT":0,"ARCOUNT":0,"ID":4091,"size":27},"time":1503927917,"dst_addr":"147.231.12.1"},{"lts":94,"src_addr":"2001:718:1e06::16","af":6,"submax":3,"proto":"UDP","subid":3,"result":{"abuf":"pqqBgAABAAIAAgAEBTF4YmV0A2NvbQAAAQABwAwAAQABAAAAFwAEvnnShcAMAAEAAQAAABcABL5pwjrADAACAAEAAVUHABUEcGV0ZQJucwpjbG91ZGZsYXJlwBLADAACAAEAAVUHAAcEZGFuYcBMwGgAAQABAAFVBwAErfU6acBoABwAAQABVQcAECQAywAgSQABAAAAAK31OmnARwABAAEAAVUHAASt9TuIwEcAHAABAAFVBwAQJADLACBJAAEAAAAArfU7iA==","rt":5.684,"NSCOUNT":2,"QDCOUNT":1,"ANCOUNT":2,"ARCOUNT":4,"ID":42666,"size":199},"time":1503927918,"dst_addr":"2001:718:1e06::55"}],"prb_id":4062,"group_id":9211416,"type":"dns","msm_name":"Tdig"}'
     )
     self.noerrornodata = Result.get(
         '{"lts":42,"from":"2001:718:1:a100::161:50","msm_id":9386425,"fw":4780,"proto":"UDP","af":6,"msm_name":"Tdig","prb_id":6068,"result":{"abuf":"8RCAgAABAAAAAQAACGlwdjRvbmx5BGFycGEAABwAAcAMAAYAAQAABikALQNzbnMDZG5zBWljYW5uA29yZwADbm9jwC94Ob7xAAAcIAAADhAACTqAAAAOEA==","rt":153.425,"NSCOUNT":1,"QDCOUNT":1,"ID":61712,"ARCOUNT":0,"ANCOUNT":0,"size":88},"timestamp":1506557387,"src_addr":"2001:718:1:a100::161:50","group_id":9386425,"type":"dns","dst_addr":"2001:4860:4860::6464"}'
     )
     self.noresponse = Result.get(
         '{"lts":11,"from":"2a01:538:1:f000:fa1a:67ff:fe4d:7f1d","msm_id":9386425,"fw":4780,"timestamp":1506681497,"proto":"UDP","msm_name":"Tdig","prb_id":11879,"af":6,"error":{"timeout":5000},"src_addr":"2a01:538:1:f000:fa1a:67ff:fe4d:7f1d","group_id":9386425,"type":"dns","dst_addr":"2001:4860:4860::6464"}'
     )
     self.noabuf = Result.get(
         '{"lts":27,"from":"80.92.240.37","msm_id":9211416,"fw":4780,"timestamp":1503927938,"resultset":[{"lts":27,"src_addr":"192.168.254.254","af":4,"submax":2,"proto":"UDP","subid":1,"time":1503927938,"error":{"timeout":5000},"dst_addr":"80.92.240.6"}],"prb_id":30410,"group_id":9211416,"type":"dns","msm_name":"Tdig"}'
     )
Example #19
0
def print_traceroute(rr):
    result = Result.get(rr)
    print(isinstance(result, TracerouteResult))
    print(result.af)
    print(result.destination_address)
    print(result.destination_name)
    print(result.end_time.isoformat())
    print(result.origin)
    print(result.firmware)
    print(result.measurement_id)
    print(result.probe_id)
    print(result.paris_id)
    print(result.protocol)
    print(result.total_hops)
    print(result.last_median_rtt)
    print(result.ip_path[3][1])
    print(result.hops[0].packets[0].destination_option_size)
    print(result.hops[0].packets[0].hop_by_hop_option_size)
    print(result.hops[0].packets[0].mtu)
    print(result.hops[3].index)
    print(result.hops[3].packets[0].origin)
    print(result.hops[3].packets[1].rtt)
    print(result.hops[3].packets[1].size)
    print(result.hops[3].packets[2].ttl)
    print(result.hops[-1].index)
    print(
        "============================================================================"
    )
Example #20
0
def test_ntp_timeout():
    result = (
        '{ "msm_id":"1020235", "fw":4661, "lts":76, "timestamp":1418196642, "dst_name":"atlas", '
        '"prb_id":71, "dst_addr":"193.0.6.139", "src_addr":"193.0.10.127", "proto":"UDP", "af": 4,'
        '"from": "193.0.0.78", "type": "ntp", "result": '
        '[ { "x":"*" }, { "x":"*" }, { "x":"*" } ] '
        "}"
    )
    result = Result.get(result)
    assert isinstance(result, NtpResult)
    assert result.af == 4
    assert result.firmware == 4661
    assert result.destination_address == "193.0.6.139"
    assert result.destination_name == "atlas"
    assert result.source_address == "193.0.10.127"
    assert result.origin == "193.0.0.78"
    assert result.leap_second_indicator is None
    assert result.stratum is None
    assert result.rtt_median is None
    assert result.offset_median is None
    assert getattr(result.packets[0], "final_timestamp", None) is None
    assert getattr(result.packets[0], "final_times", None) is None
    assert getattr(result.packets[0], "origin_timestamp", None) is None
    assert getattr(result.packets[0], "origin_time", None) is None
    assert getattr(result.packets[0], "transmitted_timestamp", None) is None
    assert getattr(result.packets[0], "transmitted_time", None) is None
    assert getattr(result.packets[0], "received_timestamp", None) is None
    assert getattr(result.packets[0], "received_time", None) is None
    assert result.packets[0].offset is None
    assert result.packets[0].rtt is None
Example #21
0
def test_ping_buggy():
    result = Result.get(
        '{"af":4,"avg":-1,"dst_addr":"62.2.16.24","dst_name":"hsi.cablecom.ch","dup":2,"from":"62.195.143.53","fw":4600,"lts":130,"max":-1,"min":-1,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":0,"result":[{"srcaddr":"192.168.1.229","x":"*"},{"dup":1,"rtt":1635.423,"ttl":55},{"dup":1,"rtt":1800.4939999999999}],"sent":1,"size":12,"src_addr":"192.168.1.229","step":360,"timestamp":1394745831,"ttl":55,"type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average is None)
    assert (result.rtt_median is None)
    assert (result.destination_address == "62.2.16.24")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 2)
    assert (result.origin == "62.195.143.53")
    assert (result.firmware == 4600)
    assert (result.seconds_since_sync == 130)
    assert (result.rtt_max is None)
    assert (result.rtt_min is None)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 202)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 0)
    assert (result.packets_sent == 1)
    assert (result.packet_size == 12)
    assert (result.step == 360)
    assert (result.created.isoformat() == "2014-03-13T21:23:51+00:00")
    assert (result.packets[0].rtt is None)
    assert (result.packets[1].rtt == 1635.423)
    assert (result.packets[2].rtt == 1800.494)
    assert (result.packets[0].ttl is None)
    assert (result.packets[1].ttl == 55)
    assert (result.packets[2].ttl == 55)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is True)
    assert (result.packets[2].dup is True)
    assert (result.packets[0].source_address == "192.168.1.229")
    assert (result.packets[1].source_address == "192.168.1.229")
    assert (result.packets[2].source_address == "192.168.1.229")
Example #22
0
def test_ping_4470():
    result = Result.get(
        '{"addr":"62.2.16.12","af":4,"avg":195.649,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"194.85.27.7","fw":4470,"max":197.79300000000001,"min":193.059,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"proto":"ICMP","rcvd":3,"result":[{"rtt":196.095},{"rtt":197.79300000000001},{"rtt":193.059}],"sent":3,"size":20,"src_addr":"192.168.3.8","timestamp":1344514151,"ttl":46,"type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average == 195.649)
    assert (result.rtt_median == 196.095)
    assert (result.destination_address == "62.2.16.12")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 0)
    assert (result.origin == "194.85.27.7")
    assert (result.firmware == 4470)
    assert (result.seconds_since_sync is None)
    assert (result.rtt_max == 197.793)
    assert (result.rtt_min == 193.059)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 165)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 3)
    assert (result.packets_sent == 3)
    assert (result.packet_size == 12)
    assert (result.step is None)
    assert (result.created.isoformat() == "2012-08-09T12:09:11+00:00")
    assert (result.packets[0].rtt == 196.095)
    assert (result.packets[1].rtt == 197.793)
    assert (result.packets[2].rtt == 193.059)
    assert (result.packets[0].ttl == 46)
    assert (result.packets[1].ttl == 46)
    assert (result.packets[2].ttl == 46)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is False)
    assert (result.packets[2].dup is False)
    assert (result.packets[0].source_address == "192.168.3.8")
    assert (result.packets[1].source_address == "192.168.3.8")
    assert (result.packets[2].source_address == "192.168.3.8")
Example #23
0
def test_ping_4600():
    result = Result.get('{"af":4,"avg":47.951999999999998,"dst_addr":"62.2.16.24","dst_name":"hsi.cablecom.ch","dup":0,"from":"188.195.183.141","fw":4600,"group_id":1000192,"lts":222,"max":48.990000000000002,"min":45.939,"msm_id":1000192,"msm_name":"Ping","prb_id":270,"proto":"ICMP","rcvd":3,"result":[{"rtt":45.939},{"rtt":48.927},{"rtt":48.990000000000002}],"sent":3,"size":12,"src_addr":"192.168.178.21","step":360,"timestamp":1392321470,"ttl":50,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 47.952)
    assert(result.rtt_median == 48.927)
    assert(result.destination_address == "62.2.16.24")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "188.195.183.141")
    assert(result.firmware == 4600)
    assert(result.seconds_since_sync == 222)
    assert(result.rtt_max == 48.99)
    assert(result.rtt_min == 45.939)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 270)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2014-02-13T19:57:50+00:00")
    assert(result.packets[0].rtt == 45.939)
    assert(result.packets[1].rtt == 48.927)
    assert(result.packets[2].rtt == 48.99)
    assert(result.packets[0].ttl == 50)
    assert(result.packets[1].ttl == 50)
    assert(result.packets[2].ttl == 50)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.178.21")
    assert(result.packets[1].source_address == "192.168.178.21")
    assert(result.packets[2].source_address == "192.168.178.21")
Example #24
0
def test_ping_4570():
    result = Result.get(
        '{"af":4,"avg":36.608333333333327,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"62.195.143.53","fw":4570,"lts":-1,"max":36.741,"min":36.423999999999999,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":3,"result":[{"rtt":36.741},{"rtt":36.659999999999997},{"rtt":36.423999999999999}],"sent":3,"size":12,"step":360,"timestamp":1384500425, "type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average == 36.608)
    assert (result.rtt_median == 36.66)
    assert (result.destination_address == "62.2.16.12")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 0)
    assert (result.origin == "62.195.143.53")
    assert (result.firmware == 4570)
    assert (result.seconds_since_sync is None)
    assert (result.rtt_max == 36.741)
    assert (result.rtt_min == 36.424)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 202)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 3)
    assert (result.packets_sent == 3)
    assert (result.packet_size == 12)
    assert (result.step == 360)
    assert (result.created.isoformat() == "2013-11-15T07:27:05+00:00")
    assert (result.packets[0].rtt == 36.741)
    assert (result.packets[1].rtt == 36.66)
    assert (result.packets[2].rtt == 36.424)
    assert (result.packets[0].ttl is None)
    assert (result.packets[1].ttl is None)
    assert (result.packets[2].ttl is None)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is False)
    assert (result.packets[2].dup is False)
    assert (result.packets[0].source_address is None)
    assert (result.packets[1].source_address is None)
    assert (result.packets[2].source_address is None)
Example #25
0
def test_ssl_4520():
    result = Result.get('{"af":4,"cert":["-----BEGIN CERTIFICATE-----\nMIIEzjCCAragAwIBAgIDDXW/MA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv\nb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ\nQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y\ndEBjYWNlcnQub3JnMB4XDTEzMDcwNjA1NTQ1NFoXDTE0MDEwMjA1NTQ1NFowGDEW\nMBQGA1UEAxQNKi5wcmV0aWNhbC5lZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC\nAQoCggEBAMS+vX7gA8TvzFwxryFFRj1OyQjnW88GvfMuGhKJopalG1EB103oRsxi\nMcXqwFZUicpqLKHW4lCHcRuhpKoZp8EOILnRAJRKFOjgIrcHQ02Xn4Lf/ewl601h\n5qxqt1keU1P8j+u9m7zZN+vOoNlEKZ5SnZhysAAYqr/XIt1WY2cji/4GxjF+q1OH\nIl5zddkIfnE52UbREKKlIakfFdj/c6GXqqsP2QTmm4x2HitCD964tZ06fA9BitQj\nnnBXNhtm2MCuBIPBSq0/C7LREwmfnqxCFqE7iqEPNIQ2IT2D4Gh4c+nIZHqYKvCV\nP3zh3aUaBj1o5Lo83IDdXCKAIiQRFMkCAwEAAaO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.18","fw":4520,"method":"SSL","msm_id":1006864,"msm_name":"SSLCert","prb_id":517,"src_addr":"77.95.64.18","timestamp":1378499876,"type":"sslcert","ver":"3.0"}')
    assert(isinstance(result, SslResult))
    assert(result.af == 4)
    assert(result.firmware == 4520)
    assert(result.destination_address == "80.79.115.54")
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address == "77.95.64.18")
    assert(result.port == 443)
    assert(result.origin == "77.95.64.18")
    assert(result.method == "SSL")
    assert(result.version == "3.0")
    assert(result.response_time is None)
    assert(result.time_to_connect is None)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 517)
    assert(result.created.isoformat() == "2013-09-06T20:37:56+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 1)
    assert(result.certificates[0])
    assert(result.certificates[0].subject_cn == "*.pretical.ee")
    assert(result.certificates[0].subject_o is None)
    assert(result.certificates[0].subject_c is None)
    assert(result.certificates[0].issuer_cn == "CA Cert Signing Authority")
    assert(result.certificates[0].issuer_o == "Root CA")
    assert(result.certificates[0].issuer_c is None)
    assert(result.certificates[0].valid_from.isoformat() == "2013-07-06T05:54:54+00:00")
    assert(result.certificates[0].valid_until.isoformat() == "2014-01-02T05:54:54+00:00")
    assert(result.certificates[0].checksum == "F9:C1:DC:CE:CE:C2:E8:42:00:D1:A1:B5:0D:93:09:DE:73:DA:CE:56:0A:FD:A3:BB:B1:CC:1E:2E:47:15:C3:A6")
    assert(result.certificates[0].checksum_md5 == "38:07:D1:3C:0C:79:01:5E:F6:0E:6B:48:B4:3C:F4:59")
    assert(result.certificates[0].checksum_sha1 == "C5:31:2B:AC:B2:4F:D2:F8:47:57:2A:4F:04:D7:F9:18:91:20:C7:1F")
    assert(result.certificates[0].checksum_sha256 == "F9:C1:DC:CE:CE:C2:E8:42:00:D1:A1:B5:0D:93:09:DE:73:DA:CE:56:0A:FD:A3:BB:B1:CC:1E:2E:47:15:C3:A6")
Example #26
0
def test_ssl_4500():
    result = Result.get('{"af":4,"cert":["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aWNhbC5lZTANBgkqhkiG9w0B\nAQUFAAOCAgEAycddS/c47eo0WVrFxpvCIJdfvn7CYdTPpXNSg0kjapkSjYuAkcmq\nsrScUUGMBe6tfkmkdPTuNKwRVYNJ1Wi9EYaMvJ3CVw6x9O5mgktmu0ogbIXsivwI\nTSzGDMWcb9Of85e/ALWpK0cWIugtWO0d6v3qMWfxlYfAaYu49pttOJQOjbXAAhfR\njE5VOcDaIlWChG48jLAyCLsMwHlyLw8D5Myb9MfTs1XxgLESO9ZTSqGEqJw+BwTJ\nstHk/oCHo9FL/Xv5MmFcNaTpqbB60duYJ+DLLX1QiRRfLJ18G7wEiEAm6H9egupQ\nL9MhQQLJ4o60xTrCnpqGTXTSR16jiTm70bDB0+SU3xTpNwCzdigH6ceKbPIr0cO6\no0ump598e2JNCPsXIc+XcbLDDFgYrlnl3YnK3J+K3LC7SWPMsYdDfe+Im880tNuW\nOlnOCDpP8408KqCp4xm0DMznmThUM34/Ia+o8Q3NWNBfuaOsJ9aA+FmgobJhih9e\nUr9x3ByRQXcW5Cs/AMtCikKWVPsx+IA5eeyt+1i+dKBWksO40B3ADsq1O5DRYYRa\n+dwqdX/jduqZjbyHuFH04q28j4zVDviUBQEa9UQoDM3c82dILDjbYtZ+T28sPMTa\nbMZdcMur9E+ovrS58lIKGCvDEPSUDXHzr0tpb4A13TTnxW6pclqUyJk=\n-----END CERTIFICATE-----"],"dst_addr":"80.79.115.54","dst_name":"pretical.ee","dst_port":"https","from":"77.95.64.18","fw":4500,"method":"SSL","msm_id":1006864,"prb_id":517,"src_addr":"77.95.64.18","timestamp":1365577623,"type":"sslcert","ver":"3.0"}')
    assert(isinstance(result, SslResult))
    assert(result.af == 4)
    assert(result.firmware == 4500)
    assert(result.destination_address == "80.79.115.54")
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address == "77.95.64.18")
    assert(result.port == 443)
    assert(result.origin == "77.95.64.18")
    assert(result.method == "SSL")
    assert(result.version == "3.0")
    assert(result.response_time is None)
    assert(result.time_to_connect is None)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 517)
    assert(result.created.isoformat() == "2013-04-10T07:07:03+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 1)
    assert(result.certificates[0])
    assert(result.certificates[0].subject_cn == "*.pretical.ee")
    assert(result.certificates[0].subject_o is None)
    assert(result.certificates[0].subject_c is None)
    assert(result.certificates[0].issuer_cn == "CA Cert Signing Authority")
    assert(result.certificates[0].issuer_o == "Root CA")
    assert(result.certificates[0].issuer_c is None)
    assert(result.certificates[0].valid_from.isoformat() == "2013-01-06T14:00:55+00:00")
    assert(result.certificates[0].valid_until.isoformat() == "2013-07-05T14:00:55+00:00")
    assert(result.certificates[0].checksum == "AC:D1:6F:FB:3A:F2:06:C9:92:A4:4D:2A:A2:0B:1C:37:35:25:75:A7:5D:4A:62:21:03:AD:E6:46:42:E5:65:4C")
    assert(result.certificates[0].checksum_md5 == "91:EA:DF:FF:57:6F:7C:91:F1:83:2A:9F:7F:A2:FE:E4")
    assert(result.certificates[0].checksum_sha1 == "11:00:27:07:F7:E8:0C:6B:5F:B6:A3:5A:20:19:BC:CA:22:85:E5:3C")
    assert(result.certificates[0].checksum_sha256 == "AC:D1:6F:FB:3A:F2:06:C9:92:A4:4D:2A:A2:0B:1C:37:35:25:75:A7:5D:4A:62:21:03:AD:E6:46:42:E5:65:4C")
Example #27
0
def test_ping_4550():
    result = Result.get('{"af":4,"avg":27.300999999999998,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"80.56.151.3","fw":4550,"lts":365,"max":27.300999999999998,"min":27.300999999999998,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":1,"result":[{"srcaddr":"192.168.1.229","x":"*"},{"x":"*"},{"rtt":27.300999999999998,"ttl":54}],"sent":3,"size":20,"src_addr":"192.168.1.229","step":360,"timestamp":1378271710,"ttl":54,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 27.301)
    assert(result.rtt_median == 27.301)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "80.56.151.3")
    assert(result.firmware == 4550)
    assert(result.seconds_since_sync == 365)
    assert(result.rtt_max == 27.301)
    assert(result.rtt_min == 27.301)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 1)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2013-09-04T05:15:10+00:00")
    assert(result.packets[0].rtt is None)
    assert(result.packets[1].rtt is None)
    assert(result.packets[2].rtt == 27.301)
    assert(result.packets[0].ttl is None)
    assert(result.packets[1].ttl is None)
    assert(result.packets[2].ttl == 54)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.1.229")
    assert(result.packets[1].source_address == "192.168.1.229")
    assert(result.packets[2].source_address == "192.168.1.229")
Example #28
0
def test_ping_4520():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":67.420999999999992,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"194.85.27.7","fw":4520,"max":70.230999999999995,"min":65.974999999999994,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"proto":"ICMP","rcvd":3,"result":[{"rtt":70.230999999999995},{"rtt":65.974999999999994},{"rtt":66.057000000000002}],"sent":3,"size":20,"src_addr":"192.168.3.8","timestamp":1365379380,"ttl":47,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 67.421)
    assert(result.rtt_median == 66.057)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "194.85.27.7")
    assert(result.firmware == 4520)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 70.231)
    assert(result.rtt_min == 65.975)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 165)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2013-04-08T00:03:00+00:00")
    assert(result.packets[0].rtt == 70.231)
    assert(result.packets[1].rtt == 65.975)
    assert(result.packets[2].rtt == 66.057)
    assert(result.packets[0].ttl == 47)
    assert(result.packets[1].ttl == 47)
    assert(result.packets[2].ttl == 47)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.3.8")
    assert(result.packets[1].source_address == "192.168.3.8")
    assert(result.packets[2].source_address == "192.168.3.8")
Example #29
0
def test_ping_4560():
    result = Result.get('{"af":4,"avg":36.887,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"62.195.143.53","fw":4560,"lts":36,"max":40.234000000000002,"min":34.747999999999998,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":3,"result":[{"rtt":40.234000000000002},{"rtt":34.747999999999998,"srcaddr":"192.168.1.229"},{"rtt":35.679000000000002,"srcaddr":"192.168.1.229"}],"sent":3,"size":20,"src_addr":"192.168.1.229","step":360,"timestamp":1380586151,"ttl":54,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 36.887)
    assert(result.rtt_median == 35.679)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "62.195.143.53")
    assert(result.firmware == 4560)
    assert(result.seconds_since_sync is 36)
    assert(result.rtt_max == 40.234)
    assert(result.rtt_min == 34.748)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2013-10-01T00:09:11+00:00")
    assert(result.packets[0].rtt == 40.234)
    assert(result.packets[1].rtt == 34.748)
    assert(result.packets[2].rtt == 35.679)
    assert(result.packets[0].ttl == 54)
    assert(result.packets[1].ttl == 54)
    assert(result.packets[2].ttl == 54)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.1.229")
    assert(result.packets[1].source_address == "192.168.1.229")
    assert(result.packets[2].source_address == "192.168.1.229")
Example #30
0
def test_ping_4460():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":48.388333333333328,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"188.194.234.136","fw":4460,"max":56.948999999999998,"min":43.869999999999997,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":270,"proto":"ICMP","rcvd":3,"result":[{"rtt":43.869999999999997},{"rtt":56.948999999999998},{"rtt":44.345999999999997}],"sent":3,"size":20,"src_addr":"192.168.178.21","timestamp":1340524626,"ttl":52,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 48.388)
    assert(result.rtt_median == 44.346)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "188.194.234.136")
    assert(result.firmware == 4460)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 56.949)
    assert(result.rtt_min == 43.87)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 270)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2012-06-24T07:57:06+00:00")
    assert(result.packets[0].rtt == 43.87)
    assert(result.packets[1].rtt == 56.949)
    assert(result.packets[2].rtt == 44.346)
    assert(result.packets[0].ttl == 52)
    assert(result.packets[1].ttl == 52)
    assert(result.packets[2].ttl == 52)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.178.21")
    assert(result.packets[1].source_address == "192.168.178.21")
    assert(result.packets[2].source_address == "192.168.178.21")
Example #31
0
def test_ping_buggy():
    result = Result.get('{"af":4,"avg":-1,"dst_addr":"62.2.16.24","dst_name":"hsi.cablecom.ch","dup":2,"from":"62.195.143.53","fw":4600,"lts":130,"max":-1,"min":-1,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":0,"result":[{"srcaddr":"192.168.1.229","x":"*"},{"dup":1,"rtt":1635.423,"ttl":55},{"dup":1,"rtt":1800.4939999999999}],"sent":1,"size":12,"src_addr":"192.168.1.229","step":360,"timestamp":1394745831,"ttl":55,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average is None)
    assert(result.rtt_median is None)
    assert(result.destination_address == "62.2.16.24")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 2)
    assert(result.origin == "62.195.143.53")
    assert(result.firmware == 4600)
    assert(result.seconds_since_sync == 130)
    assert(result.rtt_max is None)
    assert(result.rtt_min is None)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 0)
    assert(result.packets_sent == 1)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    print(result.created, type(result.created))
    print(result.created.isoformat())
    assert(result.created.isoformat() == "2014-03-13T21:23:51+00:00")
    assert(result.packets[0].rtt is None)
    assert(result.packets[1].rtt == 1635.423)
    assert(result.packets[2].rtt == 1800.494)
    assert(result.packets[0].ttl is None)
    assert(result.packets[1].ttl == 55)
    assert(result.packets[2].ttl == 55)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is True)
    assert(result.packets[2].dup is True)
    assert(result.packets[0].source_address == "192.168.1.229")
    assert(result.packets[1].source_address == "192.168.1.229")
    assert(result.packets[2].source_address == "192.168.1.229")
    def __iter__(self):

        sagans = []

        for line in self._iterable:

            # line may be a dictionary (parsed JSON)
            if hasattr(line, "strip"):
                line = line.strip()

            # Break out when there's nothing left
            if not line:
                break

            try:
                sagan = SaganResult.get(
                    line,
                    on_error=SaganResult.ACTION_IGNORE,
                    on_warning=SaganResult.ACTION_IGNORE
                )
                if not self._probes or sagan.probe_id in self._probes:
                    sagans.append(sagan)
                if len(sagans) > 100:
                    for sagan in self._attach_probes(sagans):
                        yield sagan
                    sagans = []
            except ResultParseError:
                pass  # Probably garbage in the file

        for sagan in self._attach_probes(sagans):
            yield sagan
Example #33
0
def test_ping_4500():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":30.114666666666665,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"80.56.151.3","fw":4500,"max":30.344999999999999,"min":29.960999999999999,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":202,"proto":"ICMP","rcvd":3,"result":[{"rtt":30.038},{"rtt":29.960999999999999},{"rtt":30.344999999999999}],"sent":3,"size":20,"src_addr":"192.168.1.229","timestamp":1361244431,"ttl":55,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 30.115)
    assert(result.rtt_median == 30.038)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "80.56.151.3")
    assert(result.firmware == 4500)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 30.345)
    assert(result.rtt_min == 29.961)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2013-02-19T03:27:11+00:00")
    assert(result.packets[0].rtt == 30.038)
    assert(result.packets[1].rtt == 29.961)
    assert(result.packets[2].rtt == 30.345)
    assert(result.packets[0].ttl == 55)
    assert(result.packets[1].ttl == 55)
    assert(result.packets[2].ttl == 55)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.1.229")
    assert(result.packets[1].source_address == "192.168.1.229")
    assert(result.packets[2].source_address == "192.168.1.229")
    def __call__(self, key, value):
        while type(value) == str or type(value) == unicode:
            value = json.load(value)

	parsed_result = Result.get(value)

        ipStr = parsed_result.origin

        gir = self.geo.record_by_addr(ipStr)
        if gir is None:
            value["geo"] = {}
            yield key, value
            return

        d = {}

        fields = ["country_code", "country_name", "region", "region_name",
                "city", "postal_code", "latitude", "longitude", "area_code",
                "time_zone", "metro_code"]

        saved_fields = ["cc", "country", "st", "state", "city", "postcode",
                "lat", "lng", "areacode", "tz", "metrocode"]

        for field, save_as in zip(fields, saved_fields):
            val = gir[field]
            if val is None: continue
            d[save_as] = val

        value["geo"] = d

        yield key, value
Example #35
0
def test_http_4610_fail():
    result = Result.get(
        '{"from":"2001:630:301:1080:220:4aff:fee0:20a0","fw":4610,"msm_id":1003932,"msm_name":"HTTPGet","prb_id":2493,"result":[{"af":6,"dst_addr":"2001:42d0:0:200::6","err":"timeout reading chunk","method":"GET","src_addr":"2001:630:301:1080:220:4aff:fee0:20a0"}],"timestamp":1398184661,"type":"http","uri":"http://www.afrinic.net/"}'
    )
    assert (isinstance(result, HttpResult))
    assert (result.origin == "2001:630:301:1080:220:4aff:fee0:20a0")
    assert (result.firmware == 4610)
    assert (result.measurement_id == 1003932)
    assert (result.probe_id == 2493)
    assert (result.created.isoformat() == "2014-04-22T16:37:41+00:00")
    assert (result.uri == "http://www.afrinic.net/")
    assert (result.method == HttpResult.METHOD_GET)
    assert (isinstance(result.responses, list))
    assert (len(result.responses) == 1)
    assert (result.responses[0].af == 6)
    assert (result.responses[0].body_size is None)
    assert (result.responses[0].head_size is None)
    assert (result.responses[0].destination_address == "2001:42d0:0:200::6")
    assert (result.responses[0].code is None)
    assert (result.responses[0].response_time is None)
    assert (result.responses[0].source_address ==
            "2001:630:301:1080:220:4aff:fee0:20a0")
    assert (result.responses[0].version is None)
    assert (result.responses[0].is_error is True)
    assert (result.responses[0].error_string == "timeout reading chunk")
Example #36
0
    def __iter__(self):

        sagans = []

        for line in self._iterable:

            # line may be a dictionary (parsed JSON)
            if hasattr(line, "strip"):
                line = line.strip()

            # Break out when there's nothing left
            if not line:
                break

            try:
                sagan = SaganResult.get(line,
                                        on_error=SaganResult.ACTION_IGNORE,
                                        on_warning=SaganResult.ACTION_IGNORE)
                if not self._probes or sagan.probe_id in self._probes:
                    sagans.append(sagan)
                if len(sagans) > 100:
                    for sagan in self._attach_probes(sagans):
                        yield sagan
                    sagans = []
            except ResultParseError:
                pass  # Probably garbage in the file

        for sagan in self._attach_probes(sagans):
            yield sagan
Example #37
0
def test_wifi_error():
    raw_data = {
        "bundle": 1463493022,
        "error": "wpa timeout",
        "from": "2001:67c:2e8:ffe1:eade:27ff:fe69:e6f0",
        "fw": "4733",
        "group_id": 1021275,
        "msm_id": 1021275,
        "msm_name": "WiFi",
        "prb_id": 105,
        "timestamp": 1463493023,
        "type": "wifi",
        "wpa_supplicant": {"connect-time": "11"},
    }

    result = Result.get(raw_data)
    assert isinstance(result, WiFiResult)
    assert result.bundle == 1463493022
    assert result.origin == "2001:67c:2e8:ffe1:eade:27ff:fe69:e6f0"
    assert result.firmware == 4733
    assert result.group_id == 1021275
    assert result.created_timestamp == 1463493023
    assert result.wpa_supplicant.address is None
    assert result.wpa_supplicant.bssid is None
    assert result.wpa_supplicant.connect_time == "11"
    assert result.wpa_supplicant.group_cipher is None
    assert result.wpa_supplicant.wpa_supplicant_id is None
    assert result.wpa_supplicant.ip_address is None
    assert result.wpa_supplicant.key_management is None
    assert result.wpa_supplicant.mode is None
    assert result.wpa_supplicant.pairwise_cipher is None
    assert result.wpa_supplicant.ssid is None
    assert result.wpa_supplicant.wpa_state is None
Example #38
0
def test_ping_4560():
    result = Result.get(
        '{"af":4,"avg":36.887,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"62.195.143.53","fw":4560,"lts":36,"max":40.234000000000002,"min":34.747999999999998,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":3,"result":[{"rtt":40.234000000000002},{"rtt":34.747999999999998,"srcaddr":"192.168.1.229"},{"rtt":35.679000000000002,"srcaddr":"192.168.1.229"}],"sent":3,"size":20,"src_addr":"192.168.1.229","step":360,"timestamp":1380586151,"ttl":54,"type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average == 36.887)
    assert (result.rtt_median == 35.679)
    assert (result.destination_address == "62.2.16.12")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 0)
    assert (result.origin == "62.195.143.53")
    assert (result.firmware == 4560)
    assert (result.seconds_since_sync is 36)
    assert (result.rtt_max == 40.234)
    assert (result.rtt_min == 34.748)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 202)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 3)
    assert (result.packets_sent == 3)
    assert (result.packet_size == 12)
    assert (result.step == 360)
    assert (result.created.isoformat() == "2013-10-01T00:09:11+00:00")
    assert (result.packets[0].rtt == 40.234)
    assert (result.packets[1].rtt == 34.748)
    assert (result.packets[2].rtt == 35.679)
    assert (result.packets[0].ttl == 54)
    assert (result.packets[1].ttl == 54)
    assert (result.packets[2].ttl == 54)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is False)
    assert (result.packets[2].dup is False)
    assert (result.packets[0].source_address == "192.168.1.229")
    assert (result.packets[1].source_address == "192.168.1.229")
    assert (result.packets[2].source_address == "192.168.1.229")
Example #39
0
def test_ping_4480():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":95.756666666666661,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"194.85.27.7","fw":4480,"max":96.147999999999996,"min":95.388999999999996,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"proto":"ICMP","rcvd":3,"result":[{"rtt":95.733000000000004},{"rtt":96.147999999999996},{"rtt":95.388999999999996}],"sent":3,"size":20,"src_addr":"192.168.3.8","timestamp":1349776268,"ttl":46,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 95.757)
    assert(result.rtt_median == 95.733)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "194.85.27.7")
    assert(result.firmware == 4480)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 96.148)
    assert(result.rtt_min == 95.389)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 165)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2012-10-09T09:51:08+00:00")
    assert(result.packets[0].rtt == 95.733)
    assert(result.packets[1].rtt == 96.148)
    assert(result.packets[2].rtt == 95.389)
    assert(result.packets[0].ttl == 46)
    assert(result.packets[1].ttl == 46)
    assert(result.packets[2].ttl == 46)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.3.8")
    assert(result.packets[1].source_address == "192.168.3.8")
    assert(result.packets[2].source_address == "192.168.3.8")
Example #40
0
def test_ping_4600():
    result = Result.get(
        '{"af":4,"avg":47.951999999999998,"dst_addr":"62.2.16.24","dst_name":"hsi.cablecom.ch","dup":0,"from":"188.195.183.141","fw":4600,"group_id":1000192,"lts":222,"max":48.990000000000002,"min":45.939,"msm_id":1000192,"msm_name":"Ping","prb_id":270,"proto":"ICMP","rcvd":3,"result":[{"rtt":45.939},{"rtt":48.927},{"rtt":48.990000000000002}],"sent":3,"size":12,"src_addr":"192.168.178.21","step":360,"timestamp":1392321470,"ttl":50,"type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average == 47.952)
    assert (result.rtt_median == 48.927)
    assert (result.destination_address == "62.2.16.24")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 0)
    assert (result.origin == "188.195.183.141")
    assert (result.firmware == 4600)
    assert (result.seconds_since_sync == 222)
    assert (result.rtt_max == 48.99)
    assert (result.rtt_min == 45.939)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 270)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 3)
    assert (result.packets_sent == 3)
    assert (result.packet_size == 12)
    assert (result.step == 360)
    assert (result.created.isoformat() == "2014-02-13T19:57:50+00:00")
    assert (result.packets[0].rtt == 45.939)
    assert (result.packets[1].rtt == 48.927)
    assert (result.packets[2].rtt == 48.99)
    assert (result.packets[0].ttl == 50)
    assert (result.packets[1].ttl == 50)
    assert (result.packets[2].ttl == 50)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is False)
    assert (result.packets[2].dup is False)
    assert (result.packets[0].source_address == "192.168.178.21")
    assert (result.packets[1].source_address == "192.168.178.21")
    assert (result.packets[2].source_address == "192.168.178.21")
Example #41
0
 def add_probe_and_target_results(self, results_dict):
     with open(self.filename) as results:
         for result in results.readlines():
             parsed_result = Result.get(result)
             probe_id = self._get_attr("probe_id", parsed_result)
             target = self._get_attr("target", parsed_result)
             key = str(probe_id) + ' ; ' + target
             origin = parsed_result.origin
             try:
                 # see if this key exists yet
                 inner_dict = results_dict[str(key)]
             except KeyError:
                 # initialize all types to 0
                 results_dict[str(key)] = {"probe_id" : probe_id, "target" : target, "ping" : 0, "dns" : 0, "traceroute" : 0, "origins" : {}}
                 # increment the appropriate type (ping, dns, traceroute)
                 results_dict[str(key)][self.type] += 1
                 results_dict[str(key)]["origins"][origin] = 1
             else:
                 # already initialized, increment
                 results_dict[str(key)][self.type] += 1
                 # origins
                 try:
                     results_dict[str(key)]["origins"][origin] += 1
                 except KeyError:
                     results_dict[str(key)]["origins"][origin] = 1
Example #42
0
def test_ping_4460():
    result = Result.get(
        '{"addr":"62.2.16.12","af":4,"avg":48.388333333333328,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"188.194.234.136","fw":4460,"max":56.948999999999998,"min":43.869999999999997,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":270,"proto":"ICMP","rcvd":3,"result":[{"rtt":43.869999999999997},{"rtt":56.948999999999998},{"rtt":44.345999999999997}],"sent":3,"size":20,"src_addr":"192.168.178.21","timestamp":1340524626,"ttl":52,"type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average == 48.388)
    assert (result.rtt_median == 44.346)
    assert (result.destination_address == "62.2.16.12")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 0)
    assert (result.origin == "188.194.234.136")
    assert (result.firmware == 4460)
    assert (result.seconds_since_sync is None)
    assert (result.rtt_max == 56.949)
    assert (result.rtt_min == 43.87)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 270)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 3)
    assert (result.packets_sent == 3)
    assert (result.packet_size == 12)
    assert (result.step is None)
    assert (result.created.isoformat() == "2012-06-24T07:57:06+00:00")
    assert (result.packets[0].rtt == 43.87)
    assert (result.packets[1].rtt == 56.949)
    assert (result.packets[2].rtt == 44.346)
    assert (result.packets[0].ttl == 52)
    assert (result.packets[1].ttl == 52)
    assert (result.packets[2].ttl == 52)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is False)
    assert (result.packets[2].dup is False)
    assert (result.packets[0].source_address == "192.168.178.21")
    assert (result.packets[1].source_address == "192.168.178.21")
    assert (result.packets[2].source_address == "192.168.178.21")
Example #43
0
 def add_to_results_dict(self, key_name, results_dict):
     with open(self.filename) as results:
         for result in results.readlines():
             parsed_result = Result.get(result)
             key = self._get_attr(key_name, parsed_result)
             origin = parsed_result.origin
             target = self._get_attr("target", parsed_result)
             try:
                 # see if this key exists yet
                 inner_dict = results_dict[str(key)]
             except KeyError:
                 # initialize all types to 0
                 results_dict[str(key)] = {"ping" : 0, "dns" : 0, "traceroute" : 0, "origins" : {}, "targets" : {}}
                 # increment the appropriate type
                 results_dict[str(key)][self.type] += 1
                 results_dict[str(key)]["origins"][origin] = 1
                 results_dict[str(key)]["targets"][target] = 1
             else:
                 # already initialized, increment
                 results_dict[str(key)][self.type] += 1
                 # origins
                 try:
                     results_dict[str(key)]["origins"][origin] += 1
                 except KeyError:
                     results_dict[str(key)]["origins"][origin] = 1
                 # targets
                 try:
                     results_dict[str(key)]["targets"][target] += 1
                 except KeyError:
                     results_dict[str(key)]["targets"][target] = 1
Example #44
0
def test_qbuf():
    result = Result.get('{"from":"208.118.139.24","fw":4610,"group_id":1666151,"msm_id":1666151,"msm_name":"Tdig","prb_id":15112,"resultset":[{"af":4,"dst_addr":"8.8.8.8","proto":"TCP","qbuf":"dakBgAABAAAAAAABBTE1MTEyCjE0MDA2NjU1MjMDd3d3B3R3aXR0ZXIDY29tAAABAAEAACkCAAAAgAAABAADAAA=","result":{"ANCOUNT":0,"ARCOUNT":1,"ID":30121,"NSCOUNT":1,"QDCOUNT":1,"rt":57.764,"size":133},"src_addr":"10.0.5.101","subid":1,"submax":2,"time":1400665523},{"af":4,"dst_addr":"8.8.4.4","proto":"TCP","qbuf":"JTEBgAABAAAAAAABBTE1MTEyCjE0MDA2NjU1MjQDd3d3B3R3aXR0ZXIDY29tAAABAAEAACkCAAAAgAAABAADAAA=","result":{"ANCOUNT":0,"ARCOUNT":1,"ID":9521,"NSCOUNT":1,"QDCOUNT":1,"rt":57.263,"size":133},"src_addr":"10.0.5.101","subid":2,"submax":2,"time":1400665524}],"timestamp":1400665523,"type":"dns"}')
    assert(result.responses[0].abuf is None)
    assert(str(result.responses[0].qbuf) == "dakBgAABAAAAAAABBTE1MTEyCjE0MDA2NjU1MjMDd3d3B3R3aXR0ZXIDY29tAAABAAEAACkCAAAAgAAABAADAAA=")
    assert(result.responses[0].qbuf.header.aa is False)
    assert(result.responses[0].qbuf.header.qr is False)
    assert(result.responses[0].qbuf.header.nscount == 0)
    assert(result.responses[0].qbuf.header.qdcount == 1)
    assert(result.responses[0].qbuf.header.ancount == 0)
    assert(result.responses[0].qbuf.header.tc is False)
    assert(result.responses[0].qbuf.header.rd is True)
    assert(result.responses[0].qbuf.header.arcount == 1)
    assert(result.responses[0].qbuf.header.return_code == "NOERROR")
    assert(result.responses[0].qbuf.header.opcode == "QUERY")
    assert(result.responses[0].qbuf.header.ra is True)
    assert(result.responses[0].qbuf.header.z == 0)
    assert(result.responses[0].qbuf.header.id == 30121)
    assert(len(result.responses[0].qbuf.questions) == 1)
    assert(result.responses[0].qbuf.questions[0].klass == "IN")
    assert(result.responses[0].qbuf.questions[0].type == "A")
    assert(result.responses[0].qbuf.questions[0].name == "15112.1400665523.www.twitter.com.")
    assert(result.responses[0].qbuf.edns0.extended_return_code == 0)
    assert(result.responses[0].qbuf.edns0.udp_size == 512)
    assert(result.responses[0].qbuf.edns0.version == 0)
    assert(result.responses[0].qbuf.edns0.z == 255)
    assert(result.responses[0].qbuf.edns0.type == "OPT")
    assert(result.responses[0].qbuf.edns0.name == ".")
    assert(len(result.responses[0].qbuf.edns0.options) == 1)
    assert(result.responses[0].qbuf.edns0.options[0].code == 3)
    assert(result.responses[0].qbuf.edns0.options[0].name == "NSID")
    assert(result.responses[0].qbuf.edns0.options[0].nsid == "")
    assert(result.responses[0].qbuf.edns0.options[0].length == 0)
def get_results(mid):
    from datetime import datetime
    from ripe.atlas.cousteau import AtlasResultsRequest

    kwargs = {
        "msm_id": mid,
    }

    is_success, results = AtlasResultsRequest(**kwargs).create()

    if is_success:
        #        print(results)
        pass
    else:
        raise Exception("Unsuccessful when getting results.")

    from ripe.atlas.sagan import Result
    ret = {}
    for r in results:
        rp = Result.get(r)
        print "probe_id=%d probe_ip=%s sent=%d recv=%d" % (
            rp.probe_id, rp.origin, rp.packets_sent, rp.packets_received)
        if rp.probe_id in ret:
            raise Exception("Probe ID %d is already in result." % rp.probe_id)
        else:
            ret[rp.
                probe_id] = False if rp.packets_sent > 0 and rp.packets_received == 0 else True

    return ret
Example #46
0
    def process_results(self, results, probes_filter):
        logger.info("Processing results...")

        # Be sure to have info for every probe in the resultset
        self.update_probes(results)

        if len(results) == 0:
            logger.info("No results found.")
            return

        # Processing results...

        for json_result in results:
            result = Result.get(json_result, on_error=Result.ACTION_IGNORE,
                                on_malformation=Result.ACTION_IGNORE)

            probe = self.get_probe(result)
            if probe not in probes_filter:
                logger.debug(
                    "  skipping {} because of probes filter".format(probe)
                )
                continue

            self.process_result(result)
            self.update_latest_result_ts(result)
            self.internal_labels["results"] = {}

        self.ip_cache.save()
Example #47
0
def test_ping_4470():
    result = Result.get('{"addr":"62.2.16.12","af":4,"avg":195.649,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"194.85.27.7","fw":4470,"max":197.79300000000001,"min":193.059,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"proto":"ICMP","rcvd":3,"result":[{"rtt":196.095},{"rtt":197.79300000000001},{"rtt":193.059}],"sent":3,"size":20,"src_addr":"192.168.3.8","timestamp":1344514151,"ttl":46,"type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 195.649)
    assert(result.rtt_median == 196.095)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "194.85.27.7")
    assert(result.firmware == 4470)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 197.793)
    assert(result.rtt_min == 193.059)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 165)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step is None)
    assert(result.created.isoformat() == "2012-08-09T12:09:11+00:00")
    assert(result.packets[0].rtt == 196.095)
    assert(result.packets[1].rtt == 197.793)
    assert(result.packets[2].rtt == 193.059)
    assert(result.packets[0].ttl == 46)
    assert(result.packets[1].ttl == 46)
    assert(result.packets[2].ttl == 46)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address == "192.168.3.8")
    assert(result.packets[1].source_address == "192.168.3.8")
    assert(result.packets[2].source_address == "192.168.3.8")
    def aggregate(self, results, probes):

        # Build "sagans" as a list of Sagan result objects: http://goo.gl/HKFkHE
        sagans = []
        for result in results:
            try:
                result = Result.get(result)
                if not probes or result.probe_id in probes:
                    sagans.append(result)
            except ResultError:
                print("Bad result found: {}\n".format(json.dumps(result)))

        # Build a lookup dictionary of id:object for below
        probes = dict([
            (p.id, p) for p in Probe.get_from_api([r.probe_id for r in sagans])
        ])

        # Build the aggregate database
        db = {}
        for result in sagans:
            line = self.renderer.on_result(result, probes=probes)
            db.setdefault(probes[line.probe_id].country_code, []).append(
                line)

        # Print everything out
        r = ""
        for country, lines in db.items():
            r += "{}\n".format(country)
            for line in lines:
                r += "  {}".format(line)
            r += "\n"

        return r
Example #49
0
def test_ping_4480():
    result = Result.get(
        '{"addr":"62.2.16.12","af":4,"avg":95.756666666666661,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"194.85.27.7","fw":4480,"max":96.147999999999996,"min":95.388999999999996,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"proto":"ICMP","rcvd":3,"result":[{"rtt":95.733000000000004},{"rtt":96.147999999999996},{"rtt":95.388999999999996}],"sent":3,"size":20,"src_addr":"192.168.3.8","timestamp":1349776268,"ttl":46,"type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average == 95.757)
    assert (result.rtt_median == 95.733)
    assert (result.destination_address == "62.2.16.12")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 0)
    assert (result.origin == "194.85.27.7")
    assert (result.firmware == 4480)
    assert (result.seconds_since_sync is None)
    assert (result.rtt_max == 96.148)
    assert (result.rtt_min == 95.389)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 165)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 3)
    assert (result.packets_sent == 3)
    assert (result.packet_size == 12)
    assert (result.step is None)
    assert (result.created.isoformat() == "2012-10-09T09:51:08+00:00")
    assert (result.packets[0].rtt == 95.733)
    assert (result.packets[1].rtt == 96.148)
    assert (result.packets[2].rtt == 95.389)
    assert (result.packets[0].ttl == 46)
    assert (result.packets[1].ttl == 46)
    assert (result.packets[2].ttl == 46)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is False)
    assert (result.packets[2].dup is False)
    assert (result.packets[0].source_address == "192.168.3.8")
    assert (result.packets[1].source_address == "192.168.3.8")
    assert (result.packets[2].source_address == "192.168.3.8")
Example #50
0
def test_ntp_error():
    result = (
        '{ "msm_id":"1020235", "fw":4661, "lts":76, "timestamp":1418196642, "dst_name":"atlas", '
        '"prb_id":71, "dst_addr":"193.0.6.139", "src_addr":"193.0.10.127", "proto":"UDP", "af": 4,'
        '"from": "193.0.0.78", "type": "ntp", "result": '
        '[ { "error":"error-example" }, { "error":"error-example" }, { "x":"*" } ] '
        '}')
    result = Result.get(result)
    assert (isinstance(result, NtpResult))
    assert (result.af == 4)
    assert (result.firmware == 4661)
    assert (result.destination_address == "193.0.6.139")
    assert (result.destination_name == "atlas")
    assert (result.source_address == "193.0.10.127")
    assert (result.origin == "193.0.0.78")
    assert (result.leap_second_indicator is None)
    assert (result.stratum is None)
    assert (result.rtt_median is None)
    assert (result.offset_median is None)
    assert (getattr(result.packets[0], "final_timestamp", None) is None)
    assert (getattr(result.packets[0], "final_time", None) is None)
    assert (getattr(result.packets[0], "origin_timestamp", None) is None)
    assert (getattr(result.packets[0], "origin_time", None) is None)
    assert (getattr(result.packets[0], "transmitted_timestamp", None) is None)
    assert (getattr(result.packets[0], "transmitted_time", None) is None)
    assert (getattr(result.packets[0], "received_timestamp", None) is None)
    assert (getattr(result.packets[0], "received_time", None) is None)
    assert (result.packets[0].offset is None)
    assert (result.packets[0].rtt is None)
Example #51
0
def test_ping_4500():
    result = Result.get(
        '{"addr":"62.2.16.12","af":4,"avg":30.114666666666665,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"80.56.151.3","fw":4500,"max":30.344999999999999,"min":29.960999999999999,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":202,"proto":"ICMP","rcvd":3,"result":[{"rtt":30.038},{"rtt":29.960999999999999},{"rtt":30.344999999999999}],"sent":3,"size":20,"src_addr":"192.168.1.229","timestamp":1361244431,"ttl":55,"type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average == 30.115)
    assert (result.rtt_median == 30.038)
    assert (result.destination_address == "62.2.16.12")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 0)
    assert (result.origin == "80.56.151.3")
    assert (result.firmware == 4500)
    assert (result.seconds_since_sync is None)
    assert (result.rtt_max == 30.345)
    assert (result.rtt_min == 29.961)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 202)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 3)
    assert (result.packets_sent == 3)
    assert (result.packet_size == 12)
    assert (result.step is None)
    assert (result.created.isoformat() == "2013-02-19T03:27:11+00:00")
    assert (result.packets[0].rtt == 30.038)
    assert (result.packets[1].rtt == 29.961)
    assert (result.packets[2].rtt == 30.345)
    assert (result.packets[0].ttl == 55)
    assert (result.packets[1].ttl == 55)
    assert (result.packets[2].ttl == 55)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is False)
    assert (result.packets[2].dup is False)
    assert (result.packets[0].source_address == "192.168.1.229")
    assert (result.packets[1].source_address == "192.168.1.229")
    assert (result.packets[2].source_address == "192.168.1.229")
Example #52
0
def test_ssl_4610():
    result = Result.get('{"af":4,"cert":["-----BEGIN CERTIFICATE-----\nMIIEzjCCAragAwIBAg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Wu1UWP9uXmnNK7lwYqVSykGRkbJCG1Wnwku2CqIPvRwrazmd0IAOZ\nXO3kymgbo+pmARWIulpbxz5wzCG0K5OFSFO0Ow4p4MqdrGcid9tZ81Z+db7PbVkk\nGAwlJya0Y8kRZS/arG+UPCPl+O2OV6ICmZ3502+nJJhZ1Ahx7stjtv69HxWoX3zQ\n/xuBnKFIZK1EtlVKVvXcFth7akRqs0K9/h1kaxoKoPBfxpZqhjOiu6+OkdydP+CY\nkRZsj2WDYqZlbSnzYNsqy1Asp/cfsyWHp+scUBh+f4ENDg98M9sl4tpOATH+OFD7\nypdttWGjShYfOeQWWJF9J9Q/YFseYH1oAyQ4AV4ga4SM5BZksbsfXgEgXyxdo8DN\nZO4PfRAtaSH+ZKrmgmrcm/CcvNn+EaW6qw7dAhJE4JNkfUAm5qMTuA35ERMkgucD\nyu/PjjzBG2HeHrSqzb3ZoERlF8wfU0wIJeiDRtHYUfu/Hr+XA/80Uq66YrhRyqPS\nM1x0SqeaCYdgfsmK1fB0/brDbOhNXIYbvIShcimGyjfKyHK/FL18SF676/Mc9fbe\ngWyIey4h+S/dYCHJpVKj2HUq1Jni6n3CtxNyqF0EjR1FVA==\n-----END CERTIFICATE-----"],"dst_addr":"80.79.115.54","dst_name":"pretical.ee","dst_port":"443","from":"125.238.215.240","fw":4610,"method":"SSL","msm_id":1006864,"msm_name":"SSLCert","prb_id":74,"rt":696.07500000000005,"src_addr":"10.0.0.2","timestamp":1396269382,"ttc":345.97899999999998,"type":"sslcert","ver":"3.0"}')
    assert(isinstance(result, SslResult))
    assert(result.af == 4)
    assert(result.firmware == 4610)
    assert(result.destination_address == "80.79.115.54")
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address == "10.0.0.2")
    assert(result.port == 443)
    assert(result.origin == "125.238.215.240")
    assert(result.method == "SSL")
    assert(result.version == "3.0")
    assert(result.response_time == 696.075)
    assert(result.time_to_connect == 345.979)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 74)
    assert(result.created.isoformat() == "2014-03-31T12:36:22+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 1)
    assert(result.certificates[0])
    assert(result.certificates[0].subject_cn == "*.pretical.ee")
    assert(result.certificates[0].subject_o is None)
    assert(result.certificates[0].subject_c is None)
    assert(result.certificates[0].issuer_cn == "CA Cert Signing Authority")
    assert(result.certificates[0].issuer_o == "Root CA")
    assert(result.certificates[0].issuer_c is None)
    assert(result.certificates[0].valid_from.isoformat() == "2014-01-03T21:22:51+00:00")
    assert(result.certificates[0].valid_until.isoformat() == "2014-07-02T21:22:51+00:00")
    assert(result.certificates[0].checksum == "28:E6:A2:51:CE:D1:E9:34:2E:69:41:44:55:43:41:88:4D:93:4E:67:02:09:48:8C:86:68:25:8F:5E:DF:96:98")
    assert(result.certificates[0].checksum_md5 == "97:A2:0C:C7:93:E1:4B:24:6D:EA:55:09:6E:21:A8:96")
    assert(result.certificates[0].checksum_sha1 == "2B:FE:E8:F8:4B:25:19:D4:9B:3B:18:A3:29:E1:6C:79:72:FF:96:02")
    assert(result.certificates[0].checksum_sha256 == "28:E6:A2:51:CE:D1:E9:34:2E:69:41:44:55:43:41:88:4D:93:4E:67:02:09:48:8C:86:68:25:8F:5E:DF:96:98")
Example #53
0
def test_ping_4520():
    result = Result.get(
        '{"addr":"62.2.16.12","af":4,"avg":67.420999999999992,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"194.85.27.7","fw":4520,"max":70.230999999999995,"min":65.974999999999994,"msm_id":1000192,"name":"hsi.cablecom.ch","prb_id":165,"proto":"ICMP","rcvd":3,"result":[{"rtt":70.230999999999995},{"rtt":65.974999999999994},{"rtt":66.057000000000002}],"sent":3,"size":20,"src_addr":"192.168.3.8","timestamp":1365379380,"ttl":47,"type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average == 67.421)
    assert (result.rtt_median == 66.057)
    assert (result.destination_address == "62.2.16.12")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 0)
    assert (result.origin == "194.85.27.7")
    assert (result.firmware == 4520)
    assert (result.seconds_since_sync is None)
    assert (result.rtt_max == 70.231)
    assert (result.rtt_min == 65.975)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 165)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 3)
    assert (result.packets_sent == 3)
    assert (result.packet_size == 12)
    assert (result.step is None)
    assert (result.created.isoformat() == "2013-04-08T00:03:00+00:00")
    assert (result.packets[0].rtt == 70.231)
    assert (result.packets[1].rtt == 65.975)
    assert (result.packets[2].rtt == 66.057)
    assert (result.packets[0].ttl == 47)
    assert (result.packets[1].ttl == 47)
    assert (result.packets[2].ttl == 47)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is False)
    assert (result.packets[2].dup is False)
    assert (result.packets[0].source_address == "192.168.3.8")
    assert (result.packets[1].source_address == "192.168.3.8")
    assert (result.packets[2].source_address == "192.168.3.8")
Example #54
0
def test_ssl_4520():
    result = Result.get('{"af":4,"cert":["-----BEGIN CERTIFICATE-----\nMIIEzjCCAragAwIBAgIDDXW/MA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv\nb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ\nQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y\ndEBjYWNlcnQub3JnMB4XDTEzMDcwNjA1NTQ1NFoXDTE0MDEwMjA1NTQ1NFowGDEW\nMBQGA1UEAxQNKi5wcmV0aWNhbC5lZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC\nAQoCggEBAMS+vX7gA8TvzFwxryFFRj1OyQjnW88GvfMuGhKJopalG1EB103oRsxi\nMcXqwFZUicpqLKHW4lCHcRuhpKoZp8EOILnRAJRKFOjgIrcHQ02Xn4Lf/ewl601h\n5qxqt1keU1P8j+u9m7z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V1b1/+nK5+00wJEF6mIvtMCMr+7zf62LTLRgM8U\njzPNkFt0hzq3coOKOeho6pGvE9NyV+8Ed7K9H3DpYf4y5BDigOGfLVU9bnYaJdWn\ngRkq8Xmcm73lglN49oBXrxZrxQh0LAHWgbNxuQ3iMAvmuw==\n-----END CERTIFICATE-----"],"dst_addr":"80.79.115.54","dst_name":"pretical.ee","dst_port":"https","from":"77.95.64.18","fw":4520,"method":"SSL","msm_id":1006864,"msm_name":"SSLCert","prb_id":517,"src_addr":"77.95.64.18","timestamp":1378499876,"type":"sslcert","ver":"3.0"}')
    assert(isinstance(result, SslResult))
    assert(result.af == 4)
    assert(result.firmware == 4520)
    assert(result.destination_address == "80.79.115.54")
    assert(result.destination_name == "pretical.ee")
    assert(result.source_address == "77.95.64.18")
    assert(result.port == 443)
    assert(result.origin == "77.95.64.18")
    assert(result.method == "SSL")
    assert(result.version == "3.0")
    assert(result.response_time is None)
    assert(result.time_to_connect is None)
    assert(result.measurement_id == 1006864)
    assert(result.probe_id == 517)
    assert(result.created.isoformat() == "2013-09-06T20:37:56+00:00")
    assert(isinstance(result.certificates, list))
    assert(len(result.certificates) == 1)
    assert(result.certificates[0])
    assert(result.certificates[0].subject_cn == "*.pretical.ee")
    assert(result.certificates[0].subject_o is None)
    assert(result.certificates[0].subject_c is None)
    assert(result.certificates[0].issuer_cn == "CA Cert Signing Authority")
    assert(result.certificates[0].issuer_o == "Root CA")
    assert(result.certificates[0].issuer_c is None)
    assert(result.certificates[0].valid_from.isoformat() == "2013-07-06T05:54:54+00:00")
    assert(result.certificates[0].valid_until.isoformat() == "2014-01-02T05:54:54+00:00")
    assert(result.certificates[0].checksum == "F9:C1:DC:CE:CE:C2:E8:42:00:D1:A1:B5:0D:93:09:DE:73:DA:CE:56:0A:FD:A3:BB:B1:CC:1E:2E:47:15:C3:A6")
    assert(result.certificates[0].checksum_md5 == "38:07:D1:3C:0C:79:01:5E:F6:0E:6B:48:B4:3C:F4:59")
    assert(result.certificates[0].checksum_sha1 == "C5:31:2B:AC:B2:4F:D2:F8:47:57:2A:4F:04:D7:F9:18:91:20:C7:1F")
    assert(result.certificates[0].checksum_sha256 == "F9:C1:DC:CE:CE:C2:E8:42:00:D1:A1:B5:0D:93:09:DE:73:DA:CE:56:0A:FD:A3:BB:B1:CC:1E:2E:47:15:C3:A6")
Example #55
0
def test_ping_4550():
    result = Result.get(
        '{"af":4,"avg":27.300999999999998,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"80.56.151.3","fw":4550,"lts":365,"max":27.300999999999998,"min":27.300999999999998,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":1,"result":[{"srcaddr":"192.168.1.229","x":"*"},{"x":"*"},{"rtt":27.300999999999998,"ttl":54}],"sent":3,"size":20,"src_addr":"192.168.1.229","step":360,"timestamp":1378271710,"ttl":54,"type":"ping"}'
    )
    assert (result.af == 4)
    assert (result.rtt_average == 27.301)
    assert (result.rtt_median == 27.301)
    assert (result.destination_address == "62.2.16.12")
    assert (result.destination_name == "hsi.cablecom.ch")
    assert (result.duplicates == 0)
    assert (result.origin == "80.56.151.3")
    assert (result.firmware == 4550)
    assert (result.seconds_since_sync == 365)
    assert (result.rtt_max == 27.301)
    assert (result.rtt_min == 27.301)
    assert (result.measurement_id == 1000192)
    assert (result.probe_id == 202)
    assert (result.protocol == PingResult.PROTOCOL_ICMP)
    assert (result.packets_received == 1)
    assert (result.packets_sent == 3)
    assert (result.packet_size == 12)
    assert (result.step == 360)
    assert (result.created.isoformat() == "2013-09-04T05:15:10+00:00")
    assert (result.packets[0].rtt is None)
    assert (result.packets[1].rtt is None)
    assert (result.packets[2].rtt == 27.301)
    assert (result.packets[0].ttl is None)
    assert (result.packets[1].ttl is None)
    assert (result.packets[2].ttl == 54)
    assert (result.packets[0].dup is False)
    assert (result.packets[1].dup is False)
    assert (result.packets[2].dup is False)
    assert (result.packets[0].source_address == "192.168.1.229")
    assert (result.packets[1].source_address == "192.168.1.229")
    assert (result.packets[2].source_address == "192.168.1.229")
    def setUp(self):
        result = {'af': 4, 'prb_id': 1216, 'result': [{'rtt': 27.429}, {'rtt': 25.672}, {'rtt': 25.681}], 'ttl': 54, 'avg': 26.2606666667, 'size': 20, 'from': '109.190.83.40', ' proto': 'ICMP', 'timestamp': 1445025400, 'dup': 0, 'type': 'ping', 'sent': 3, 'msm_id': 1000192, 'fw': 4700, 'max': 27.429, 'step': 360, 'src_addr': '192.168.103.132', 'rcvd': 3, 'msm_name': 'Ping', 'lts': 377, 'dst_name': 'hsi.cablecom.ch', 'min': 25.672, 'dst_addr': '62.2.16.24'}

        probes = [
            Probe(
                id=1216,
                meta_data={"country_code": "GR", "asn_v4": 3337, "asn_v6": "4445"}
            ),
            Probe(
                id=121,
                meta_data={"country_code": "GR", "asn_v4": 3338, "asn_v6": "4445"}
            ),
            Probe(
                id=12,
                meta_data={"country_code": "DE", "asn_v4": 3339, "asn_v6": 3337}
            ),
            Probe(
                id=1,
                meta_data={"country_code": "NL", "asn_v4": 3337, "asn_v6": "4446"}
            )
        ]
        self.sagan_results = []
        for probe in probes:
            sagan_result = Result.get(
                result, on_error=Result.ACTION_IGNORE, on_warning=Result.ACTION_IGNORE
            )
            sagan_result.probe = probe
            self.sagan_results.append(sagan_result)
Example #57
0
def test_ping_4570():
    result = Result.get('{"af":4,"avg":36.608333333333327,"dst_addr":"62.2.16.12","dst_name":"hsi.cablecom.ch","dup":0,"from":"62.195.143.53","fw":4570,"lts":-1,"max":36.741,"min":36.423999999999999,"msm_id":1000192,"msm_name":"Ping","prb_id":202,"proto":"ICMP","rcvd":3,"result":[{"rtt":36.741},{"rtt":36.659999999999997},{"rtt":36.423999999999999}],"sent":3,"size":12,"step":360,"timestamp":1384500425, "type":"ping"}')
    assert(result.af == 4)
    assert(result.rtt_average == 36.608)
    assert(result.rtt_median == 36.66)
    assert(result.destination_address == "62.2.16.12")
    assert(result.destination_name == "hsi.cablecom.ch")
    assert(result.duplicates == 0)
    assert(result.origin == "62.195.143.53")
    assert(result.firmware == 4570)
    assert(result.seconds_since_sync is None)
    assert(result.rtt_max == 36.741)
    assert(result.rtt_min == 36.424)
    assert(result.measurement_id == 1000192)
    assert(result.probe_id == 202)
    assert(result.protocol == PingResult.PROTOCOL_ICMP)
    assert(result.packets_received == 3)
    assert(result.packets_sent == 3)
    assert(result.packet_size == 12)
    assert(result.step == 360)
    assert(result.created.isoformat() == "2013-11-15T07:27:05+00:00")
    assert(result.packets[0].rtt == 36.741)
    assert(result.packets[1].rtt == 36.66)
    assert(result.packets[2].rtt == 36.424)
    assert(result.packets[0].ttl is None)
    assert(result.packets[1].ttl is None)
    assert(result.packets[2].ttl is None)
    assert(result.packets[0].dup is False)
    assert(result.packets[1].dup is False)
    assert(result.packets[2].dup is False)
    assert(result.packets[0].source_address is None)
    assert(result.packets[1].source_address is None)
    assert(result.packets[2].source_address is None)