diff --git a/.travis.yml b/.travis.yml index ab63218b..180a9b1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ jobs: - pip install -r requirements.txt - pip install -e .[dev] script: - - py.test -v + - pytest -v - <<: *test python: "3.4" - <<: *test diff --git a/README.md b/README.md index 37900752..9c054599 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,6 @@ How to manage users 1) [Running the examples](#running-the-examples) - How to retrieve a Yoti profile using the token -1) [Running the tests](#running-the-tests) - -Running tests for SDK example - 1) [API Coverage](#api-coverage) - Attributes defined @@ -196,14 +193,6 @@ To run the Flask or Django container: * [Profile - Flask](examples/yoti_example_flask) * [Doc Scan](examples/doc_scan) -## Running the Tests - -Running the tests is done by the following process, ensuring you are using Python 3.0+: - -1. Install dependencies: `pip install -r requirements.txt` -1. Install the SDK and development dependencies: `pip install .[dev]` -1. Execute in the main project dir: `py.test` - ## API Coverage * Activity Details diff --git a/examples/doc_scan/README.md b/examples/doc_scan/README.md index 9bb59371..0ac37ee4 100644 --- a/examples/doc_scan/README.md +++ b/examples/doc_scan/README.md @@ -5,4 +5,4 @@ 1. Rename the [.env.example](.env.example) file to `.env` and fill in the required configuration values 1. Install the dependencies with `pip install -r requirements.txt` 1. Start the server `flask run --cert=adhoc` -1. Visit `https://localhost:5000` \ No newline at end of file +1. Visit `https://localhost:5000` diff --git a/examples/doc_scan/app.py b/examples/doc_scan/app.py index 963d4140..0a862861 100644 --- a/examples/doc_scan/app.py +++ b/examples/doc_scan/app.py @@ -1,19 +1,21 @@ -import base64 -from io import BytesIO - import yoti_python_sdk -from filetype import filetype -from flask import Flask, Response, render_template, request, send_file, session +from flask import Flask, Response, render_template, request, session from yoti_python_sdk.doc_scan import ( DocScanClient, RequestedDocumentAuthenticityCheckBuilder, RequestedFaceMatchCheckBuilder, + RequestedIDDocumentComparisonCheckBuilder, RequestedLivenessCheckBuilder, RequestedTextExtractionTaskBuilder, SdkConfigBuilder, SessionSpecBuilder, ) from yoti_python_sdk.doc_scan.exception import DocScanException +from yoti_python_sdk.doc_scan.session.create.filter import ( + RequiredIdDocumentBuilder, + DocumentRestrictionBuilder, + DocumentRestrictionsFilterBuilder, +) from .settings import YOTI_APP_BASE_URL, YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH @@ -48,7 +50,11 @@ def create_session(): .with_client_session_token_ttl(600) .with_resources_ttl(90000) .with_user_tracking_id("some-user-tracking-id") - .with_requested_check(RequestedDocumentAuthenticityCheckBuilder().build()) + .with_requested_check( + RequestedDocumentAuthenticityCheckBuilder() + .with_manual_check_never() + .build() + ) .with_requested_check( RequestedLivenessCheckBuilder() .for_zoom_liveness() @@ -56,18 +62,37 @@ def create_session(): .build() ) .with_requested_check( - RequestedFaceMatchCheckBuilder().with_manual_check_fallback().build() + RequestedFaceMatchCheckBuilder().with_manual_check_never().build() ) + .with_requested_check(RequestedIDDocumentComparisonCheckBuilder().build()) .with_requested_task( - RequestedTextExtractionTaskBuilder().with_manual_check_always().build() + RequestedTextExtractionTaskBuilder() + .with_manual_check_never() + .with_chip_data_desired() + .build() ) .with_sdk_config(sdk_config) + .with_required_document(build_required_id_document_restriction("PASSPORT")) + .with_required_document( + build_required_id_document_restriction("DRIVING_LICENCE") + ) .build() ) return doc_scan_client.create_session(session_spec) +def build_required_id_document_restriction(document_type): + document_restriction = ( + DocumentRestrictionBuilder().with_document_types([document_type]).build() + ) + + filter_builder = DocumentRestrictionsFilterBuilder().for_whitelist() + filter_builder.with_document_restriction(document_restriction) + + return RequiredIdDocumentBuilder().with_filter(filter_builder.build()).build() + + @app.route("/") def index(): try: @@ -118,8 +143,6 @@ def media(): doc_scan_client = DocScanClient(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH) - base64_req = request.args.get("base64", "0") - session_id = session.get("doc_scan_session_id", None) if session_id is None: return Response("No session ID available", status=404) @@ -129,21 +152,6 @@ def media(): except DocScanException as e: return render_template("error.html", error=e.text) - if base64_req == "1" and retrieved_media.mime_type == "application/octet-stream": - decoded = base64.b64decode(retrieved_media.content) - info = filetype.guess(decoded) - - buffer = BytesIO() - buffer.write(decoded) - buffer.seek(0) - - return send_file( - buffer, - attachment_filename="media." + info.extension, - mimetype=info.mime, - as_attachment=True, - ) - return Response( retrieved_media.content, content_type=retrieved_media.mime_type, status=200 ) diff --git a/examples/doc_scan/templates/success.html b/examples/doc_scan/templates/success.html index ae3842de..646e3c5f 100644 --- a/examples/doc_scan/templates/success.html +++ b/examples/doc_scan/templates/success.html @@ -34,6 +34,12 @@
Method: {{ page.capture_method }}
-Method: {{ page.capture_method }}
+ID | -- - {{ liveness.facemap.media.id }} - - | -