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