Skip to content

Commit

Permalink
Merge pull request #367 from sentrysoftware/feature/issue-366-option-…
Browse files Browse the repository at this point in the history
…2c-not-recognized-for-snmp-version-in-metricshub-cli-and-metricshubyaml

Issue #366: Recognize '2c' as a valid SNMP version option
  • Loading branch information
NassimBtk authored Aug 9, 2024
2 parents c5cf9d2 + 26200b0 commit f59bb1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ public static SnmpVersion interpretValueOf(@NonNull final String version) {
return V1;
}

if ("2".equals(lowerCaseVersion) || "v2".equals(lowerCaseVersion) || "v2c".equals(lowerCaseVersion)) {
if (
"2".equals(lowerCaseVersion) ||
"v2".equals(lowerCaseVersion) ||
"v2c".equals(lowerCaseVersion) ||
"2c".equals(lowerCaseVersion)
) {
return V2C;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sentrysoftware.metricshub.extension.snmp;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -99,4 +100,14 @@ void testValidateConfiguration() {
assertThrows(InvalidConfigurationException.class, () -> snmpConfig.validateConfiguration(resourceKey));
}
}

@Test
void testSnmpVersionInterpretValueOf() {
assertEquals(SnmpVersion.V1, SnmpVersion.interpretValueOf("1"));
assertEquals(SnmpVersion.V1, SnmpVersion.interpretValueOf("v1"));
assertEquals(SnmpVersion.V2C, SnmpVersion.interpretValueOf("2"));
assertEquals(SnmpVersion.V2C, SnmpVersion.interpretValueOf("v2"));
assertEquals(SnmpVersion.V2C, SnmpVersion.interpretValueOf("v2c"));
assertEquals(SnmpVersion.V2C, SnmpVersion.interpretValueOf("2c"));
}
}

0 comments on commit f59bb1c

Please sign in to comment.