def test_append_entry_to_secrets(self):
     pap_path = '/tmp/pap-secrets'
     chap_path = '/tmp/chap-secrets'
     touch(pap_path)
     touch(chap_path)
     
     append_entry_to_secrets('vodafone', 'vodafone', pap_path, chap_path)
     pap_data = get_file_data(pap_path)
     chap_data = get_file_data(chap_path)
     
     self.assertEqual(pap_data, '"vodafone"\t*\t"vodafone"\n')
     self.assertEqual(pap_data, chap_data)
     
     os.unlink(pap_path)
     os.unlink(chap_path)
Ejemplo n.º 2
0
    def test_append_entry_to_secrets(self):
        pap_path = '/tmp/pap-secrets'
        chap_path = '/tmp/chap-secrets'
        touch(pap_path)
        touch(chap_path)

        append_entry_to_secrets('vodafone', 'vodafone', pap_path, chap_path)
        pap_data = get_file_data(pap_path)
        chap_data = get_file_data(chap_path)

        self.assertEqual(pap_data, '"vodafone"\t*\t"vodafone"\n')
        self.assertEqual(pap_data, chap_data)

        os.unlink(pap_path)
        os.unlink(chap_path)
 def test_get_file_data(self):
     text = os.urandom(2000)
     path = '/tmp/file.foo'
     fobj = open(path, 'w')
     fobj.write(text)
     fobj.close()
     
     self.assertEqual(text, get_file_data(path))
     os.unlink(path)
Ejemplo n.º 4
0
    def test_get_file_data(self):
        text = os.urandom(2000)
        path = '/tmp/file.foo'
        fobj = open(path, 'w')
        fobj.write(text)
        fobj.close()

        self.assertEqual(text, get_file_data(path))
        os.unlink(path)
 def test_generate_vmc_dns_lock(self):
     dns1 = '212.33.21.1'
     dns2 = '212.33.21.2'
     
     path = '/tmp/test-vmc.lock'
     expected = 'DNS1  212.33.21.1\nDNS2  212.33.21.2\n'
     
     generate_vmc_dns_lock(dns1, dns2, path)
     self.assertEqual(get_file_data(path), expected)
     
     os.unlink(path)
Ejemplo n.º 6
0
    def test_generate_vmc_dns_lock(self):
        dns1 = '212.33.21.1'
        dns2 = '212.33.21.2'

        path = '/tmp/test-vmc.lock'
        expected = 'DNS1  212.33.21.1\nDNS2  212.33.21.2\n'

        generate_vmc_dns_lock(dns1, dns2, path)
        self.assertEqual(get_file_data(path), expected)

        os.unlink(path)
Ejemplo n.º 7
0
    def test_get_wvdial_conf_file(self):
        conf = dict(apn='ac.vodafone.es',
                    username='******',
                    password='******',
                    dialer_profile='default',
                    staticdns=False,
                    dns=None)
        expected = \
"""# wvdial template for VMC

[Dialer Defaults]

Phone = *99***1#
Username = vodafone
Password = vodafone
Stupid Mode = 1
Dial Command = ATDT
Check Def Route = on
Dial Attempts = 3

[Dialer connect]

Modem = /dev/ttyUSB0
Baud = 460800
Init2 = ATZ
Init3 = ATQ0 V1 E0 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,"IP","ac.vodafone.es"
ISDN = 0
Modem Type = Analog Modem
"""

        dialerconf = DialerConf.from_config_dict(conf)
        path = get_wvdial_conf_file(dialerconf, '/dev/ttyUSB0')
        data = get_file_data(path)
        self.assertEqual(data, expected)

        shutil.rmtree(os.path.dirname(path))
    def test_get_wvdial_conf_file(self):
        conf = dict(apn='ac.vodafone.es',
                    username='******',
                    password='******',
                    dialer_profile='default',
                    staticdns=False,
                    dns=None)
        expected = \
"""# wvdial template for VMC

[Dialer Defaults]

Phone = *99***1#
Username = vodafone
Password = vodafone
Stupid Mode = 1
Dial Command = ATDT
Check Def Route = on
Dial Attempts = 3

[Dialer connect]

Modem = /dev/ttyUSB0
Baud = 460800
Init2 = ATZ
Init3 = ATQ0 V1 E0 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,"IP","ac.vodafone.es"
ISDN = 0
Modem Type = Analog Modem
"""
        
        dialerconf = DialerConf.from_config_dict(conf)
        path = get_wvdial_conf_file(dialerconf, '/dev/ttyUSB0')
        data = get_file_data(path)
        self.assertEqual(data, expected)
        
        shutil.rmtree(os.path.dirname(path))
Ejemplo n.º 9
0
 def get_timezone(self):
     timezone_re = re.compile('ZONE="(?P<tzname>[\w/]+)"')
     sysconf_clock_file = get_file_data('/etc/sysconfig/clock')
     search_dict = timezone_re.search(sysconf_clock_file).groupdict()
     return search_dict['tzname']
Ejemplo n.º 10
0
 def get_timezone(self):
     timezone_re = re.compile('ZONE=(?P<tzname>[\w/]+)')
     sysconf_clock_file = get_file_data('/etc/sysconfig/clock')
     search_dict = timezone_re.search(sysconf_clock_file).groupdict()
     return search_dict['tzname'] or None
Ejemplo n.º 11
0
 def get_timezone(self):
     return get_file_data('/etc/timezone').replace('\n', '')
Ejemplo n.º 12
0
 def get_timezone(self):
     return get_file_data('/etc/timezone').replace('\n', '')
Ejemplo n.º 13
0
 def get_timezone(self):
     timezone_re = re.compile('TIMEZONE="(?P<tzname>[\w/]+)"')
     sysconf_clock_file = get_file_data("/etc/sysconfig/clock")
     search_dict = timezone_re.search(sysconf_clock_file).groupdict()
     return search_dict["tzname"]