Example #1
0
 def updateActionConfig(self, uniquename, action, value):
     autorisation = Autorisation()
     autorisation.module_config = value
     self.storage.updateActionConfig(
         uniquename=uniquename,
         action=action,
         value=self.__ThriftToJson(autorisation))
Example #2
0
def test2():
    try:
        input = Person()
        input.uniquename = '== Hans =='

        details = user_detail()
        details.firstname = 'Hans'
        details.lastname = 'van der Pol'
        details.gender = 'Men'
        details.dob = '6-3-1966'
        input.details = details
        input.username = '******'
        input.password = None
        input.code = '456'
        input.enabled = True

        autorisation = Autorisation()
        autorisation.write_enabled = True
        autorisation.enabled = True
        autorisation.module_config = pickle.dumps(obj="unique name", protocol=None, fix_imports=False)

        actions = dict()
        actions[ActionEnum.LOGIN] = autorisation
        input.autorisations = actions
        ConnectLongMemory().storeNewPerson(input)

    except Thrift.TException as tx:
        print("%s" % (tx.message))
Example #3
0
 def changeAllModuleSettings(self):
     try:
         if self.__secondPerson is not None:
             tokenInput = self.createEarPiAuthObject()
             print(self.__secondPerson)
             autorisations = self.__secondPerson.autorisations
             if autorisations is None:
                 print('test failed, autorisations where none')
                 autorisations = dict()
                 autorisation = Autorisation()
                 autorisation.write_enabled = True
                 autorisation.enabled = True
                 autorisation.module_config = pickle.dumps(
                     obj='hallo nieuwe config',
                     protocol=None,
                     fix_imports=False)
                 autorisations[ActionEnum.LOGIN] = autorisation
             else:
                 for auto in autorisations:
                     autorisations[auto].enabled = True
             token = ConnectEarPi().configureUserModule(
                 self.__secondUniquename, autorisations, tokenInput)
             self.__token = token
         else:
             print("failed, test not executed")
     except Thrift.TException as tx:
         print("%s" % (tx.message))
 def __phone_autorisations():
     phoneautorisation = Autorisation()
     phoneautorisation.enabled = True
     phone_config = PhoneConfigStruct()
     phone_config.email = "*****@*****.**"
     phoneautorisation.module_config = pickle.dumps(obj=phone_config,
                                                    protocol=None,
                                                    fix_imports=False)
     return phoneautorisation
 def __weather_autorisations():
     weatherautorisation = Autorisation()
     weatherautorisation.enabled = True
     weather_input = WeatherInput()
     weather_input.location = 'Amsterdam,nl'
     weatherautorisation.module_config = pickle.dumps(obj=weather_input,
                                                      protocol=None,
                                                      fix_imports=False)
     return weatherautorisation
 def __music_autorisations():
     musicautorisation = Autorisation()
     musicautorisation.enabled = True
     music_config = MusicConfigStruct()
     music_config.email = "*****@*****.**"
     musicautorisation.module_config = pickle.dumps(obj=music_config,
                                                    protocol=None,
                                                    fix_imports=False)
     return musicautorisation
 def __agenda_autorisations():
     agendaautorisation = Autorisation()
     agendaautorisation.enabled = True
     agenda_config = AgendaConfigStruct()
     agenda_config.email = "*****@*****.**"
     agendaautorisation.module_config = pickle.dumps(obj=agenda_config,
                                                     protocol=None,
                                                     fix_imports=False)
     return agendaautorisation
Example #8
0
    def __JsonToThrift(jsondata):
        # thrift_string = TSerialization.deserialize(
        #     jsondata, None, TBinaryProtocol.TBinaryProtocolFactory())
        # person = thrift_string

        person = Person()
        person.uniquename = '%s' % jsondata['uniquename']
        if 'details' in jsondata:
            user_detail_json = jsondata['details']
            details = user_detail()
            if 'firstname' in user_detail_json:
                details.firstname = '%s' % user_detail_json['firstname']
            if 'lastname' in user_detail_json:
                details.lastname = '%s' % user_detail_json['lastname']
            if 'gender' in user_detail_json:
                details.gender = '%s' % user_detail_json['gender']
            if 'dob' in user_detail_json:
                details.dob = '%s' % user_detail_json['dob']
            person.details = details
        if 'enabled' in jsondata:
            person.enabled = True if jsondata['enabled'] else False
        if 'autorisations' in jsondata:
            autorisation_json = jsondata['autorisations']
            print(autorisation_json)
            autorisations = dict()
            for key in autorisation_json:
                value = autorisation_json[key]
                autorisation = Autorisation()
                autorisation.write_enabled = True if value[
                    'write_enabled'] else False
                autorisation.enabled = True if value['enabled'] else False
                if 'module_config' in value and value[
                        'module_config'] is not None:
                    autorisation.module_config = str.encode(
                        value['module_config'])
                autorisations[int(key)] = autorisation
            person.autorisations = autorisations
        return person
 def __config_autorisations():
     configautorisation = Autorisation()
     configautorisation.enabled = True
     return configautorisation
 def __light_autorisations():
     lightautorisation = Autorisation()
     lightautorisation.enabled = True
     # TODO: check if stateless
     return lightautorisation
 def __login_autorisations():
     loginautorisation = Autorisation()
     loginautorisation.enabled = True
     return loginautorisation