Skip to content

Commit 3e6d670

Browse files
committed
Docs: Improve setup for test environments
1 parent b489cdc commit 3e6d670

3 files changed

Lines changed: 259 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Active Directory Test Environment
2+
3+
Helper scripts for setting up Active Directory test data for NETworkManager.
4+
5+
## Scripts
6+
7+
### `Create-TestAdComputers.ps1`
8+
9+
Creates computer accounts in Active Directory to test NETworkManager's **AD profile import** feature (import of computer accounts as connection profiles).
10+
11+
#### Requirements
12+
13+
- Windows with the **ActiveDirectory** PowerShell module (RSAT)
14+
- Domain-joined machine with write permissions to the target OU
15+
16+
Install RSAT if missing:
17+
18+
```powershell
19+
Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
20+
```
21+
22+
#### Parameters
23+
24+
| Parameter | Default | Description |
25+
| --------------- | ------------------------------------- | ---------------------------------------------------------------------------- |
26+
| `-OUPath` | Domain's built-in Computers container | Distinguished name of the target OU |
27+
| `-Count` | `25` | Number of computer accounts to create |
28+
| `-NamePrefix` | `NM-TEST-` | Name prefix for computer accounts |
29+
| `-DnsZone` | AD domain DNS root | DNS zone appended to the computer name to build `dnsHostName` |
30+
| `-CreateOU` | _(switch)_ | Create the target OU if it does not exist |
31+
| `-DisableEvery` | `0` _(never)_ | Disable every Nth account — useful for testing the "exclude disabled" filter |
32+
33+
#### Examples
34+
35+
Create 25 computers in the default Computers container:
36+
37+
```powershell
38+
.\Create-TestAdComputers.ps1
39+
```
40+
41+
Create 50 computers in a custom OU (creates the OU if missing), disable every 5th:
42+
43+
```powershell
44+
.\Create-TestAdComputers.ps1 `
45+
-OUPath "OU=NetworkManagerTest,DC=lab,DC=local" `
46+
-Count 50 `
47+
-CreateOU `
48+
-DisableEvery 5
49+
```
50+
51+
Preview changes without applying them (`-WhatIf`):
52+
53+
```powershell
54+
.\Create-TestAdComputers.ps1 -OUPath "OU=NM,DC=lab,DC=local" -Count 10 -WhatIf
55+
```
56+
57+
#### Idempotency
58+
59+
The script skips accounts that already exist and reports them as `[skip]`. Re-running it is safe.

Tests/Environments/SNMP/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# SNMP Test Environment
2+
3+
A minimal, self-contained SNMP test environment running on Linux (Debian/Ubuntu) to test NETworkManager's SNMP features.
4+
5+
> **Warning:** This configuration is intentionally insecure. Use in isolated test environments only, never in production.
6+
7+
## Requirements
8+
9+
- Debian / Ubuntu (tested on Ubuntu 22.04+)
10+
- Root / `sudo` access
11+
12+
## Setup
13+
14+
Run the setup script to install and configure the SNMP daemon:
15+
16+
```bash
17+
sudo bash setup.sh
18+
```
19+
20+
The script is idempotent — re-running it overwrites the configuration and resets the SNMPv3 credentials.
21+
22+
To customise community strings or credentials, edit the variables at the top of `setup.sh` before running.
23+
24+
## Default credentials
25+
26+
| Protocol | Setting | Value |
27+
| ------------------- | ------------- | ---------------- |
28+
| SNMPv2c | Community | `public` |
29+
| SNMPv3 noAuthNoPriv | Username | `noAuthUser` |
30+
| SNMPv3 authNoPriv | Username | `authNoPrivUser` |
31+
| SNMPv3 authNoPriv | Auth protocol | SHA-512 |
32+
| SNMPv3 authNoPriv | Auth password | `auth123456789` |
33+
| SNMPv3 authPriv | Username | `authPrivUser` |
34+
| SNMPv3 authPriv | Auth protocol | SHA-512 |
35+
| SNMPv3 authPriv | Auth password | `auth123456789` |
36+
| SNMPv3 authPriv | Priv protocol | AES |
37+
| SNMPv3 authPriv | Priv password | `priv987654321` |
38+
39+
## Accessible OIDs
40+
41+
The `systemonly` view restricts access to:
42+
43+
| OID prefix | Description |
44+
| ------------------- | ---------------------------------------------- |
45+
| `.1.3.6.1.2.1.1` | System group (sysDescr, sysName, sysUpTime, …) |
46+
| `.1.3.6.1.2.1.25.1` | Host resources — hrSystem group |
47+
48+
## Ports
49+
50+
The daemon listens on UDP port **161** for both IPv4 (`udp:161`) and IPv6 (`udp6:161`).
51+
52+
## Verifying the setup
53+
54+
```bash
55+
# SNMPv2c
56+
snmpwalk -v2c -c public localhost .1.3.6.1.2.1.1
57+
58+
# SNMPv3 – noAuthNoPriv
59+
snmpwalk -v3 -l noAuthNoPriv -u noAuthUser localhost .1.3.6.1.2.1.1
60+
61+
# SNMPv3 – authNoPriv
62+
snmpwalk -v3 -l authNoPriv -u authNoPrivUser \
63+
-a SHA-512 -A auth123456789 \
64+
localhost .1.3.6.1.2.1.1
65+
66+
# SNMPv3 – authPriv
67+
snmpwalk -v3 -l authPriv -u authPrivUser \
68+
-a SHA-512 -A auth123456789 \
69+
-x AES -X priv987654321 \
70+
localhost .1.3.6.1.2.1.1
71+
```
72+
73+
## Additional configuration
74+
75+
Drop extra `.conf` files into `/etc/snmp/snmpd.conf.d/` — they are included automatically by the daemon.

