diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 16928f7..95fccba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -223,7 +223,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: test-screenshots_from_main - path: aries-mobile-tests/*.png + path: ./aries-mobile-tests/*.png retention-days: 7 diff --git a/.github/workflows/run-test-harness/action.yml b/.github/workflows/run-test-harness/action.yml index fb2ad94..83d99c5 100644 --- a/.github/workflows/run-test-harness/action.yml +++ b/.github/workflows/run-test-harness/action.yml @@ -69,7 +69,7 @@ runs: uses: actions/upload-artifact@v3 with: name: test-screenshots_from_run_action - path: aries-mobile-tests/*.png + path: ./aries-mobile-tests/*.png retention-days: 7 branding: diff --git a/aries-mobile-tests/agent_factory/bc_showcase/bc_showcase_issuer_agent_interface.py b/aries-mobile-tests/agent_factory/bc_showcase/bc_showcase_issuer_agent_interface.py index 87eba6d..92385d1 100644 --- a/aries-mobile-tests/agent_factory/bc_showcase/bc_showcase_issuer_agent_interface.py +++ b/aries-mobile-tests/agent_factory/bc_showcase/bc_showcase_issuer_agent_interface.py @@ -4,6 +4,7 @@ import base64 import io from agent_factory.issuer_agent_interface import IssuerAgentInterface +from agent_test_utils import add_border_to_qr_code from sys import platform from selenium import webdriver from selenium.webdriver.chrome.service import Service @@ -100,9 +101,7 @@ def send_credential(self, actor:str, credential_offer=None, version=1, schema=No self.driver.maximize_window() self.driver.save_screenshot('connect_with_best_bc_college_page.png') qrcode = self._connect_with_best_bc_college_page.get_qr_code() - - contents = qrcode.screenshot_as_base64.encode('utf-8') - return contents.decode('utf-8') + return add_border_to_qr_code(qrcode) def revoke_credential(self, publish_immediately=True, notify_holder=False): diff --git a/aries-mobile-tests/agent_factory/bc_showcase/bc_showcase_verifier_agent_interface.py b/aries-mobile-tests/agent_factory/bc_showcase/bc_showcase_verifier_agent_interface.py index 77e7118..5976021 100644 --- a/aries-mobile-tests/agent_factory/bc_showcase/bc_showcase_verifier_agent_interface.py +++ b/aries-mobile-tests/agent_factory/bc_showcase/bc_showcase_verifier_agent_interface.py @@ -4,6 +4,7 @@ from asyncio import sleep from agent_factory.verifier_agent_interface import VerifierAgentInterface +from agent_test_utils import add_border_to_qr_code from sys import platform from selenium import webdriver from selenium.webdriver.chrome.service import Service @@ -123,8 +124,8 @@ def send_proof_request(self, actor:str, proof:str, version=1, request_for_proof= self.driver.maximize_window() qrcode = self._start_booking_the_room_page.get_qr_code() - contents = qrcode.screenshot_as_base64.encode('utf-8') - return contents.decode('utf-8') + + return add_border_to_qr_code(qrcode) def proof_success(self, proof_result): diff --git a/aries-mobile-tests/agent_test_utils.py b/aries-mobile-tests/agent_test_utils.py index 5737558..9e6d61f 100644 --- a/aries-mobile-tests/agent_test_utils.py +++ b/aries-mobile-tests/agent_test_utils.py @@ -4,7 +4,7 @@ import json import io from qrcode import QRCode -from PIL import Image +from PIL import Image, ImageOps def get_qr_code_from_invitation(invitation_json, print_qr_code=False, save_qr_code=False, qr_code_border=40): if "invitation_url" in invitation_json: @@ -174,3 +174,21 @@ def table_to_str(table): result += cell + '|' result += '\n' return result + + +def add_border_to_qr_code(qr_code_element, border_size=30): + # Take a screenshot of the QR code element + qr_code_screenshot = qr_code_element.screenshot_as_base64.encode('utf-8') + + # Convert the screenshot to an image + qr_code_image = Image.open(io.BytesIO(base64.b64decode(qr_code_screenshot))) + + # Add a border to the image + qr_code_with_border = ImageOps.expand(qr_code_image, border=border_size, fill='white') + + # Convert the modified image back to base64 + buffered = io.BytesIO() + qr_code_with_border.save(buffered, format="PNG") + qr_code_with_border_base64 = base64.b64encode(buffered.getvalue()).decode('utf-8') + + return qr_code_with_border_base64 \ No newline at end of file