예제 #1
0
 def __init__(self,
              dbuser=os.environ.get('MONGODB_USER', None),
              dbpassword=os.environ.get('MONGODB_PASS', None),
              port=os.environ.get('MONGODB_PORT', None),
              host='mongodbhost',
              authsource=os.environ.get('MONGODB_USER', None),
              authmechanism='SCRAM-SHA-256'):
     self.rec = record()
     self.conf = {}  #Ocean daemon config
     self.dbuser = dbuser  #Database login details
     self.dbpassword = dbpassword
     self.authsource = authsource
     self.authmechanism = authmechanism
     self.port = port
     self.host = host
     self.count = 0
예제 #2
0
 def __init__(self,
              token=None,
              whitelisted_dir="whitelisted",
              consider_dir="consider",
              logger=None):
     if logger != None:
         self.logger = logger
     else:
         self.logger = logging.getLogger(self.__class__.__name__)
     self.whitelisted_dir = whitelisted_dir
     self.consider_dir = consider_dir
     self.record = record.record()
     self.onfido = onfido
     self.configuration = self.onfido.Configuration()
     self.configuration.api_key_prefix['Authorization'] = 'Token'
     self.api_instance = self.onfido.DefaultApi()
     if token:
         self.configuration.api_key['Authorization'] = 'token=' + token
예제 #3
0
 def test(self):
     db = database()
     #Get the data from onfido - the hrefs will be given in the webhook
     applicant_check = self.find_applicant_check(
         'https://api.onfido.com/v2/applicants/2bc75038-4776-464c-807d-7d7ad21a08ce/checks/cd210ae4-f487-43da-9f7a-21de0ac43550'
     )
     rec = record.record()
     #Fill a record object
     rec.import_from_applicant_check(applicant_check)
     #Upload to MongoDB database
     db.connect()
     print("Whitelist before: ")
     print(db.whitelist)
     print("Adding customer record: ")
     print(rec.get())
     db.addToWhitelist(rec)
     print("Read customer from database using id: " + rec._id)
     pprint(db.getFromID(rec._id))
     print("Delete customer from database using id: " + rec._id)
     db.whitelist.remove({"_id": rec._id})
     print("Read customer from database using id: " + rec._id)
     pprint(db.getFromID(rec._id))
예제 #4
0
    def test(self, keyFile=None):
        self.connect()
        customer1 = record('customer-00001')
        customer2 = record('customer-00002')

        if (keyFile):
            customer1.importKeys(keyFile)

        else:
            customer1.keys = ['4rt34rt34t4323', '43g349843rt34']
            customer1.addresses = ['32r23f908h23f098h23', '32f08hj23f09823f']

        customer2.keys = ['f348hg0832gf', 'f238fh2938hf98']
        customer2.addresses = ['0294jf0q23hfg0q93efgh', 'qe8fh98hq349fh89']

        print("Record for customer 1.")
        print(customer1.get())

        print("Records in db:")
        print(self.whitelist)

        print("Insert record into db - cust_id_1:")
        cust_id_1 = self.addToWhitelist(customer1)
        print(cust_id_1)

        print("Fetch the customer record using the _id")
        pprint.pprint(self.getFromID(customer1._id))

        print("Fetch a non-existent customer")
        pprint.pprint(self.getFromID(customer2._id))

        print("Add customer2 to the whitelist")
        cust_id_2 = self.addToWhitelist(customer2)
        print(cust_id_2)

        print("Fetch customer2")
        pprint.pprint(self.getFromID(customer2._id))

        print(
            "Fetch the customer record that contains the customer1.addresses")
        pprint.pprint(
            self.whitelist.find_one({'addresses': customer1.addresses}))

        print(
            "Fetch the customer record that contains the first key belonging to customer 2"
        )
        pprint.pprint(self.whitelist.find_one({'keys': customer2.keys[0]}))

        print("Remove customer1 from the db:")
        self.whitelist.remove({"_id": customer1._id})

        print("Fetch customer1")
        pprint.pprint(self.getFromID(customer1._id))

        print("Remove customer2 from the db:")
        self.whitelist.remove({"_id": customer2._id})

        print("Fetch customer2")
        pprint.pprint(self.getFromID(customer2._id))

        print("Finished test.")
예제 #5
0
    def main(self):
        print('Processing considerlist...')
        self.db.connect()

#Loop through all applicant records in consider list.
        for document in self.db.considerlist.find():
            print('========Displaying checks for customer ' + document['_id'])
            pprint(self.id_api.find_applicant(document['_id']))
            n_checks_approved=0
            n_checks_rejected=0
    #Loop through all the checks in the applicant record and request a decision from the user.
            checks_list  = self.id_api.list_checks(document['_id'])
            print('There are ' + str(len(checks_list)) + ' checks in considerlist for this applicant. Results urls are: ')
            nCheck=1
            for check in checks_list :
                print(str(nCheck) + ':   ' + check.results_uri)
                nCheck=nCheck+1
                nCheck=1
            for check in checks_list:
                b_sure=False
        #webbrowser.open(check.download_uri, new=0, autoraise=True)
                print('Displaying check result number ' + str(nCheck) + ' in web browser at '  + str(check.results_uri))
                webbrowser.open(check.results_uri, new=0, autoraise=True)
                while(b_sure==False):
                    review_result=input('Result? [accept/reject/quit]: ')
                    prepend=""
                    if(review_result == "quit"):
                        quit()
                    elif(review_result == "accept"):
                        prepend="Confirm \"accept\" "
                    elif(review_result == 'reject'):
                        prepend="Confirm \"reject\""
                    else:
                        print('Please respond accept/reject/quit.')
                        continue
                    sure=""
                    while((sure != 'yes') and (sure !='no') and (sure != 'quit')):
                        sure=input(prepend + '? [yes/no/quit]: ')
                        if(sure=='quit'):
                            quit()
                        elif(sure=='yes'):
                            b_sure=True
                        elif(sure=='no'):
                            b_sure=False
                        else:
                            print("Please respond yes/no/quit.")
        
                if(review_result=='accept'):
                    customer_record = record()
                    customer_record.import_from_applicant_check(self.id_api.find_applicant_check(applicant_id=document['_id'], check_id=check.id))
                    self.db.addToWhitelist(customer_record)
                    n_checks_approved=n_checks_approved+1
                else:
                    n_checks_rejected=n_checks_rejected+1
                nCheck=nCheck+1
            

        
            print('=============================================================================================')
            print('Finished processing checks for applicant ' + document['_id'])
            print('Summary: ')
            print('')
            print('Checks approved:' + str(n_checks_approved))
            print('Checks rejected:' + str(n_checks_rejected))
            remove_ok=input('Remove applicant from consider list? [yes/no]: ')
            if(remove_ok == 'yes'):
                self.db.remove_from_considerlist(document['_id'])
            print('---------------------------------------------------------------------------------------------')

            
        print('')
        print('...finished processing considerlist.')