snmp-object-setSecurity_error.phpt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --TEST--
  2. OO API: SNMP::setSecurity (errors)
  3. --CREDITS--
  4. Boris Lytochkin
  5. --SKIPIF--
  6. <?php
  7. require_once(dirname(__FILE__).'/skipif.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once(dirname(__FILE__).'/snmp_include.inc');
  12. //EXPECTF format is quickprint OFF
  13. snmp_set_quick_print(false);
  14. snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
  15. $session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries);
  16. $session->setSecurity('noAuthNoPriv');
  17. #echo "Checking error handling\n";
  18. var_dump($session->setSecurity());
  19. var_dump($session->setSecurity(''));
  20. var_dump($session->setSecurity('bugusPriv'));
  21. var_dump($session->setSecurity('authNoPriv', 'TTT'));
  22. var_dump($session->setSecurity('authNoPriv', 'MD5', ''));
  23. var_dump($session->setSecurity('authNoPriv', 'MD5', 'te'));
  24. var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'BBB'));
  25. var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', ''));
  26. var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', 'ty'));
  27. var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', 'test12345', 'context', 'dsa'));
  28. var_dump($session->close());
  29. ?>
  30. --EXPECTF--
  31. Warning: SNMP::setSecurity() expects at least 1 parameter, 0 given in %s on line %d
  32. bool(false)
  33. Warning: SNMP::setSecurity(): Invalid security level '' in %s on line %d
  34. bool(false)
  35. Warning: SNMP::setSecurity(): Invalid security level 'bugusPriv' in %s on line %d
  36. bool(false)
  37. Warning: SNMP::setSecurity(): Unknown authentication protocol 'TTT' in %s on line %d
  38. bool(false)
  39. Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
  40. bool(false)
  41. Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase 'te': Generic error (The supplied password length is too short.) in %s on line %d
  42. bool(false)
  43. Warning: SNMP::setSecurity(): Unknown security protocol 'BBB' in %s on line %d
  44. bool(false)
  45. Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
  46. bool(false)
  47. Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase 'ty': Generic error (The supplied password length is too short.) in %s on line %d
  48. bool(false)
  49. Warning: SNMP::setSecurity(): Bad engine ID value 'dsa' in %s on line %d
  50. bool(false)
  51. bool(true)