nac-test-pyats-common
⚠️ INITIAL DEVELOPMENT: This package is under active initial development and not yet ready for production use.
A shared library consolidating duplicated PyATS testing infrastructure across NAC (Network as Code) architecture repositories. This package serves as a Layer 2 adapter between architecture-specific test repositories (ACI, SD-WAN, Catalyst Center) and the core nac-test framework.
Overview
The nac-test-pyats-common package addresses the architectural challenge of duplicated pyats_common/ directories across NAC architecture repositories. It consolidates shared PyATS testing infrastructure—including authentication classes, test base classes, and device resolvers—into a centralized, maintainable package.
Problem Solved
Each NAC architecture repository previously contained duplicated PyATS infrastructure code:
- ~90% of base test class code was identical across architectures
- Bug fixes and improvements required manual propagation to all repos
- Each architecture team maintained essentially the same code
- Adding new architectures (ISE, Meraki, IOS-XE) compounded the duplication problem
Solution Architecture
┌─────────────────────────────────────────────────────────────────────┐
│ Layer 3: Architecture Repositories │
│ (nac-aci-terraform, nac-sdwan-terraform, nac-catc-terraform) │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Test Files │ │ NAC Schema │ │
│ │ (verify_*.py) │ │ Definitions │ │
│ └────────┬────────┘ └─────────────────┘ │
│ │ │
│ │ imports │
│ ▼ │
└───────────┼──────────────────────────────────────────────────────────┘
│
┌───────────▼──────────────────────────────────────────────────────────┐
│ Layer 2: nac-test-pyats-common (Architecture Adapters) │
│ DEPENDS ON nac-test │
│ │
│ • Architecture-specific authentication (APICAuth, VManageAuth) │
│ • Architecture-specific test base classes (APICTestBase, etc.) │
│ • Architecture-specific device resolvers (SDWANDeviceResolver) │
│ │ │
│ │ imports NACTestBase, SSHTestBase, AuthCache │
│ ▼ │
└───────────────────────┼──────────────────────────────────────────────┘
│
┌───────────────────────▼──────────────────────────────────────────────┐
│ Layer 1: nac-test (Core Framework) │
│ Orchestration + Generic Infrastructure │
│ │
│ • Test orchestration (discovering tests, running them) │
│ • Testbed generation (generic device dict → PyATS YAML) │
│ • Connection brokering (SSH connection pooling) │
│ • HTML report generation │
│ • Generic base classes (NACTestBase, SSHTestBase) │
└─────────────────────────────────────────────────────────────────────┘
Supported Architectures
Currently Supported
-
ACI (Application Centric Infrastructure)
APICAuth- APIC authentication with cookie-based sessionsAPICTestBase- Base class for ACI/APIC testsACIDeviceResolver- Device inventory from ACI data models
-
SD-WAN
VManageAuth- vManage authentication with token-based sessionsVManageTestBase- Base class for vManage API testsSDWANSSHTestBase- Base class for SD-WAN D2D/SSH testsSDWANDeviceResolver- Device inventory from sites.nac.yaml
-
Catalyst Center
CatalystCenterAuth- Token-based authentication (X-Auth-Token)CatalystCenterTestBase- Base class for Catalyst Center API testsCatalystCenterDeviceResolver- Device inventory from NAC schemas
Planned Support
- ISE (Identity Services Engine)
- Meraki
- IOS-XE (Direct device access)
Installation
Python 3.10+ is required. Don't have Python 3.10 or later? See Python 3 Installation & Setup Guide.
pip install nac-test-pyats-common
This will automatically install the required dependencies:
nac-test~=1.1.0- Core testing framework (brings PyATS as transitive dependency)httpx>=0.28- HTTP client for authentication
Usage
Import Pattern
Replace the old fragile imports from architecture repos:
# Old pattern (remove this)
from templates.catc.test.pyats_common.catc_base_test import CatalystCenterTestBase
# New pattern (use this)
from nac_test_pyats_common.catc import CatalystCenterTestBase
Example Test File
# In nac-catalystcenter-terraform/tests/templates/catc/test/api/verify_something.py
from nac_test_pyats_common.catc import CatalystCenterTestBase
from nac_test.pyats_core.reporting.types import ResultStatus
from pyats import aetest
class TestCatalystCenterFeature(CatalystCenterTestBase):
"""Test class for Catalyst Center feature verification."""
@aetest.test
def verify_feature(self):
"""Verify feature configuration."""
# self.client is already configured with auth headers
response = self.client.get("/api/v1/feature")
if response.status_code == 200:
self.result = ResultStatus.PASS
else:
self.result = ResultStatus.FAIL
API Structure
Authentication Classes
Each architecture provides an authentication class that handles controller-specific authentication:
from nac_test_pyats_common.aci import APICAuth
from nac_test_pyats_common.sdwan import VManageAuth
from nac_test_pyats_common.catc import CatalystCenterAuth
# Authentication is handled automatically when using test base classes
# But can be used directly if needed:
auth_data = CatalystCenterAuth.get_auth() # Uses AuthCache internally
Test Base Classes
Test base classes extend NACTestBase from nac-test with architecture-specific setup:
from nac_test_pyats_common.catc import CatalystCenterTestBase
class MyTest(CatalystCenterTestBase):
"""Your test class."""
@aetest.setup
def setup(self):
"""Setup is handled by base class."""
super().setup()
# self.client is now available with auth headers configured
# self.auth_data contains authentication tokens/cookies
Device Resolvers
Device resolvers parse NAC schemas to provide device inventory for SSH tests:
from nac_test_pyats_common.sdwan import SDWANDeviceResolver
# Used by nac-test orchestrator internally
devices = SDWANDeviceResolver.get_ssh_device_inventory(data_model)
Environment Variables
Each architecture requires specific environment variables for authentication:
Catalyst Center
CC_URL- Controller URLCC_USERNAME- UsernameCC_PASSWORD- PasswordCC_INSECURE- Skip SSL verification (optional, default: "True")
SD-WAN
VMANAGE_URL- vManage URLVMANAGE_USERNAME- UsernameVMANAGE_PASSWORD- PasswordVMANAGE_INSECURE- Skip SSL verification (optional, default: "True")
ACI
APIC_URL- APIC URLAPIC_USERNAME- UsernameAPIC_PASSWORD- PasswordAPIC_INSECURE- Skip SSL verification (optional, default: "True")
Development
Local Development Setup
# Clone the repository
git clone https://github.com/netascode/nac-test-pyats-common.git
cd nac-test-pyats-common
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/unit/ -v
pytest tests/integration/ -v # Requires nac-test
# Type checking
mypy --strict src/
# Linting
ruff check src/
Contributing
When contributing, understand which repository to modify:
| Change Type | Repository | Example |
|---|---|---|
| Auth endpoint change | nac-test-pyats-common | Catalyst Center adds new auth API |
| Test base setup logic | nac-test-pyats-common | Add new setup step for all CC tests |
| Generic orchestration | nac-test | Change how tests are discovered/run |
| HTML report format | nac-test | Modify report template |
| Test file (verify_*.py) | Architecture repo | Add new verification test |
Dependencies
nac-test~=1.1.0- Core testing framework- Provides:
NACTestBase,SSHTestBase,AuthCache, orchestration - Brings PyATS as transitive dependency
- Provides:
httpx>=0.28- Modern async-capable HTTP client
Versioning
This package follows Semantic Versioning 2.0.0:
- MAJOR: Breaking API changes
- MINOR: New features, backward compatible
- PATCH: Bug fixes, backward compatible
Compatibility Matrix
| nac-test-pyats-common | nac-test Required | Notes |
|---|---|---|
| 1.0.x | ~=1.1.0 | Initial release |
| 1.1.x | ~=1.1.0 | New architecture added |
| 2.0.x | ~=2.0.0 | Breaking changes |
License
This project is licensed under the Mozilla Public License 2.0 (MPL-2.0) - see the LICENSE file for details.
Support
For issues, questions, or contributions, please visit the GitHub repository.
Metadata
Release files for nac-test-pyats-common 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nac_test_pyats_common-0.3.0.tar.gz | 56.4 kB | Without provenance | Details for nac_test_pyats_common-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nac_test_pyats_common-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for nac_test_pyats_common-0.3.0-py3-none-any.whl |
Total release size: 112.2 kB
Release files / nac_test_pyats_common-0.3.0.tar.gz
| Download URL | nac_test_pyats_common-0.3.0.tar.gz |
|---|---|
| Size | 56.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a53d1bb12e247c832efe66945a7042ef4e1e33b8d5276afb375ad91f227b8748
|
|
BLAKE2b-256 checksum How to use checksums |
baaffa4ea391ebb43feb108bf39e008268815b19c24bece741d098349ec034c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / nac_test_pyats_common-0.3.0-py3-none-any.whl
| Download URL | nac_test_pyats_common-0.3.0-py3-none-any.whl |
|---|---|
| Size | 55.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20f67cf19a100258b3e66af1196e5c8cfc98d9b726d8770d3065084c4a450ee6
|
|
BLAKE2b-256 checksum How to use checksums |
e3c4157014d4b67de1598b1bc6533f6e71807d710a2ecc1758b95d7a13d4bbca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for nac-test-pyats-common 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.