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