示例#1
0
    def test_get_document_types(self, mock_requests):
        mock_response_json = {
            "DE":
            ["DrivingLicence", "IdentityCard", "Passport", "ResidencePermit"]
        }
        response_obj = Response()
        response_obj.__setattr__("status_code", 200)
        response_obj.__setattr__(
            "_content",
            json.dumps(mock_response_json).encode("utf-8"))
        mock_requests.return_value = response_obj

        country_code = "DE"

        reponse = VerificationService().get_document_types(country_code)

        assert (reponse == {
            "DE":
            ["DrivingLicence", "IdentityCard", "Passport", "ResidencePermit"]
        })
    def test_get_all_authentications(self, mock_requests):
        mock_response_json = {
            "authentications": [{
                "key":
                "b007b547-8a2c-4e46-9fe0-514398d1be58",
                "reviewed_at":
                None,
                "review_status":
                None,
                "created_at":
                "2019-12-18T06:03:32.692Z",
                "additional_attributes": {
                    "identifier": "*****@*****.**",
                    "country_code": "in",
                    "identifier_type": "email",
                    "customer_user_id": "1234567"
                },
                "authentication_assessments": {
                    "facematch": {
                        "value": "0.0"
                    },
                    "id_authenticity": {
                        "value": "0.0"
                    },
                    "liveness": {
                        "value": "0.9133184035386636"
                    },
                    "overall": {
                        "value": "0.2283296008846659"
                    }
                },
                "authentication_document":
                "NATIONAL_ID_CARD",
                "additional_document":
                None,
                "documents": [{
                    "document_type":
                    "NATIONAL_ID_CARD",
                    "document_information": [{
                        "key": "DATE_OF_EXPIRY",
                        "value": None
                    }, {
                        "key": "DATE_OF_ISSUE",
                        "value": None
                    }, {
                        "key": "DATE_OF_BIRTH",
                        "value": None
                    }, {
                        "key": "NATIONALITY",
                        "value": "India"
                    }]
                }, {
                    "document_type": None,
                    "document_information": []
                }],
                "end_user": {
                    "customer_user_id": "1234567"
                }
            }, {
                "key":
                "05bd4d91-acf6-4f24-972f-fd1e315a9f18",
                "reviewed_at":
                "2019-12-18T08:03:16.239Z",
                "review_status":
                False,
                "created_at":
                "2019-12-18T07:58:08.924Z",
                "additional_attributes": {
                    "identifier": "*****@*****.**",
                    "country_code": "in",
                    "identifier_type": "email",
                    "customer_user_id": "123"
                },
                "authentication_assessments": {
                    "facematch": {
                        "value": "0.0"
                    },
                    "id_authenticity": {
                        "value": "0.0"
                    },
                    "liveness": {
                        "value": "0.930943828332993"
                    },
                    "overall": {
                        "value": "0.23273595708324826"
                    }
                },
                "authentication_document":
                "NATIONAL_ID_CARD",
                "additional_document":
                None,
                "documents": [{
                    "document_type":
                    "NATIONAL_ID_CARD",
                    "document_information": [{
                        "key": "DATE_OF_EXPIRY",
                        "value": None
                    }, {
                        "key": "DATE_OF_ISSUE",
                        "value": None
                    }, {
                        "key": "DATE_OF_BIRTH",
                        "value": None
                    }, {
                        "key": "NATIONALITY",
                        "value": "India"
                    }]
                }, {
                    "document_type": None,
                    "document_information": []
                }],
                "end_user": {
                    "customer_user_id": "123"
                }
            }],
            "number_of_authentications":
            2,
            "status":
            "success",
            "code":
            "200"
        }

        response_obj = Response()
        response_obj.__setattr__("status_code", 200)
        response_obj.__setattr__(
            "_content",
            json.dumps(mock_response_json).encode("utf-8"))

        mock_requests.return_value = response_obj

        response = PassbaseVerificationService().get_all_authentications()

        assert (response == {
            "authentications": [{
                "key":
                "b007b547-8a2c-4e46-9fe0-514398d1be58",
                "reviewed_at":
                None,
                "review_status":
                None,
                "created_at":
                "2019-12-18T06:03:32.692Z",
                "additional_attributes": {
                    "identifier": "*****@*****.**",
                    "country_code": "in",
                    "identifier_type": "email",
                    "customer_user_id": "1234567"
                },
                "authentication_assessments": {
                    "facematch": {
                        "value": "0.0"
                    },
                    "id_authenticity": {
                        "value": "0.0"
                    },
                    "liveness": {
                        "value": "0.9133184035386636"
                    },
                    "overall": {
                        "value": "0.2283296008846659"
                    }
                },
                "authentication_document":
                "NATIONAL_ID_CARD",
                "additional_document":
                None,
                "documents": [{
                    "document_type":
                    "NATIONAL_ID_CARD",
                    "document_information": [{
                        "key": "DATE_OF_EXPIRY",
                        "value": None
                    }, {
                        "key": "DATE_OF_ISSUE",
                        "value": None
                    }, {
                        "key": "DATE_OF_BIRTH",
                        "value": None
                    }, {
                        "key": "NATIONALITY",
                        "value": "India"
                    }]
                }, {
                    "document_type": None,
                    "document_information": []
                }],
                "end_user": {
                    "customer_user_id": "1234567"
                }
            }, {
                "key":
                "05bd4d91-acf6-4f24-972f-fd1e315a9f18",
                "reviewed_at":
                "2019-12-18T08:03:16.239Z",
                "review_status":
                False,
                "created_at":
                "2019-12-18T07:58:08.924Z",
                "additional_attributes": {
                    "identifier": "*****@*****.**",
                    "country_code": "in",
                    "identifier_type": "email",
                    "customer_user_id": "123"
                },
                "authentication_assessments": {
                    "facematch": {
                        "value": "0.0"
                    },
                    "id_authenticity": {
                        "value": "0.0"
                    },
                    "liveness": {
                        "value": "0.930943828332993"
                    },
                    "overall": {
                        "value": "0.23273595708324826"
                    }
                },
                "authentication_document":
                "NATIONAL_ID_CARD",
                "additional_document":
                None,
                "documents": [{
                    "document_type":
                    "NATIONAL_ID_CARD",
                    "document_information": [{
                        "key": "DATE_OF_EXPIRY",
                        "value": None
                    }, {
                        "key": "DATE_OF_ISSUE",
                        "value": None
                    }, {
                        "key": "DATE_OF_BIRTH",
                        "value": None
                    }, {
                        "key": "NATIONALITY",
                        "value": "India"
                    }]
                }, {
                    "document_type": None,
                    "document_information": []
                }],
                "end_user": {
                    "customer_user_id": "123"
                }
            }],
            "number_of_authentications":
            2,
            "status":
            "success",
            "code":
            "200"
        })
