-
Notifications
You must be signed in to change notification settings - Fork 930
feat(application): add license notification #3553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ashwinvaidya17
wants to merge
10
commits into
open-edge-platform:main
Choose a base branch
from
ashwinvaidya17:ashwin/feat/license_acceptance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d46908
Add license provider
ashwinvaidya17 482ff1a
remove close button
ashwinvaidya17 1a3396d
run format checks
ashwinvaidya17 9ab1774
address github-advanced-security issue
ashwinvaidya17 4446151
Address copilot comments
ashwinvaidya17 c650161
simplify license
ashwinvaidya17 d29d852
remove array + version
ashwinvaidya17 3bffe8c
remove enum
ashwinvaidya17 ecdcdab
undo docstring changes
ashwinvaidya17 71fdff8
Merge branch 'main' into ashwin/feat/license_acceptance
ashwinvaidya17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Copyright (C) 2026 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from unittest.mock import AsyncMock, MagicMock | ||
|
|
||
| import pytest | ||
| from fastapi import status | ||
|
|
||
| from api.dependencies.dependencies import get_system_service | ||
| from main import app | ||
| from pydantic_models.system import DeploymentType, LicenseAcceptanceResponse, LicenseReference, LicenseStatus | ||
| from services import SystemService | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def fxt_system_service() -> MagicMock: | ||
| system_service = MagicMock(spec=SystemService) | ||
| system_service.get_license_status = AsyncMock( | ||
| return_value=LicenseStatus( | ||
| accepted=False, | ||
| accepted_version=None, | ||
| app_version="1.2.3", | ||
| deployment_type=DeploymentType.DOCKER, | ||
| licenses=[ | ||
| LicenseReference( | ||
| name="Apache 2.0 License", | ||
| url="https://www.apache.org/licenses/LICENSE-2.0", | ||
| required_for="Docker and development deployments", | ||
| ), | ||
| ], | ||
| ), | ||
| ) | ||
| system_service.accept_licenses = AsyncMock( | ||
| return_value=LicenseAcceptanceResponse(accepted=True, accepted_version="1.2.3"), | ||
| ) | ||
| app.dependency_overrides[get_system_service] = lambda: system_service | ||
| return system_service | ||
|
|
||
|
|
||
| def test_get_license_status(fxt_client, fxt_system_service): | ||
| response = fxt_client.get("/api/system/license") | ||
|
|
||
| assert response.status_code == status.HTTP_200_OK | ||
| assert response.json()["accepted"] is False | ||
| assert response.json()["app_version"] == "1.2.3" | ||
| fxt_system_service.get_license_status.assert_awaited_once() | ||
|
|
||
|
|
||
| def test_accept_license(fxt_client, fxt_system_service): | ||
| response = fxt_client.post("/api/system/license:accept") | ||
|
|
||
| assert response.status_code == status.HTTP_200_OK | ||
| assert response.json() == {"accepted": True, "accepted_version": "1.2.3"} | ||
| fxt_system_service.accept_licenses.assert_awaited_once() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.