Annotation of embedaddon/php/ext/snmp/tests/snmp3.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--                                 
                      2: SNMPv3 Support
                      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: 
                     13: //int snmp3_get(string host, string sec_name, string sec_level, string auth_protocol, 
                     14: //              string auth_passphrase, string priv_protocol, string priv_passphrase, 
                     15: //              string object_id [, int timeout [, int retries]]);
                     16: 
                     17: echo "Working version\n";
                     18: snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
                     19: echo "GET single: noAuthNoPriv\n";
                     20: var_dump(snmp3_get($hostname, $user_noauth, 'noAuthNoPriv', '', '', '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
                     21: 
                     22: foreach(array('MD5', 'SHA') as $signalg) {
                     23:        echo "GET single: $signalg\n";
                     24:        var_dump(snmp3_get($hostname, $user_auth_prefix . $signalg, 'authNoPriv', $signalg, $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
                     25: }
                     26: 
                     27: foreach(array('AES', 'DES', 'AES128') as $chipher) {
                     28:        echo "GET single: MD5/$chipher\n";
                     29:        var_dump(snmp3_get($hostname, $user_auth_prefix . 'MD5' . $chipher, 'authPriv', 'MD5', $auth_pass, $chipher, $priv_pass, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
                     30: }
                     31: $username = $user_auth_prefix . 'MD5';
                     32: echo "GET multiple\n";
                     33: var_dump(snmp3_get($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
                     34: echo "GETNEXT single\n";
                     35: var_dump(snmp3_getnext($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
                     36: 
                     37: echo "WALK single on single OID\n";
                     38: $z = snmp3_walk($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries);
                     39: var_dump(gettype($z));
                     40: var_dump(count($z));
                     41: var_dump($z);
                     42: 
                     43: echo "REALWALK single on single OID\n";
                     44: $z = snmp3_real_walk($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries);
                     45: var_dump(gettype($z));
                     46: var_dump(count($z));
                     47: var_dump($z);
                     48: 
                     49: echo "WALK multiple on single OID\n";
                     50: $z = snmp3_walk($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', '.1.3.6.1.2.1.1', $timeout, $retries);
                     51: var_dump(gettype($z));
                     52: var_dump(count($z));
                     53: var_dump(key($z));
                     54: var_dump(array_shift($z));
                     55: 
                     56: echo "REALWALK multiple on single OID\n";
                     57: $z = snmp3_real_walk($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, 'AES', '', '.1.3.6.1.2.1.1', $timeout, $retries);
                     58: var_dump(gettype($z));
                     59: var_dump(count($z));
                     60: var_dump(key($z));
                     61: var_dump(array_shift($z));
                     62: 
                     63: echo "SET single OID\n";
                     64: $oid1 = 'SNMPv2-MIB::sysContact.0';
                     65: $oldvalue1 = snmp3_get($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, $timeout, $retries);
                     66: $newvalue1 = $oldvalue1 . '0';
                     67: 
                     68: $z = snmp3_set($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, 's', $newvalue1, $timeout, $retries);
                     69: var_dump($z);
                     70: var_dump((snmp3_get($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, $timeout, $retries) === $newvalue1));
                     71: $z = snmp3_set($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, 's', $oldvalue1, $timeout, $retries);
                     72: var_dump($z);
                     73: var_dump((snmp3_get($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, $timeout, $retries) === $oldvalue1));
                     74: 
                     75: ?>
                     76: --EXPECTF--
                     77: Working version
                     78: GET single: noAuthNoPriv
                     79: %string|unicode%(%d) "%s"
                     80: GET single: MD5
                     81: %string|unicode%(%d) "%s"
                     82: GET single: SHA
                     83: %string|unicode%(%d) "%s"
                     84: GET single: MD5/AES
                     85: %string|unicode%(%d) "%s"
                     86: GET single: MD5/DES
                     87: %string|unicode%(%d) "%s"
                     88: GET single: MD5/AES128
                     89: %string|unicode%(%d) "%s"
                     90: GET multiple
                     91: array(2) {
                     92:   ["%s"]=>
                     93:   %string|unicode%(%d) "%s"
                     94:   ["%s"]=>
                     95:   %string|unicode%(%d) "%s"
                     96: }
                     97: GETNEXT single
                     98: %string|unicode%(%d) "%s"
                     99: WALK single on single OID
                    100: %string|unicode%(5) "array"
                    101: int(1)
                    102: array(1) {
                    103:   [0]=>
                    104:   %string|unicode%(%d) "%s"
                    105: }
                    106: REALWALK single on single OID
                    107: %string|unicode%(5) "array"
                    108: int(1)
                    109: array(1) {
                    110:   ["%s"]=>
                    111:   %string|unicode%(%d) "%s"
                    112: }
                    113: WALK multiple on single OID
                    114: %string|unicode%(5) "array"
                    115: int(%d)
                    116: int(0)
                    117: %string|unicode%(%d) "%s"
                    118: REALWALK multiple on single OID
                    119: %string|unicode%(5) "array"
                    120: int(%d)
                    121: %string|unicode%(%d) "%s"
                    122: %string|unicode%(%d) "%s"
                    123: SET single OID
                    124: bool(true)
                    125: bool(true)
                    126: bool(true)
                    127: bool(true)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>