xref: /PHP-8.3/ext/oci8/tests/password.phpt (revision a53e5617)
1--TEST--
2oci_password_change() for non-persistent connections
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8if (is_null($dbase)) die ("skip requires database connection string be set");
9if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
10if ($test_drcp) die("skip password change not supported in DRCP Mode");
11?>
12--FILE--
13<?php
14
15require __DIR__.'/connect.inc';
16
17$stmtarray = array(
18    "drop user testuser_pw cascade",
19    "create user testuser_pw identified by testuserpwd",
20    "grant connect, create session to testuser_pw"
21);
22
23oci8_test_sql_execute($c, $stmtarray);
24
25
26// Connect and change the password
27$c1 = oci_connect("testuser_pw", "testuserpwd", $dbase);
28var_dump($c1);
29$rn1 = (int)$c1;
30
31oci_password_change($c1, "testuser_pw", "testuserpwd", "testuserpwd2");
32
33// Second connect should return a new resource because the hash string will be different from $c1
34$c2 = oci_connect("testuser_pw", "testuserpwd2", $dbase);
35var_dump($c2);
36$rn2 = (int)$c2;
37
38// Despite using the old password this connect should succeed and return the original resource
39$c3 = oci_connect("testuser_pw", "testuserpwd", $dbase);
40var_dump($c3);
41$rn3 = (int)$c3;
42
43// Connections should differ
44if ($rn1 == $rn2) {
45    echo "First and second connections share a resource: Not OK\n";
46    var_dump($c1);
47}
48else {
49    echo "First and second connections are different: OK\n";
50}
51
52// Connections should be the same
53if ($rn1 == $rn3) {
54    echo "First and third connections share a resource: OK\n";
55}
56else {
57    echo "First and third connections are different: Not OK\n";
58    var_dump($c1);
59    var_dump($c2);
60}
61
62echo "Done\n";
63
64?>
65--CLEAN--
66<?php
67
68require __DIR__.'/connect.inc';
69
70$stmtarray = array(
71    "drop user testuser_pw cascade"
72);
73
74oci8_test_sql_execute($c, $stmtarray);
75
76?>
77--EXPECTF--
78resource(%d) of type (oci8 connection)
79resource(%d) of type (oci8 connection)
80resource(%d) of type (oci8 connection)
81First and second connections are different: OK
82First and third connections share a resource: OK
83Done
84