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