Skip to content

Commit

Permalink
Modify base tests for real module cases
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismeyersfsu committed Aug 28, 2024
1 parent 61f373d commit 803a090
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ relative_files = true
source =
tests
source_pkgs =
awx_plugins.credentials.x.api
awx_plugins.credentials
7 changes: 7 additions & 0 deletions dependencies/direct/py.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
-c py-constraints.in # limits known broken versions

azure-identity # credentials.azure_kv
azure-keyvault # credentials.azure_kv
boto3 # credentials.awx_secretsmanager
covdefaults
coverage # accessed directly from tox
coverage-enable-subprocess
msrestazure # credentials.azure_kv
pytest
pytest-cov
python-dsv-sdk >= 1.0.4 # credentials.thycotic_dsv
python-tss-sdk >= 1.2.1 # credentials.thycotic_tss
pytest-xdist
requests # credentials.aim, credentials.centrify_vault, credentials.conjur, credentials.hashivault
5 changes: 0 additions & 5 deletions src/awx_plugins/credentials/x/api.py

This file was deleted.

33 changes: 29 additions & 4 deletions tests/importable_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Smoke tests related to loading entry points."""

from importlib.metadata import entry_points as _discover_entry_points
from subprocess import check_call as _invoke_command
from sys import executable as _current_runtime

import pytest


@pytest.mark.parametrize(
'entry_points_group',
(
'awx.credential_plugins',
'awx_plugins.credentials',
),
)
Expand All @@ -19,8 +20,32 @@ def test_entry_points_exposed(entry_points_group: str) -> None:
pre-installed.
"""
entry_points = _discover_entry_points(group=entry_points_group)
assert 'x' in entry_points.names
expected_entry_points = {
'aim': 'aim_plugin',
'conjur': 'conjur_plugin',
'hashivault_kv': 'hashivault_kv_plugin',
'hashivault_ssh': 'hashivault_ssh_plugin',
'azure_kv': 'azure_keyvault_plugin',
'centrify_vault_kv': 'centrify_plugin',
'thycotic_dsv': 'dsv_plugin',
'thycotic_tss': 'tss_plugin',
'aws_secretsmanager_credential': 'aws_secretmanager_plugin',
}
for x in expected_entry_points.keys():
assert x in entry_points.names

assert entry_points['x'].value == 'awx_plugins.credentials.x.api:XPlugin'
for k, v in expected_entry_points.items():
callable_ref_spec = entry_points[k].value
import_ref, callable_sep, callable_ref = callable_ref_spec.partition(
':')
assert callable_sep
assert v == str(callable_ref)

assert callable(entry_points['x'].load())
test_is_importable_callable_cmd = (
_current_runtime,
'-c',
f'from sys import exit; '
f'from {import_ref} import {callable_ref}; '
f'exit(not type({callable_ref}).__name__ == "CredentialPlugin")',
)
_invoke_command(test_is_importable_callable_cmd)

0 comments on commit 803a090

Please sign in to comment.