Tests/Environments/SNMP/setup.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/usr/bin/env bash
2+
# Sets up a minimal, insecure SNMP test environment on Debian/Ubuntu.
3+
# Idempotent: safe to re-run; resets configuration and SNMPv3 credentials each time.
4+
set -euo pipefail
5+
6+
# ------------------------------------------------------------------------------
7+
# Configuration — adjust to your needs
8+
# ------------------------------------------------------------------------------
9+
SYS_LOCATION="Testserver"
10+
SYS_CONTACT="Test <test@borntoberoot.net>"
11+
12+
V2C_COMMUNITY="public"
13+
14+
V3_NOAUTH_USER="noAuthUser"
15+
16+
V3_AUTH_USER="authNoPrivUser"
17+
V3_AUTH_PROTOCOL="SHA-512" # MD5 | SHA | SHA-224 | SHA-256 | SHA-384 | SHA-512
18+
V3_AUTH_PASSWORD="auth123456789"
19+
20+
V3_AUTHPRIV_USER="authPrivUser"
21+
V3_PRIV_PROTOCOL="AES" # DES | AES
22+
V3_PRIV_PASSWORD="priv987654321"
23+
# ------------------------------------------------------------------------------
24+
25+
SNMPD_CONF="/etc/snmp/snmpd.conf"
26+
SNMPD_PERSIST="/var/lib/snmp/snmpd.conf"
27+
SNMPD_CONF_D="/etc/snmp/snmpd.conf.d"
28+
29+
if [[ $EUID -ne 0 ]]; then
30+
echo "ERROR: Run as root or with sudo." >&2
31+
exit 1
32+
fi
33+
34+
echo "==> Installing packages..."
35+
apt-get update -y -qq
36+
apt-get install -y -qq snmp snmpd
37+
38+
echo "==> Stopping snmpd..."
39+
systemctl stop snmpd 2>/dev/null || true
40+
41+
# snmpd moves 'createUser' entries into /var/lib/snmp/snmpd.conf on first start
42+
# and removes them from the main config. Remove the persisted user so snmpd
43+
# re-creates it from our config on the next start (idempotency).
44+
echo "==> Resetting SNMPv3 credentials from persistent store..."
45+
if [[ -f "$SNMPD_PERSIST" ]]; then
46+
sed -i "/usmUser.*\"$V3_NOAUTH_USER\"/d" "$SNMPD_PERSIST"
47+
sed -i "/usmUser.*\"$V3_AUTH_USER\"/d" "$SNMPD_PERSIST"
48+
sed -i "/usmUser.*\"$V3_AUTHPRIV_USER\"/d" "$SNMPD_PERSIST"
49+
fi
50+
51+
echo "==> Writing $SNMPD_CONF..."
52+
cat > "$SNMPD_CONF" << EOF
53+
sysLocation $SYS_LOCATION
54+
sysContact $SYS_CONTACT
55+
sysServices 72
56+
57+
master agentx
58+
59+
agentaddress udp:161,udp6:161
60+
61+
view systemonly included .1.3.6.1.2.1.1
62+
view systemonly included .1.3.6.1.2.1.25.1
63+
64+
# v2c
65+
rocommunity $V2C_COMMUNITY default -V systemonly
66+
rocommunity6 $V2C_COMMUNITY default -V systemonly
67+
68+
# v3 – noAuthNoPriv (no authentication, no encryption)
69+
createUser $V3_NOAUTH_USER
70+
rouser $V3_NOAUTH_USER noauth -V systemonly
71+
72+
# v3 – authNoPriv (authentication, no encryption)
73+
createUser $V3_AUTH_USER $V3_AUTH_PROTOCOL $V3_AUTH_PASSWORD
74+
rouser $V3_AUTH_USER auth -V systemonly
75+
76+
# v3 – authPriv (authentication and encryption)
77+
createUser $V3_AUTHPRIV_USER $V3_AUTH_PROTOCOL $V3_AUTH_PASSWORD $V3_PRIV_PROTOCOL $V3_PRIV_PASSWORD
78+
rouser $V3_AUTHPRIV_USER authpriv -V systemonly
79+
80+
# include all *.conf files in a directory
81+
includeDir $SNMPD_CONF_D
82+
EOF
83+
chmod 600 "$SNMPD_CONF"
84+
85+
echo "==> Creating $SNMPD_CONF_D (for optional extra config files)..."
86+
mkdir -p "$SNMPD_CONF_D"
87+
88+
echo "==> Enabling and starting snmpd..."
89+
systemctl enable --quiet snmpd
90+
systemctl start snmpd
91+
92+
echo ""
93+
if systemctl is-active --quiet snmpd; then
94+
echo "snmpd is running."
95+
else
96+
echo "WARNING: snmpd did not start. Check 'journalctl -u snmpd' for details." >&2
97+
exit 1
98+
fi
99+
100+
echo ""
101+
echo "Setup complete. Credentials:"
102+
echo ""
103+
echo " SNMPv2c"
104+
echo " Community string : $V2C_COMMUNITY"
105+
echo ""
106+
echo " SNMPv3 – noAuthNoPriv"
107+
echo " Username : $V3_NOAUTH_USER"
108+
echo ""
109+
echo " SNMPv3 – authNoPriv"
110+
echo " Username : $V3_AUTH_USER"
111+
echo " Auth protocol : $V3_AUTH_PROTOCOL"
112+
echo " Auth password : $V3_AUTH_PASSWORD"
113+
echo ""
114+
echo " SNMPv3 – authPriv"
115+
echo " Username : $V3_AUTHPRIV_USER"
116+
echo " Auth protocol : $V3_AUTH_PROTOCOL"
117+
echo " Auth password : $V3_AUTH_PASSWORD"
118+
echo " Priv protocol : $V3_PRIV_PROTOCOL"
119+
echo " Priv password : $V3_PRIV_PASSWORD"
120+
echo ""
121+
echo "Verify with:"
122+
echo " snmpwalk -v2c -c $V2C_COMMUNITY localhost .1.3.6.1.2.1.1"
123+
echo " snmpwalk -v3 -l noAuthNoPriv -u $V3_NOAUTH_USER localhost .1.3.6.1.2.1.1"
124+
echo " snmpwalk -v3 -l authNoPriv -u $V3_AUTH_USER -a $V3_AUTH_PROTOCOL -A $V3_AUTH_PASSWORD localhost .1.3.6.1.2.1.1"
125+
echo " snmpwalk -v3 -l authPriv -u $V3_AUTHPRIV_USER -a $V3_AUTH_PROTOCOL -A $V3_AUTH_PASSWORD -x $V3_PRIV_PROTOCOL -X $V3_PRIV_PASSWORD localhost .1.3.6.1.2.1.1"

0 commit comments

Comments
 (0)