示例#3
0
    def test_get_fields(self, mock_requests):
        mock_response_json = [{
            "PersonInfo": {
                "title":
                "PersonInfo",
                "type":
                "object",
                "properties": {
                    "FirstGivenName": {
                        "type": "string",
                        "description":
                        "First name of the individual to be verified",
                        "label": "First Name"
                    },
                    "MiddleName": {
                        "type": "string",
                        "description":
                        "Second given name of the individual to be verified",
                        "label": "Middle Name"
                    },
                    "FirstSurName": {
                        "type": "string",
                        "description":
                        "Last name of the individual to be verified",
                        "label": "Last Name"
                    },
                    "DayOfBirth": {
                        "type": "int",
                        "description":
                        "Day of birth date (e.g. 23 for a date of birth of 23/11/1975)",
                        "label": "Day Of Birth"
                    },
                    "MonthOfBirth": {
                        "type": "int",
                        "description":
                        "Month of birth date (e.g. 11 for a date of birth of 23/11/1975)",
                        "label": "Month Of Birth"
                    },
                    "YearOfBirth": {
                        "type": "int",
                        "description":
                        "Year of birth date (e.g. 1975 for a date of birth of 23/11/1975)",
                        "label": "Year Of Birth"
                    }
                },
                "required": [
                    "DayOfBirth", "FirstGivenName", "FirstSurName",
                    "MonthOfBirth", "YearOfBirth"
                ]
            },
            "Location": {
                "title": "Location",
                "type": "object",
                "properties": {
                    "BuildingNumber": {
                        "type": "string",
                        "description": "Street number of primary residence",
                        "label": "Street Number"
                    },
                    "UnitNumber": {
                        "type": "string",
                        "description":
                        "Flat/Unit/Apartment number of primary residence",
                        "label": "Unit Number"
                    },
                    "StreetName": {
                        "type": "string",
                        "description": "Street name of primary residence",
                        "label": "Street Name"
                    },
                    "StreetType": {
                        "type": "string",
                        "description":
                        "Street type of primary residence (e.g. St, Rd, etc.)",
                        "label": "Street Type"
                    },
                    "Suburb": {
                        "type": "string",
                        "description": "City or Suburb of primary residence",
                        "label": "Suburb"
                    },
                    "StateProvinceCode": {
                        "type": "string",
                        "description":
                        "State of primary residence. US sources expect 2 characters. Australian sources expect 2 or 3 characters.",
                        "label": "State"
                    },
                    "PostalCode": {
                        "type": "string",
                        "description":
                        "ZIP Code or Postal Code of primary residence",
                        "label": "Postal Code"
                    }
                },
                "required": ["PostalCode", "StreetName"]
            },
            "Communication": {
                "title": "Communication",
                "type": "object",
                "properties": {
                    "MobileNumber": {
                        "type": "string",
                        "description": "Cellular phone number",
                        "label": "Cell Number"
                    },
                    "Telephone": {
                        "type": "string",
                        "description":
                        "Telephone number of the individual to be verified",
                        "label": "Telephone"
                    }
                },
                "required": []
            },
            "Passport": {
                "title": "Passport",
                "type": "object",
                "properties": {
                    "Number": {
                        "type": "string",
                        "description":
                        "Passport number of the individual to be verified",
                        "label": "Passport Number"
                    }
                },
                "required": ["Number"]
            },
            "CountrySpecific": {
                "title": "CountrySpecific",
                "type": "object",
                "properties": {
                    "AU": {
                        "title": "AU",
                        "type": "object",
                        "properties": {
                            "PassportCountry": {
                                "type": "string",
                                "description":
                                "Passport Country (ISO 3166-1 alpha-2)",
                                "label": "Passport Country"
                            },
                            "PassportNumber": {
                                "type": "string",
                                "description":
                                "Passport number of the individual to be verified",
                                "label": "Passport Number"
                            }
                        },
                        "required": ["PassportCountry", "PassportNumber"]
                    }
                }
            }
        }]
        response_obj = Response()
        response_obj.__setattr__("status_code", 200)
        response_obj.__setattr__(
            "_content",
            json.dumps(mock_response_json).encode("utf-8"))
        mock_requests.return_value = response_obj

        configuration_name = "Identity Verification"
        country_code = "AU"

        response = VerificationService().get_fields(configuration_name,
                                                    country_code)

        assert (response == [{
            'PersonInfo': {
                'title':
                'PersonInfo',
                'type':
                'object',
                'properties': {
                    'FirstGivenName': {
                        'type': 'string',
                        'description':
                        'First name of the individual to be verified',
                        'label': 'First Name'
                    },
                    'MiddleName': {
                        'type': 'string',
                        'description':
                        'Second given name of the individual to be verified',
                        'label': 'Middle Name'
                    },
                    'FirstSurName': {
                        'type': 'string',
                        'description':
                        'Last name of the individual to be verified',
                        'label': 'Last Name'
                    },
                    'DayOfBirth': {
                        'type': 'int',
                        'description':
                        'Day of birth date (e.g. 23 for a date of birth of 23/11/1975)',
                        'label': 'Day Of Birth'
                    },
                    'MonthOfBirth': {
                        'type': 'int',
                        'description':
                        'Month of birth date (e.g. 11 for a date of birth of 23/11/1975)',
                        'label': 'Month Of Birth'
                    },
                    'YearOfBirth': {
                        'type': 'int',
                        'description':
                        'Year of birth date (e.g. 1975 for a date of birth of 23/11/1975)',
                        'label': 'Year Of Birth'
                    }
                },
                'required': [
                    'DayOfBirth', 'FirstGivenName', 'FirstSurName',
                    'MonthOfBirth', 'YearOfBirth'
                ]
            },
            'Location': {
                'title': 'Location',
                'type': 'object',
                'properties': {
                    'BuildingNumber': {
                        'type': 'string',
                        'description': 'Street number of primary residence',
                        'label': 'Street Number'
                    },
                    'UnitNumber': {
                        'type': 'string',
                        'description':
                        'Flat/Unit/Apartment number of primary residence',
                        'label': 'Unit Number'
                    },
                    'StreetName': {
                        'type': 'string',
                        'description': 'Street name of primary residence',
                        'label': 'Street Name'
                    },
                    'StreetType': {
                        'type': 'string',
                        'description':
                        'Street type of primary residence (e.g. St, Rd, etc.)',
                        'label': 'Street Type'
                    },
                    'Suburb': {
                        'type': 'string',
                        'description': 'City or Suburb of primary residence',
                        'label': 'Suburb'
                    },
                    'StateProvinceCode': {
                        'type': 'string',
                        'description':
                        'State of primary residence. US sources expect 2 characters. Australian sources expect 2 or 3 characters.',
                        'label': 'State'
                    },
                    'PostalCode': {
                        'type': 'string',
                        'description':
                        'ZIP Code or Postal Code of primary residence',
                        'label': 'Postal Code'
                    }
                },
                'required': ['PostalCode', 'StreetName']
            },
            'Communication': {
                'title': 'Communication',
                'type': 'object',
                'properties': {
                    'MobileNumber': {
                        'type': 'string',
                        'description': 'Cellular phone number',
                        'label': 'Cell Number'
                    },
                    'Telephone': {
                        'type': 'string',
                        'description':
                        'Telephone number of the individual to be verified',
                        'label': 'Telephone'
                    }
                },
                'required': []
            },
            'Passport': {
                'title': 'Passport',
                'type': 'object',
                'properties': {
                    'Number': {
                        'type': 'string',
                        'description':
                        'Passport number of the individual to be verified',
                        'label': 'Passport Number'
                    }
                },
                'required': ['Number']
            },
            'CountrySpecific': {
                'title': 'CountrySpecific',
                'type': 'object',
                'properties': {
                    'AU': {
                        'title': 'AU',
                        'type': 'object',
                        'properties': {
                            'PassportCountry': {
                                'type': 'string',
                                'description':
                                'Passport Country (ISO 3166-1 alpha-2)',
                                'label': 'Passport Country'
                            },
                            'PassportNumber': {
                                'type': 'string',
                                'description':
                                'Passport number of the individual to be verified',
                                'label': 'Passport Number'
                            }
                        },
                        'required': ['PassportCountry', 'PassportNumber']
                    }
                }
            }
        }])