예제 #1
0
def test_ntp_conf_tab():
    ntp_obj = system_time.NTPConf(context_wrap(NTP_CONF_TAB))
    assert hasattr(ntp_obj, 'data')
    assert 'tinker' in ntp_obj.data
    assert hasattr(ntp_obj, 'servers')
    assert ntp_obj.servers[0] == 'ntp1.inta.ok\tprefer'
    assert ntp_obj.servers[1] == 'ntp2.inta.ok'
    assert ntp_obj.servers[2] == 'ntp3.inta.ok'
예제 #2
0
def test_zero_hosts_ntp_conf():
    ntp_obj = system_time.NTPConf(context_wrap(ZERO_HOSTS_NTP_CONF))
    assert ntp_obj
    assert hasattr(ntp_obj, 'data')
    assert ntp_obj.data == {'broadcastclient': None}
    assert hasattr(ntp_obj, 'servers')
    assert ntp_obj.servers == []
    assert hasattr(ntp_obj, 'peers')
    assert ntp_obj.peers == []
예제 #3
0
def test_ntp_get_tinker():
    ntp_obj = system_time.NTPConf(context_wrap(NTP_TINKER_CONF))
    assert ntp_obj
    assert hasattr(ntp_obj, 'data')
    assert 'tinker' in ntp_obj.data
    # tinker defined but panic not one of its parameters
    assert ntp_obj.get_last('tinker', 'panic') is None
    # tinker step defined
    assert ntp_obj.get_last('tinker', 'step') == '0.4'

    # - keyword parameter value - param not found
    assert ntp_obj.get_last('tinker', 'panic') is None
    assert ntp_obj.get_last('tinker', default='1') == 'step 0.4'  # No param: just find last line
    assert ntp_obj.get_last('tinker', param='panic', default='1') == '1'
    assert ntp_obj.get_last('tinker', 'panic', '1') == '1'

    # - keyword parameter value - param found
    assert ntp_obj.get_last('tinker', 'step') == '0.4'
    assert ntp_obj.get_last('tinker', param='step', default='1') == '0.4'  # Value from config
    assert ntp_obj.get_last('tinker', 'step', '1') == '0.4'
예제 #4
0
def test_standard_ntp_conf():
    ntp_obj = system_time.NTPConf(context_wrap(STANDARD_NTP_CONF))
    assert ntp_obj
    assert hasattr(ntp_obj, 'data')

    # Test configuration dictionary
    data = ntp_obj.data
    assert data == {
        'driftfile': ['/var/lib/ntp/drift'],
        'restrict': [
            'default nomodify notrap nopeer noquery',
            '127.0.0.1',
            '::1',
        ],
        'includefile': ['/etc/ntp/crypto/pw'],
        'keys': ['/etc/ntp/keys'],
        'broadcastclient': None,
        'iburst': None,
        'server': [
            '127.127.1.0',
            '10.20.30.40',
            '192.168.1.111',
        ],
        'fudge': ['127.127.1.0 stratum 10'],
        'peer': [
            'ntp1.example.com',
            'ntp2.example.com',
            'ntp3.example.com',
        ]
    }

    # Test other attributes
    assert hasattr(ntp_obj, 'servers')
    assert ntp_obj.servers == \
        ['10.20.30.40', '127.127.1.0', '192.168.1.111']
    assert hasattr(ntp_obj, 'peers')
    assert ntp_obj.peers == \
        ['ntp1.example.com', 'ntp2.example.com', 'ntp3.example.com']

    # Test get_last with parameter not found
    assert ntp_obj.get_last('tinker', 'panic') is None