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--
36Warning: SNMP::setSecurity() expects at least 1 parameter, 0 given in %s on line %d
37bool(false)
38
39Warning: SNMP::setSecurity(): Invalid security level '' in %s on line %d
40bool(false)
41
42Warning: SNMP::setSecurity(): Invalid security level 'bugusPriv' in %s on line %d
43bool(false)
44
45Warning: SNMP::setSecurity(): Unknown authentication protocol 'TTT' in %s on line %d
46bool(false)
47
48Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
49bool(false)
50
51Warning: 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
52bool(false)
53
54Warning: SNMP::setSecurity(): Unknown security protocol 'BBB' in %s on line %d
55bool(false)
56
57Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
58bool(false)
59
60Warning: 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
61bool(false)
62
63Warning: SNMP::setSecurity(): Bad engine ID value 'dsa' in %s on line %d
64bool(false)
65bool(true)
66