class UserTest(unittest.TestCase): def runTest(self): unittest.main() def setUp(self): # Generate random 16 byte username u = uuid4() m = md5(u.bytes) self.username = m.hexdigest()[:16] # Use full username as temporary password self.password = m.hexdigest() self.user = User() def test_add_user(self): home = '/home/' + self.username assert self.user.adduser( self.username, self.password, home ) def test_delete_user(self): assert self.user.deluser(self.username)
def setUp(self): # Generate random 16 byte username u = uuid4() m = md5(u.bytes) self.username = m.hexdigest()[:16] # Use full username as temporary password self.password = m.hexdigest() self.user = User()
from ConfigParser import ConfigParser s = ConfigParser() s.read(['/etc/vsftpd/app.cfg', 'app.cfg']) path.append(join(abspath(dirname(__file__)), s.get('main', 'path'))) # Add virtualenv to path if present in config. # This happens before Driver.User is initiated so it can find the sh module. try: path.append(join(abspath(dirname(__file__)), s.get('main', 'virtualenv'))) except: pass from Driver.User import User user = User(s) parser = optparse.OptionParser( description = 'Delete a vsftpd user', epilog = 'By [email protected]', usage = 'Usage: %prog [options] <username>' ) parser.add_option( '-g', '--groups', action = 'store', metavar = 'sudo,staff', default = '', type = 'string', help = 'Comma-separated list of additional groups to delete' )
from ConfigParser import ConfigParser s = ConfigParser() s.read(['/etc/vsftpd/app.cfg', 'app.cfg']) path.append(join(abspath(dirname(__file__)), s.get('main', 'path'))) # Add virtualenv to path if present in config. # This happens before Driver.User is initiated so it can find the sh module. try: path.append(join(abspath(dirname(__file__)), s.get('main', 'virtualenv'))) except: pass from Driver.User import User user = User(s) def password_push(**config): url = config.get('api_url') values = {'password': config.get('password')} data = urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) return loads(response.read()) def get_random_password(**config): url = config.get('api_url') values = {'words': 4, 'bits': 10} data = urlencode(values)