From 96627a8ec093fa0d6f8aaa3fb769313aabffcfc2 Mon Sep 17 00:00:00 2001 From: Anindya Roy Date: Thu, 25 Jul 2024 12:19:34 +0530 Subject: [PATCH] NXDRIVE-2889: Display system notification for document review -added testcase for EngineModel --- .github/workflows/release.yml | 98 +++++++++++++++++++++++++++++++++++ tests/unit/test_view.py | 44 +++++++++++++++- 2 files changed, 141 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 396b8eda9e..269c7475d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -150,8 +150,106 @@ jobs: SYSTEM_VERSION_COMPAT: 0 run: bash tools/osx/deploy_ci_agent.sh --check-upgrade + # + # Windows + # + - name: "[Windows] Unlock PowerShell" + if: matrix.os == 'windows-latest' + run: powershell Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine + + - name: "[Windows] Setup the environment" + if: matrix.os == 'windows-latest' + run: powershell ".\\tools\\windows\\deploy_ci_agent.ps1" -install_release + + - name: Setup Certificate + if: matrix.os == 'windows-latest' + run: | + echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12 + cat /d/Certificate_pkcs12.p12 + shell: bash + + - name: Set variables + if: matrix.os == 'windows-latest' + id: variables + run: | + dir + echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + echo "KEYPAIR_NAME=gt-standard-keypair" >> $GITHUB_OUTPUT + echo "CERTIFICATE_NAME=gt-certificate" >> $GITHUB_OUTPUT + echo "SM_HOST=${{ secrets.SM_HOST }}" >> "$GITHUB_ENV" + echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> "$GITHUB_ENV" + echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_ENV" + echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV" + echo "SM_KEYPAIR_ALIAS=${{ secrets.SM_KEYPAIR_ALIAS }}" >> "$GITHUB_ENV" + echo "SM_CODE_SIGNING_CERT_SHA1_HASH=${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}" >> "$GITHUB_ENV" + echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH + echo "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools" >> $GITHUB_PATH + echo "C:\Program Files\DigiCert\DigiCert Keylocker Tools" >> $GITHUB_PATH + shell: bash + + - name: Setup Keylocker KSP on windows + if: matrix.os == 'windows-latest' + run: | + curl -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/Keylockertools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o Keylockertools-windows-x64.msi + msiexec /i Keylockertools-windows-x64.msi /quiet /qn + smksp_registrar.exe list + smctl.exe keypair ls + C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user + shell: cmd + + - name: Certificates Sync + if: matrix.os == 'windows-latest' + run: | + smctl windows certsync --keypair-alias=${{ secrets.SM_KEYPAIR_ALIAS }} + shell: cmd + + - name: Health status + if: matrix.os == 'windows-latest' + run: | + smctl healthcheck + shell: cmd + - name: "[Windows] Generate the .exe and validate against 2021" + timeout-minutes: 15 + if: matrix.os == 'windows-latest' + env: + KEYCHAIN_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }} + NXDRIVE_TEST_NUXEO_URL: "https://drive-2021.beta.nuxeocloud.com/nuxeo" + SIGNING_ID: "Nuxeo" + SIGNTOOL_PATH: 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.20348.0\x86' + run: powershell ".\\tools\\windows\\deploy_ci_agent.ps1" -check_upgrade + + - name: "[Windows] Generate the .exe and validate against 2023" + timeout-minutes: 15 + if: matrix.os == 'windows-latest' + env: + NXDRIVE_TEST_NUXEO_URL: "https://drive-2023.beta.nuxeocloud.com/nuxeo" + NXDRIVE_TEST_USERNAME: ${{ secrets.NXDRIVE_2023_TEST_USERNAME }} + NXDRIVE_TEST_PASSWORD: ${{ secrets.NXDRIVE_2023_TEST_PASSWORD }} + SIGNING_ID: "Nuxeo" + SIGNTOOL_PATH: 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.20348.0\x86' + run: powershell ".\\tools\\windows\\deploy_ci_agent.ps1" -check_upgrade + + - name: "[Windows] Generate and sign the .exe" + timeout-minutes: 15 + if: matrix.os == 'windows-latest' && github.event.inputs.signExe == 'true' + env: + KEYCHAIN_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }} + SIGNING_ID_NEW: "Hyland Software, Inc." + SIGNTOOL_PATH: 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.20348.0\x86' + run: powershell ".\\tools\\windows\\deploy_ci_agent.ps1" -build_installer_and_sign + + - name: "Upload artifacts" + uses: actions/upload-artifact@v4 + with: + name: package-distributions-${{ matrix.os }} + path: | + ./dist/*.exe + ./dist/*.dmg + ./dist/*.AppImage + if-no-files-found: error + deploy: runs-on: ubuntu-latest needs: [release] diff --git a/tests/unit/test_view.py b/tests/unit/test_view.py index 076d3ad335..d02e92247d 100644 --- a/tests/unit/test_view.py +++ b/tests/unit/test_view.py @@ -2,7 +2,11 @@ from typing import Any, List from unittest.mock import Mock -from nxdrive.gui.view import FileModel, TasksModel +import pytest + +from nxdrive.client.workflow import Workflow +from nxdrive.gui.application import Application +from nxdrive.gui.view import EngineModel, FileModel, TasksModel from nxdrive.qt.imports import QModelIndex from nxdrive.translator import Translator from nxdrive.utils import find_resource @@ -79,3 +83,41 @@ def translate(message: str, /, *, values: List[Any] = None) -> str: dummy_task_list = [dummy_task2] assert not tasks_model.loadList(dummy_task_list, "Administrator") + + +@pytest.fixture() +def workflow(): + return Workflow() + + +@pytest.fixture() +def application(manager_factory, workflow): + manager = manager_factory() + application = Mock(spec=Application) + application.manager = manager + application._init_translator = Mock() + application.setWindowIcon = Mock() + application.setApplicationName = Mock() + application.setQuitOnLastWindowClosed = Mock() + application.show_metrics_acceptance = Mock() + application.init_checks = Mock() + application._setup_notification_center = Mock() + application.workflow = workflow + + return application + + +def test_engine_model(): + application_ = application + application_.api = Mock() + application_.update_workflow = Mock() + application_.update_workflow_user_engine_list = Mock() + application_.manager = Mock() + application_.manager.engines = {"dummy_uid": "dummy_engine"} + engine_model = EngineModel(application_) + engine_model.beginInsertRows = Mock() + engine_model.endInsertRows = Mock() + engine_model._connect_engine = Mock() + engine_model.removeRows = Mock() + assert not engine_model.addEngine("dummy_uid") + assert not engine_model.removeEngine("dummy_uid")