snmp3-error.phpt 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. --TEST--
  2. SNMPv3 Support (errors)
  3. --CREDITS--
  4. Boris Lytochkin
  5. --EXTENSIONS--
  6. snmp
  7. --SKIPIF--
  8. <?php
  9. require_once(__DIR__.'/skipif.inc');
  10. ?>
  11. --FILE--
  12. <?php
  13. require_once(__DIR__.'/snmp_include.inc');
  14. echo "Checking error handling\n";
  15. //int snmp3_get(string host, string sec_name, string sec_level, string auth_protocol,
  16. // string auth_passphrase, string priv_protocol, string priv_passphrase,
  17. // string object_id [, int timeout [, int retries]]);
  18. try {
  19. var_dump(snmp3_get($hostname, $community, '', '', '', '', '', '.1.3.6.1.2.1.1.1.0'));
  20. } catch (\ValueError $e) {
  21. echo $e->getMessage() . \PHP_EOL;
  22. }
  23. try {
  24. var_dump(snmp3_get($hostname, $community, 'bugusPriv', '', '', '', '', '.1.3.6.1.2.1.1.1.0'));
  25. } catch (\ValueError $e) {
  26. echo $e->getMessage() . \PHP_EOL;
  27. }
  28. try {
  29. var_dump(snmp3_get($hostname, $community, 'authNoPriv', 'TTT', '', '', '', '.1.3.6.1.2.1.1.1.0'));
  30. } catch (\ValueError $e) {
  31. echo $e->getMessage() . \PHP_EOL;
  32. }
  33. var_dump(snmp3_get($hostname, $community, 'authNoPriv', 'MD5', '', '', '', '.1.3.6.1.2.1.1.1.0'));
  34. var_dump(snmp3_get($hostname, $community, 'authNoPriv', 'MD5', 'te', '', '', '.1.3.6.1.2.1.1.1.0'));
  35. try {
  36. var_dump(snmp3_get($hostname, $community, 'authPriv', 'MD5', $auth_pass, 'BBB', '', '.1.3.6.1.2.1.1.1.0'));
  37. } catch (\ValueError $e) {
  38. echo $e->getMessage() . \PHP_EOL;
  39. }
  40. var_dump(snmp3_get($hostname, $community, 'authPriv', 'MD5', $auth_pass, 'AES', '', '.1.3.6.1.2.1.1.1.0'));
  41. var_dump(snmp3_get($hostname, $community, 'authPriv', 'MD5', $auth_pass, 'AES', 'ty', '.1.3.6.1.2.1.1.1.0'));
  42. var_dump(snmp3_get($hostname, 'somebogususer', 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
  43. var_dump(snmp3_set($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '.1.3.6.777...7.5.3', 's', 'ttt', $timeout, $retries));
  44. try {
  45. var_dump(snmp3_set($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '.1.3.6.777.7.5.3', array('s'), 'yyy', $timeout, $retries));
  46. } catch (\TypeError $e) {
  47. echo $e->getMessage() . \PHP_EOL;
  48. }
  49. ?>
  50. --EXPECTF--
  51. Checking error handling
  52. Security level must be one of "noAuthNoPriv", "authNoPriv", or "authPriv"
  53. Security level must be one of "noAuthNoPriv", "authNoPriv", or "authPriv"
  54. Authentication protocol must be %s
  55. Warning: snmp3_get(): Error generating a key for authentication pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
  56. bool(false)
  57. Warning: snmp3_get(): Error generating a key for authentication pass phrase 'te': Generic error (The supplied password length is too short.) in %s on line %d
  58. bool(false)
  59. Security protocol must be one of "DES", "AES128", or "AES"
  60. Warning: snmp3_get(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
  61. bool(false)
  62. Warning: snmp3_get(): Error generating a key for privacy pass phrase 'ty': Generic error (The supplied password length is too short.) in %s on line %d
  63. bool(false)
  64. Warning: snmp3_get(): Fatal error: Unknown user name in %s on line %d
  65. bool(false)
  66. Warning: snmp3_set(): Invalid object identifier: .1.3.6.777...7.5.3 in %s on line %d
  67. bool(false)
  68. Type must be of type string when object ID is a string