diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml
index 460a3f6..f80417e 100644
--- a/.github/workflows/sonar.yaml
+++ b/.github/workflows/sonar.yaml
@@ -1,5 +1,5 @@
name: Sonar Scan
-on: [push, pull_request_target]
+on: []
jobs:
sonar:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 5b3004a..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-language: python
-
-dist: xenial
-
-git:
- depth: false
-
-jobs:
- allow_failures:
- - python: "3.8-dev"
- include:
- - &test
- stage: Test
- python: "3.6"
- cache: pip
- before_install:
- - pip install -U setuptools
- install:
- - pip install -r requirements.txt
- - pip install -e .[dev]
- script:
- - py.test -v
- - <<: *test
- python: "3.6-dev"
- - <<: *test
- python: "3.7"
- - <<: *test
- python: "3.7-dev"
- - <<: *test
- python: "3.8"
- - <<: *test
- python: "3.8-dev"
-
- - stage: Analyze
- name: Sonarcloud
- python: "3.8"
- addons:
- sonarcloud:
- organization: "getyoti"
- install:
- - pip install -r requirements.txt
- - pip install -e .[dev]
- script:
- - pytest --cov=yoti_python_sandbox yoti_python_sandbox/tests --cov-report=xml:coverage-reports/coverage-new.xml
- - sed -i 's+.*+/home/travis/build/getyoti/yoti-python-sdk-sandbox/yoti_python_sandbox+g' coverage-reports/coverage-new.xml
- - sonar-scanner
- if: type = pull_request OR branch = master
diff --git a/yoti_python_sandbox/doc_scan/check/__init__.py b/yoti_python_sandbox/doc_scan/check/__init__.py
index f7b1ae1..53740f5 100644
--- a/yoti_python_sandbox/doc_scan/check/__init__.py
+++ b/yoti_python_sandbox/doc_scan/check/__init__.py
@@ -17,3 +17,6 @@
from .sandbox_id_document_comparison_check import ( # noqa: F401
SandboxIdDocumentComparisonCheckBuilder,
)
+from .sandbox_third_party_check import ( # noqa: F401
+ SandboxThirdPartyCheckBuilder,
+)
diff --git a/yoti_python_sandbox/doc_scan/check/sandbox_third_party_check.py b/yoti_python_sandbox/doc_scan/check/sandbox_third_party_check.py
new file mode 100644
index 0000000..8dbc253
--- /dev/null
+++ b/yoti_python_sandbox/doc_scan/check/sandbox_third_party_check.py
@@ -0,0 +1,42 @@
+from yoti_python_sandbox.doc_scan.check.sandbox_check import SandboxCheckBuilder
+from yoti_python_sandbox.doc_scan.check.sandbox_check_report import SandboxCheckReport
+from yoti_python_sandbox.doc_scan.check.sandbox_check_result import SandboxCheckResult
+from .sandbox_check import SandboxCheck
+
+
+class SandboxThirdPartyCheck(SandboxCheck):
+ def __init__(self, result, manual_check):
+ SandboxCheck.__init__(self, result)
+ self.__manual_check = manual_check
+
+ @property
+ def type(self):
+ return "THIRD_PARTY_IDENTITY"
+
+ @property
+ def manual_check(self):
+ return self.__manual_check
+
+ def to_json(self):
+ parent = SandboxCheck.to_json(self)
+ parent["type"] = self.type
+ parent["manual_check"] = self.manual_check
+
+ return parent
+
+
+class SandboxThirdPartyCheckBuilder(SandboxCheckBuilder):
+ def __init__(self):
+ SandboxCheckBuilder.__init__(self)
+ self.__manual_check = None
+
+ def with_manual_check(self, manual_check):
+ self.__manual_check = manual_check
+
+ return self
+
+ def build(self):
+ report = SandboxCheckReport(self.recommendation, self.breakdown)
+ result = SandboxCheckResult(report)
+
+ return SandboxThirdPartyCheck(result, self.__manual_check)
diff --git a/yoti_python_sandbox/doc_scan/check_reports.py b/yoti_python_sandbox/doc_scan/check_reports.py
index 5cf4727..578dbca 100644
--- a/yoti_python_sandbox/doc_scan/check_reports.py
+++ b/yoti_python_sandbox/doc_scan/check_reports.py
@@ -22,6 +22,7 @@ def __init__(
async_report_delay=None,
id_document_comparison_checks=None,
supplementary_document_text_data_checks=None,
+ third_party_check=None,
):
if document_authenticity_check is None:
document_authenticity_check = []
@@ -41,6 +42,7 @@ def __init__(
if supplementary_document_text_data_checks is None:
supplementary_document_text_data_checks = []
+ self.__third_party_check = third_party_check
self.__document_authenticity_check = document_authenticity_check
self.__document_face_match_check = document_face_match_check
self.__document_text_data_check = document_text_data_check
@@ -79,8 +81,13 @@ def id_document_comparison_checks(self):
def supplementary_document_text_data_checks(self):
return self.__supplementary_document_text_data_checks
+ @property
+ def third_party_check(self):
+ return self.__third_party_check
+
def to_json(self):
return {
+ "THIRD_PARTY_IDENTITY": self.__third_party_check,
"ID_DOCUMENT_AUTHENTICITY": self.__document_authenticity_check,
"ID_DOCUMENT_TEXT_DATA_CHECK": self.__document_text_data_check,
"ID_DOCUMENT_FACE_MATCH": self.__document_face_match_check,
@@ -97,6 +104,7 @@ def __init__(self):
self.__document_face_match_checks = []
self.__document_text_data_checks = []
self.__liveness_checks = []
+ self.__third_party_check = None
self.__async_report_delay = None
self.__id_document_comparison_check = []
self.__supplementary_document_text_data_checks = []
@@ -195,6 +203,20 @@ def with_supplementary_document_text_data_check(
)
return self
+ def with_third_party_check(self, third_party_check):
+ """
+ Add a third party check
+
+ :param third_party_check: the third party check
+ :type third_party_check: SandboxThirdPartyCheck
+ :return: the builder
+ :rtype: SandboxCheckReportsBuilder
+ """
+
+ self.__third_party_check = third_party_check
+
+ return self
+
def build(self):
return SandboxCheckReports(
self.__document_authenticity_checks,
@@ -204,4 +226,5 @@ def build(self):
self.__async_report_delay,
self.__id_document_comparison_check,
self.__supplementary_document_text_data_checks,
+ self.__third_party_check,
)
diff --git a/yoti_python_sandbox/tests/doc_scan/check/test_sandbox_third_party_check.py b/yoti_python_sandbox/tests/doc_scan/check/test_sandbox_third_party_check.py
new file mode 100644
index 0000000..df3a2ca
--- /dev/null
+++ b/yoti_python_sandbox/tests/doc_scan/check/test_sandbox_third_party_check.py
@@ -0,0 +1,31 @@
+from mock import Mock
+
+from yoti_python_sandbox.doc_scan.check import SandboxThirdPartyCheckBuilder
+from yoti_python_sandbox.doc_scan.check.report.recommendation import (
+ SandboxRecommendation,
+)
+from yoti_python_sandbox.doc_scan.check.report.breakdown import SandboxBreakdown
+
+
+def test_third_party_check_should_set_correct_manual_check_and_type():
+ check = SandboxThirdPartyCheckBuilder().with_manual_check("NEVER").build()
+
+ assert check.manual_check == "NEVER"
+ assert check.type == "THIRD_PARTY_IDENTITY"
+
+
+def test_third_party_check_build_result_object():
+ recommendation_mock = Mock(spec=SandboxRecommendation)
+ breakdown_mock = Mock(spec=SandboxBreakdown)
+
+ check = (
+ SandboxThirdPartyCheckBuilder()
+ .with_recommendation(recommendation_mock)
+ .with_breakdown(breakdown_mock)
+ .build()
+ )
+
+ assert check.result.report.recommendation is not None
+ assert check.result.report.recommendation == recommendation_mock
+ assert len(check.result.report.breakdown) == 1
+ assert check.result.report.breakdown[0] == breakdown_mock
diff --git a/yoti_python_sandbox/tests/doc_scan/test_check_reports.py b/yoti_python_sandbox/tests/doc_scan/test_check_reports.py
index c50d0e1..1ab92a6 100644
--- a/yoti_python_sandbox/tests/doc_scan/test_check_reports.py
+++ b/yoti_python_sandbox/tests/doc_scan/test_check_reports.py
@@ -1,7 +1,6 @@
from mock import Mock
from yoti_python_sandbox.doc_scan import SandboxCheckReportsBuilder
-from yoti_python_sandbox.doc_scan.check_reports import SandboxCheckReports
from yoti_python_sandbox.doc_scan.check.sandbox_document_authenticity_check import (
SandboxDocumentAuthenticityCheck,
)
@@ -11,15 +10,19 @@
from yoti_python_sandbox.doc_scan.check.sandbox_document_text_data_check import (
SandboxDocumentTextDataCheck,
)
-from yoti_python_sandbox.doc_scan.check.sandbox_liveness_check import (
- SandboxLivenessCheck,
-)
from yoti_python_sandbox.doc_scan.check.sandbox_id_document_comparison_check import (
SandboxIdDocumentComparisonCheck,
)
+from yoti_python_sandbox.doc_scan.check.sandbox_liveness_check import (
+ SandboxLivenessCheck,
+)
from yoti_python_sandbox.doc_scan.check.sandbox_supplementary_document_text_data_check import (
SandboxSupplementaryDocumentTextDataCheck,
)
+from yoti_python_sandbox.doc_scan.check.sandbox_third_party_check import (
+ SandboxThirdPartyCheck,
+)
+from yoti_python_sandbox.doc_scan.check_reports import SandboxCheckReports
def test_should_build_with_correct_properties():
@@ -31,6 +34,7 @@ def test_should_build_with_correct_properties():
supplementary_text_data_check_mock = Mock(
spec=SandboxSupplementaryDocumentTextDataCheck
)
+ third_party_check_mock = Mock(spec=SandboxThirdPartyCheck)
async_report_delay = 12
check_reports = (
@@ -41,6 +45,7 @@ def test_should_build_with_correct_properties():
.with_liveness_check(liveness_check_mock)
.with_id_document_comparison_check(comparison_check_mock)
.with_supplementary_document_text_data_check(supplementary_text_data_check_mock)
+ .with_third_party_check(third_party_check_mock)
.with_async_report_delay(async_report_delay)
.build()
)
@@ -66,6 +71,8 @@ def test_should_build_with_correct_properties():
== supplementary_text_data_check_mock
)
+ assert check_reports.third_party_check is not None
+
assert check_reports.async_report_delay == 12
@@ -78,6 +85,7 @@ def test_json_should_have_correct_properties():
supplementary_text_data_check_mock = Mock(
spec=SandboxSupplementaryDocumentTextDataCheck
)
+ third_party_check_mock = Mock(spec=SandboxThirdPartyCheck)
async_report_delay = 12
check_reports = (
@@ -88,6 +96,7 @@ def test_json_should_have_correct_properties():
.with_liveness_check(liveness_check_mock)
.with_id_document_comparison_check(comparison_check_mock)
.with_supplementary_document_text_data_check(supplementary_text_data_check_mock)
+ .with_third_party_check(third_party_check_mock)
.with_async_report_delay(async_report_delay)
.build()
)
@@ -103,6 +112,7 @@ def test_json_should_have_correct_properties():
== supplementary_text_data_check_mock
)
assert json.get("LIVENESS")[0] == liveness_check_mock
+ assert json.get("THIRD_PARTY_IDENTITY") == third_party_check_mock
assert json.get("async_report_delay") == async_report_delay
@@ -118,6 +128,7 @@ def test_json_defaults_to_empty_array_for_checks():
assert json.get("ID_DOCUMENT_COMPARISON") == []
assert json.get("SUPPLEMENTARY_DOCUMENT_TEXT_DATA_CHECK") == []
assert json.get("LIVENESS") == []
+ assert json.get("THIRD_PARTY_IDENTITY") is None
def test_async_report_delay_not_included_when_not_specified():