Esempio n. 1
0
def export_data(path='unipass_export.json'):
    try:
        with open(path, 'w') as outfile:
            json.dump([s.__dict__ for s in Service.getall()], outfile, indent=4)
        return True
    except:
        return False
Esempio n. 2
0
 def test_delete_none(self):
     self.user = Service()
     self.user.admin = True
     self.user.name = 'John'
     self.user.password = '******'
     self.user.create()
     self.user.delete()
     self.assertFalse(self.user in Service.getall())
Esempio n. 3
0
 def test_create_none(self):
     self.user = Service()
     self.user.admin = True
     self.user.name = 'John'
     self.user.password = '******'
     self.user.create()
     self.assertTrue(self.user.valid())
     self.assertTrue(self.user in Service.getall())
Esempio n. 4
0
 def test_update_none(self):
     self.user = Service()
     self.user.admin = True
     self.user.name = 'John'
     self.user.password = '******'
     self.user.create()
     self.user = Service.getbyuuid(self.user._uuid)
     self.user.name = 'Kalle'
     self.user.update()
     self.assertTrue(self.user in Service.getall())
Esempio n. 5
0
def login(username, password):
    """User login."""
    for user in Service.getall():
        if (user.name == username and user.password == password) and user.admin:
            return True
    return False
Esempio n. 6
0
def list_all_services():
    """List all services."""
    return [(serv.service, serv.name, serv.uuid) for serv in Service.getall()]
Esempio n. 7
0
def find_by_service(service):
    """Find service."""
    for serv in Service.getall():
        if serv.service == service:
            return serv
    return None
Esempio n. 8
0
def list_all_services():
    return [(serv.service, serv.name, serv.uuid) for serv in Service.getall()]