Esempio n. 1
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));
  }
Esempio n. 2
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));
 }
Esempio n. 3
0
  @Test(timeout = 20000)
  public void testDetectScalarHexString() throws UnknownHostException {
    m_detector.setOid(".1.3.6.1.2.1.3.1.1.2.4.1.192.0.2.1");
    m_detector.setIsTable("false");

    // Validate against data type Hex-STRING for a MAC address
    m_detector.setHex("true");
    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));
  }
Esempio n. 4
0
  @Test(timeout = 20000)
  public void testDetectTableAny() 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");
    m_detector.setMatchType(MatchType.Any.name());

    // Detect service if 2 is somewhere in the table
    m_detector.setVbvalue("2");
    assertEquals(true, m_detector.isServiceDetected(m_testIpAddress));

    // Do not detect service if 1 is not in the table
    m_detector.setVbvalue("1");
    assertEquals(false, m_detector.isServiceDetected(m_testIpAddress));
  }
Esempio n. 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));
  }