示例#1
0
 @Test(timeout = 20000)
 public void testDetectScalarBackwardCompatibility() throws UnknownHostException {
   // Match type was introduced with SNMP table detection, make sure it does not break configs
   // without MatchType set
   m_detector.setOid(".1.3.6.1.2.1.1.2.0");
   m_detector.setIsTable("false");
   m_detector.setVbvalue("\\.1\\.3\\.6\\.1\\.4\\.1.*");
   assertEquals(true, m_detector.isServiceDetected(m_testIpAddress));
 }
示例#2
0
  @Before
  public void setUp() throws InterruptedException, UnknownHostException {
    MockLogAppender.setupLogging();

    m_testIpAddress = InetAddressUtils.addr(TEST_IP_ADDRESS);

    if (m_detector == null) {
      m_detector = getDetector(SnmpDetector.class);
      m_detector.setRetries(2);
      m_detector.setTimeout(500);
    }
  }
示例#3
0
  @Test(timeout = 20000)
  public void testDetectTableHexString() throws UnknownHostException {
    m_detector.setOid(".1.3.6.1.2.1.3.1.1.2.4.1");
    m_detector.setIsTable("true");

    // Validate against data type Hex-STRING for a MAC address
    m_detector.setHex("true");
    m_detector.setMatchType(MatchType.Any.name());
    m_detector.setVbvalue("000f662002fd");
    assertEquals(true, m_detector.isServiceDetected(m_testIpAddress));

    // Should not detect, input not interpreted as Hex-STRING
    m_detector.setHex("false");
    m_detector.setVbvalue("000f662002fd");
    assertEquals(false, m_detector.isServiceDetected(m_testIpAddress));
  }
示例#4
0
  @Test(timeout = 20000)
  public void testDetectTableNone() throws UnknownHostException {
    // Set to table with 3 and 2 mixed
    m_detector.setOid(".1.3.6.1.2.1.2.2.1.7");
    m_detector.setIsTable("true");

    // Detect service if 1 is not in the table
    m_detector.setVbvalue("1");
    m_detector.setMatchType(MatchType.None.name());
    assertEquals(true, m_detector.isServiceDetected(m_testIpAddress));

    // Do not detect service if 2 is somewhere in the table
    m_detector.setVbvalue("2");
    m_detector.setMatchType(MatchType.None.name());
    assertEquals(false, m_detector.isServiceDetected(m_testIpAddress));
  }
示例#5
0
  @Test(timeout = 20000)
  public void testDetectTableAll() throws UnknownHostException {
    // Set to table with all 1
    m_detector.setOid(".1.3.6.1.2.1.2.2.1.8");
    m_detector.setIsTable("true");
    m_detector.setMatchType(MatchType.All.name());

    // Detect service if all values are 1
    m_detector.setVbvalue("1");
    assertEquals(true, m_detector.isServiceDetected(m_testIpAddress));

    // Do not detect service if not all values are 2
    m_detector.setVbvalue("2");
    assertEquals(false, m_detector.isServiceDetected(m_testIpAddress));
  }
示例#6
0
  @Test(timeout = 20000)
  public void testDetectTableExist() throws UnknownHostException {
    // Set to existing table, detect service
    m_detector.setOid(".1.3.6.1.2.1.2.2.1.7");
    m_detector.setIsTable("true");
    m_detector.setMatchType(MatchType.Exist.name());
    assertEquals(true, m_detector.isServiceDetected(m_testIpAddress));

    // Set to non existing table, do not detect service
    m_detector.setOid(".9.9.9.9.9.9.9.9.999");
    assertEquals(false, m_detector.isServiceDetected(m_testIpAddress));
  }
示例#7
0
 @Test(timeout = 20000)
 public void testIsProtocolSupportedInetAddress() throws UnknownHostException {
   assertTrue("protocol is not supported", m_detector.isServiceDetected(m_testIpAddress));
 }
示例#8
0
 @Test(timeout = 20000)
 public void testIsExpectedValue() throws UnknownHostException {
   m_detector.setVbvalue("\\.1\\.3\\.6\\.1\\.4\\.1.*");
   assertTrue("protocol is not supported", m_detector.isServiceDetected(m_testIpAddress));
 }
示例#9
0
 @Test(timeout = 20000)
 public void testIsForcedV1ProtocolSupported() throws UnknownHostException {
   m_detector.setVbvalue("\\.1\\.3\\.6\\.1\\.4\\.1.*");
   m_detector.setForceVersion("snmpv1");
   assertTrue(m_detector.isServiceDetected(m_testIpAddress));
 }