Skip to content

Commit

Permalink
Merge pull request #211 from nodlesh/feature/bcw-showcase-test-dev
Browse files Browse the repository at this point in the history
fix archive and add qrcode border
  • Loading branch information
nodlesh authored Nov 21, 2023
2 parents d8ccd80 + 05fbcd6 commit f7d926a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-test-harness/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
20 changes: 19 additions & 1 deletion aries-mobile-tests/agent_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

0 comments on commit f7d926a

Please sign in to comment.