password.phpt 2.0 KB

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