[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot] 2026-01-17 12:14:21 +00:00 committed by GitHub
parent 35cd96da70
commit 523f6f433c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 37 deletions

View File

@ -29,11 +29,7 @@ class SNMPMonitorType extends MonitorType {
// a follow-up PR to keep this change scoped.
sessionOptions.securityLevel = snmp.SecurityLevel.noAuthNoPriv;
sessionOptions.username = monitor.snmp_v3_username;
session = snmp.createV3Session(
monitor.hostname,
monitor.snmp_v3_username,
sessionOptions
);
session = snmp.createV3Session(monitor.hostname, monitor.snmp_v3_username, sessionOptions);
} else {
session = snmp.createSession(monitor.hostname, monitor.radiusPassword, sessionOptions);
}

View File

@ -509,20 +509,14 @@
<div v-if="monitor.type === 'snmp'" class="my-3">
<label for="snmp_version" class="form-label">{{ $t("SNMP Version") }}</label>
<select id="snmp_version" v-model="monitor.snmpVersion" class="form-select">
<option value="1">
SNMPv1
</option>
<option value="2c">
SNMPv2c
</option>
<option value="3">
SNMPv3
</option>
<option value="1">SNMPv1</option>
<option value="2c">SNMPv2c</option>
<option value="3">SNMPv3</option>
</select>
</div>
<div v-if="monitor.type === 'snmp' && monitor.snmpVersion === '3'" class="my-3">
<label for="snmp_v3_username" class="form-label">
{{ $t('snmpV3Username') }}
{{ $t("snmpV3Username") }}
</label>
<input
@ -532,7 +526,7 @@
class="form-control"
placeholder="SNMPv3 username"
required
>
/>
</div>
<div v-if="monitor.type === 'smtp'" class="my-3">

View File

@ -9,15 +9,11 @@ describe("SNMPMonitorType", () => {
test(
"check() sets heartbeat to UP when SNMP agent responds",
{
skip:
!!process.env.CI &&
(process.platform !== "linux" || process.arch !== "x64"),
skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64"),
},
async () => {
// Expose SNMP port via Testcontainers
const container = await new GenericContainer("polinux/snmpd")
.withExposedPorts("161/udp")
.start();
const container = await new GenericContainer("polinux/snmpd").withExposedPorts("161/udp").start();
try {
// Dynamically retrieve the assigned host port and IP
@ -57,9 +53,7 @@ describe("SNMPMonitorType", () => {
test(
"check() throws when SNMP agent does not respond",
{
skip:
!!process.env.CI &&
(process.platform !== "linux" || process.arch !== "x64"),
skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64"),
},
async () => {
const monitor = {
@ -76,10 +70,7 @@ describe("SNMPMonitorType", () => {
const snmpMonitor = new SNMPMonitorType();
const heartbeat = {};
await assert.rejects(
() => snmpMonitor.check(monitor, heartbeat),
/timeout|RequestTimedOutError/i
);
await assert.rejects(() => snmpMonitor.check(monitor, heartbeat), /timeout|RequestTimedOutError/i);
}
);
@ -124,18 +115,12 @@ describe("SNMPMonitorType", () => {
const snmpMonitor = new SNMPMonitorType();
const heartbeat = {};
await assert.rejects(
() => snmpMonitor.check(monitor, heartbeat),
/stop test here/
);
await assert.rejects(() => snmpMonitor.check(monitor, heartbeat), /stop test here/);
// Assertions
assert.strictEqual(createV3Called, true);
assert.strictEqual(createSessionCalled, false);
assert.strictEqual(
receivedOptions.securityLevel,
snmp.SecurityLevel.noAuthNoPriv
);
assert.strictEqual(receivedOptions.securityLevel, snmp.SecurityLevel.noAuthNoPriv);
// Restore originals
snmp.createV3Session = originalCreateV3Session;