use of org.opennms.netmgt.config.trapd.TrapdConfiguration in project opennms by OpenNMS.
the class TrapListenerTest method verifyCheckForSnmpV3ConfigurationChange.
@Test
public void verifyCheckForSnmpV3ConfigurationChange() throws Exception {
TrapdConfiguration config = new TrapdConfiguration();
config.setSnmpTrapPort(initialConfig.getSnmpTrapPort() + 1);
Assert.assertEquals(Boolean.FALSE, receiver.hasSnmpV3UsersChanged(new TrapdConfigBean(config)));
// Add a user, should result in a difference
config.getSnmpv3UserCollection().add(createUser("MD5", "0p3nNMSv3", "some-engine-id", "DES", "0p3nNMSv3", "some-security-name"));
Assert.assertEquals(Boolean.TRUE, receiver.hasSnmpV3UsersChanged(new TrapdConfigBean(config)));
// update and verify that it now is equal
receiver.setTrapdConfig(config);
Assert.assertEquals(Boolean.FALSE, receiver.hasSnmpV3UsersChanged(new TrapdConfigBean(config)));
// Changing the port should not result in a difference
config.setSnmpTrapPort(config.getSnmpTrapPort() + 1);
Assert.assertEquals(Boolean.FALSE, receiver.hasSnmpV3UsersChanged(new TrapdConfigBean(config)));
}
use of org.opennms.netmgt.config.trapd.TrapdConfiguration in project opennms by OpenNMS.
the class TrapListenerTest method verifyCheckForTrapdConfigurationChange.
@Test
public void verifyCheckForTrapdConfigurationChange() throws Exception {
// Empty config should be different
TrapdConfiguration config = new TrapdConfiguration();
Assert.assertEquals(Boolean.TRUE, receiver.hasConfigurationChanged(new TrapdConfigBean(config)));
// Equal config should not be different
config.setSnmpTrapPort(initialConfig.getSnmpTrapPort());
config.setSnmpTrapAddress(initialConfig.getSnmpTrapAddress());
Assert.assertEquals(Boolean.FALSE, receiver.hasConfigurationChanged(new TrapdConfigBean(config)));
// Add a user, should result in a difference
config.getSnmpv3UserCollection().add(createUser("MD5", "0p3nNMSv3", "some-engine-id", "DES", "0p3nNMSv3", "some-security-name"));
Assert.assertEquals(Boolean.TRUE, receiver.hasConfigurationChanged(new TrapdConfigBean(config)));
// update and verify that it now is equal
receiver.setTrapdConfig(config);
Assert.assertEquals(Boolean.FALSE, receiver.hasConfigurationChanged(new TrapdConfigBean(config)));
// Adding another user should also result in a difference
config.getSnmpv3UserCollection().add(createUser("MD5", "0p3nNMSv3", "some-engine-id", "DES", "0p3nNMSv3", "some-security-name-2"));
Assert.assertEquals(Boolean.TRUE, receiver.hasConfigurationChanged(new TrapdConfigBean(config)));
// update and verify that it now is equal
receiver.setTrapdConfig(config);
Assert.assertEquals(Boolean.FALSE, receiver.hasConfigurationChanged(new TrapdConfigBean(config)));
// Adding another copy of an existing user will NOT trigger an update, the first entry found in the list will be used
config.getSnmpv3UserCollection().add(createUser("MD5", "0p3nNMSv3", "some-engine-id", "DES", "0p3nNMSv3", "some-security-name"));
Assert.assertEquals(Boolean.FALSE, receiver.hasConfigurationChanged(new TrapdConfigBean(config)));
// Editing a user should result in a difference
config.getSnmpv3UserCollection().get(0).setPrivacyProtocol("AES");
Assert.assertEquals(Boolean.TRUE, receiver.hasConfigurationChanged(new TrapdConfigBean(config)));
// update and verify that it now is equal
receiver.setTrapdConfig(config);
Assert.assertEquals(Boolean.FALSE, receiver.hasConfigurationChanged(new TrapdConfigBean(config)));
}
Aggregations