xref: /PHP-8.3/ext/oci8/tests/extauth_02.phpt (revision cd927ef6)
1--TEST--
2Test External Authentication errors with oci_new_connect
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7if (substr(PHP_OS, 0, 3) == 'WIN') die("skip feature not available on Windows platforms");
8die("skip random CI timeouts caused by Oracle Instant Client, see https://github.com/php/php-src/pull/9524#issuecomment-1244409815");
9?>
10--INI--
11oci8.privileged_connect=1
12--FILE--
13<?php
14
15error_reporting(E_ALL ^ E_DEPRECATED);
16
17// Run Test
18
19echo "Test 1\n";
20
21$c = oci_new_connect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT);
22if (!$c) {
23    $m = oci_error();
24    var_dump($m);
25}
26var_dump($c);
27
28echo "Test 2\n";
29
30$c = oci_new_connect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT);
31if (!$c) {
32    $m = oci_error();
33    var_dump($m);
34}
35var_dump($c);
36
37echo "Test 3\n";
38
39$c = oci_new_connect('notemtpy', '', 'anything', null, OCI_CRED_EXT);
40if (!$c) {
41    $m = oci_error();
42    var_dump($m);
43}
44var_dump($c);
45
46echo "Test 4\n";
47
48$c = oci_new_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER);
49if (!$c) {
50    $m = oci_error();
51    var_dump($m);
52}
53var_dump($c);
54
55echo "Test 5\n";
56
57$c = oci_new_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT);
58if (!$c) {
59    $m = oci_error();
60    var_dump($m);
61}
62var_dump($c);
63
64echo "Test 6\n";
65
66$c = oci_new_connect('', '', 'anything', null, OCI_CRED_EXT);
67if (!$c) {
68    $m = oci_error();
69    var_dump($m);
70}
71var_dump($c);
72
73echo "Test 7\n";
74
75$c = oci_new_connect('/', '', 'anything', null, OCI_CRED_EXT);
76if (!$c) {
77    $m = oci_error();
78    var_dump($m);
79}
80var_dump($c);
81
82echo "Test 8\n";
83
84$c = oci_new_connect('/', null, 'anything', null, OCI_CRED_EXT);
85if (!$c) {
86    $m = oci_error();
87    var_dump($m);
88}
89var_dump($c);
90
91echo "Test 9\n";
92
93$c = oci_new_connect('/', '', 'd', null, OCI_SYSDBA+OCI_CRED_EXT);
94if (!$c) {
95    $m = oci_error();
96    var_dump($m);
97}
98var_dump($c);
99
100echo "Test 10\n";
101
102$c = oci_new_connect('/', '', 'd', null, OCI_SYSOPER+OCI_CRED_EXT);
103if (!$c) {
104    $m = oci_error();
105    var_dump($m);
106}
107var_dump($c);
108
109
110?>
111--EXPECTF--
112Test 1
113
114Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
115bool(false)
116bool(false)
117Test 2
118
119Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
120bool(false)
121bool(false)
122Test 3
123
124Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
125bool(false)
126bool(false)
127Test 4
128
129Warning: oci_new_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d
130bool(false)
131bool(false)
132Test 5
133
134Warning: oci_new_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d
135bool(false)
136bool(false)
137Test 6
138
139Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
140bool(false)
141bool(false)
142Test 7
143
144Warning: oci_new_connect(): ORA-12154: %s in %s on line %d
145array(4) {
146  ["code"]=>
147  int(12154)
148  ["message"]=>
149  string(%d) "ORA-12154: %s"
150  ["offset"]=>
151  int(0)
152  ["sqltext"]=>
153  string(0) ""
154}
155bool(false)
156Test 8
157
158Warning: oci_new_connect(): ORA-12154: %s in %s on line %d
159array(4) {
160  ["code"]=>
161  int(12154)
162  ["message"]=>
163  string(%d) "ORA-12154: %s"
164  ["offset"]=>
165  int(0)
166  ["sqltext"]=>
167  string(0) ""
168}
169bool(false)
170Test 9
171
172Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d
173array(4) {
174  ["code"]=>
175  int(%d)
176  ["message"]=>
177  string(%d) "ORA-%d: %s"
178  ["offset"]=>
179  int(0)
180  ["sqltext"]=>
181  string(0) ""
182}
183bool(false)
184Test 10
185
186Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d
187array(4) {
188  ["code"]=>
189  int(%d)
190  ["message"]=>
191  string(%d) "ORA-%d: %s"
192  ["offset"]=>
193  int(0)
194  ["sqltext"]=>
195  string(0) ""
196}
197bool(false)
198