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