Annotation of embedaddon/php/ext/pdo_pgsql/tests/bug62479.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: PDO PgSQL Bug #62479 (PDO-psql cannot connect if password contains spaces)
                      3: --SKIPIF--
                      4: <?php
                      5: if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
                      6: require dirname(__FILE__) . '/config.inc';
                      7: require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
                      8: PDOTest::skip();
                      9: if (!isset($conf['ENV']['PDOTEST_DSN'])) die('no dsn found in env');
                     10: $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
                     11: $rand = rand(5, 5);
                     12: 
                     13: // Assume that if we can't create a user, this test needs to be skipped
                     14: $testQuery = "CREATE USER pdo_$rand WITH PASSWORD 'testpass'";
                     15: $db->query($testQuery);
                     16: $testQuery = "DROP USER pdo_$rand";
                     17: $db->query($testQuery);
                     18: ?>
                     19: --FILE--
                     20: <?php
                     21: require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
                     22: $pdo = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
                     23: $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
                     24: $rand = rand(5, 400);
                     25: $user = "pdo_$rand";
                     26: $template = "CREATE USER $user WITH PASSWORD '%s'";
                     27: $dropUser = "DROP USER $user";
                     28: $testQuery = 'SELECT 1 as verification';
                     29: 
                     30: // Create temp user with space in password
                     31: $sql = sprintf($template, 'my password');
                     32: $pdo->query($sql);
                     33: $testConn = new PDO($conf['ENV']['PDOTEST_DSN'], $user, "my password");
                     34: $result = $testConn->query($testQuery)->fetch();
                     35: $check = $result[0];
                     36: var_dump($check);
                     37: 
                     38: // Remove the user
                     39: $pdo->query($dropUser);
                     40: 
                     41: // Create a user with a space and single quote
                     42: $sql = sprintf($template, "my pass''word");
                     43: $pdo->query($sql);
                     44: 
                     45: $testConn = new PDO($conf['ENV']['PDOTEST_DSN'], $user, "my pass'word");
                     46: $result = $testConn->query($testQuery)->fetch();
                     47: $check = $result[0];
                     48: var_dump($check);
                     49: 
                     50: // Remove the user
                     51: $pdo->query($dropUser);
                     52: ?>
                     53: --EXPECT--
                     54: int(1)
                     55: int(1)
                     56: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>