xref: /PHP-7.3/ext/oci8/tests/drcp_privileged.phpt (revision b746e698)
1--TEST--
2DRCP: privileged connect
3--SKIPIF--
4<?php
5if (!extension_loaded('oci8')) die("skip no oci8 extension");
6require(dirname(__FILE__)."/connect.inc");
7if (!$test_drcp) die("skip requires DRCP connection");
8// Looked for :pooled in EZ connect string
9if (strpos($dbase, "/") !== false && stripos($dbase, ":pooled") === false)
10    die('skip DRCP test requires a DRCP pooled server connection');
11if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
12ob_start();
13phpinfo(INFO_MODULES);
14$phpinfo = ob_get_clean();
15if (preg_match('/Compile-time ORACLE_HOME/', $phpinfo) !== 1) {
16    // Assume building PHP with an ORACLE_HOME means the tested DB is on the same machine as PHP
17    die("skip this test is unlikely to work with a remote database - unless an Oracle password file has been created");
18}
19
20preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv);
21// This test in Oracle 12c needs a non-CDB or the root container
22if (isset($matches_sv[0]) && $matches_sv[1] >= 12) {
23    $s = oci_parse($c, "select nvl(sys_context('userenv', 'con_name'), 'notacdb') as dbtype from dual");
24    $r = @oci_execute($s);
25    if (!$r)
26        die('skip could not identify container type');
27    $r = oci_fetch_array($s);
28    if ($r['DBTYPE'] !== 'CDB$ROOT')
29        die('skip cannot run test using a PDB');
30}
31?>
32--INI--
33oci8.privileged_connect=1
34--FILE--
35<?php
36
37// Connecting as SYSDBA or SYSOPER through DRCP will give ORA-1031
38
39require dirname(__FILE__)."/details.inc";
40var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSDBA));
41var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSOPER));
42var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSDBA));
43var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSOPER));
44var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA));
45var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSOPER));
46
47echo "Done\n";
48
49?>
50--EXPECTF--
51Warning: oci_connect(): ORA-01031: %s in %s on line %d
52bool(false)
53
54Warning: oci_connect(): ORA-01031: %s in %s on line %d
55bool(false)
56
57Warning: oci_new_connect(): ORA-01031: %s in %s on line %d
58bool(false)
59
60Warning: oci_new_connect(): ORA-01031: %s in %s on line %d
61bool(false)
62
63Warning: oci_pconnect(): ORA-01031: %s in %s on line %d
64bool(false)
65
66Warning: oci_pconnect(): ORA-01031: %s in %s on line %d
67bool(false)
68Done
69