Skip to content
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

test: Add OPC UA cert management unit test for delete and show #450

Merged
merged 34 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c9d9eff
delete work
Oct 28, 2024
d1e5764
Merge branch 'dev' into user/jiacju/cert_manage_deletelist
Oct 31, 2024
2e351ab
delete something is working
Nov 2, 2024
666df2b
adding show
Nov 4, 2024
8685ef0
adding force
Nov 4, 2024
89768e6
address feedback
Nov 5, 2024
a9b24eb
Merge branch 'feature/1.0.0' into user/jiacju/cert_manage_deletelist
Nov 5, 2024
b058172
working
Nov 6, 2024
b5eb983
fix merge
Nov 6, 2024
7ce6b53
clean up and working
Nov 6, 2024
46716f1
test fix
Nov 6, 2024
4ca5b39
update
Nov 6, 2024
920390f
Merge branch 'feature/1.0.0' into user/jiacju/cert_manage_deletelist
Elsie4ever Nov 6, 2024
d8c5303
add preview
Nov 6, 2024
2560d57
fix
Nov 7, 2024
3bf9227
initiate test
Nov 8, 2024
6c9266a
small change
Nov 8, 2024
bcbb5be
Merge branch 'user/jiacju/cert_manage_deletelist' into user/jiacju/ce…
Nov 8, 2024
7df0d17
test
Nov 8, 2024
5beafb4
address comment
Nov 8, 2024
a80cee4
Merge branch 'user/jiacju/cert_manage_deletelist' into user/jiacju/ce…
Nov 8, 2024
539c4b5
cert remove test
Nov 8, 2024
5b2a11f
merge latest
Nov 11, 2024
6a5e904
fix merge and add show test
Nov 11, 2024
df00be5
trust and issuer test working
Nov 12, 2024
e7a47f5
all tests work, need clean up
Nov 12, 2024
2a60815
update test
Nov 12, 2024
b7f9cc7
update
Nov 12, 2024
8781139
update
Nov 12, 2024
f652508
Merge branch 'feature/1.0.0' into user/jiacju/cert_tests
Elsie4ever Nov 12, 2024
33993fa
update
Nov 12, 2024
0fb7c3c
Merge branch 'user/jiacju/cert_tests' of https://github.com/Elsie4eve…
Nov 12, 2024
670e983
common
Nov 12, 2024
5ea2727
address comment
Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ def mocked_logger(mocker):
yield patched


@pytest.fixture
def mocked_get_resource_client(mocker):
patched = mocker.patch("azext_edge.edge.util.queryable")
yield patched().get_resource_client


@pytest.fixture
def mocked_instance(mocker):
patched = mocker.patch(
Expand All @@ -42,6 +36,30 @@ def mocked_sleep(mocker):
yield patched


@pytest.fixture
def mocked_cl_resources(mocker):
patched = mocker.patch(
"azext_edge.edge.providers.orchestration.resources.connector.opcua.certs.OpcUACerts._get_cl_resources",
)
yield patched


@pytest.fixture
def mocked_read_file_content(mocker):
patched = mocker.patch(
"azext_edge.edge.providers.orchestration.resources.connector.opcua.certs.read_file_content",
)
yield patched


@pytest.fixture
def mocked_get_resource_client(mocker):
patched = mocker.patch(
"azext_edge.edge.util.queryable.get_resource_client",
)
yield patched


def get_spc_endpoint(spc_name: str, resource_group_name: str) -> str:
resource_path = "/azureKeyVaultSecretProviderClasses"
if spc_name:
Expand All @@ -66,8 +84,12 @@ def get_secretsync_endpoint(secretsync_name: str, resource_group_name: str) -> s
)


def get_secret_endpoint(keyvault_name: str, secret_name: Optional[str] = None) -> str:
resource_path = "/secrets"
def get_secret_endpoint(
keyvault_name: str,
deleted: bool = False,
secret_name: Optional[str] = None,
) -> str:
resource_path = "/deletedsecrets" if deleted else "/secrets"
if secret_name:
resource_path += f"/{secret_name}"

Expand All @@ -91,7 +113,7 @@ def get_mock_spc_record(spc_name: str, resource_group_name: str, objects: Option
)


def get_mock_secretsync_record(secretsync_name: str, resource_group_name: str, objects: Optional[str] = None) -> dict:
def get_mock_secretsync_record(secretsync_name: str, resource_group_name: str, objects: Optional[dict] = None) -> dict:
objects = objects or []
return get_mock_resource(
name=secretsync_name,
Expand Down Expand Up @@ -172,10 +194,16 @@ def setup_mock_common_responses(
def assemble_resource_map_mock(
resource_map_mock: Mock,
extension: Optional[dict],
custom_locations: Optional[List[dict]],
resources: Optional[List[dict]],
):
resource_map_mock().custom_locations = custom_locations
resource_map_mock().get_resources.return_value = resources
resource_map_mock().connected_cluster.get_extensions_by_type.return_value = extension
resource_map_mock().connected_cluster.get_aio_resources.return_value = resources


def generate_fortos_object_string(
Elsie4ever marked this conversation as resolved.
Show resolved Hide resolved
names: List[str]
):
object_string = "array:\n"
for name in names:
object_string += f" - |\n objectEncoding: hex\n objectName: {name}\n objectType: secret\n"
return object_string
Loading