|
| 1 | +--TEST-- |
| 2 | +MongoDB\Driver\Manager::__construct(): authentication options are validated |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | + |
| 6 | +require_once __DIR__ . '/../utils/tools.php'; |
| 7 | + |
| 8 | +echo throws(function() { |
| 9 | + new MongoDB\Driver\Manager('mongodb://localhost:27017/?authMechanism=GSSAPI&authSource=admin'); |
| 10 | +}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 11 | + |
| 12 | +echo throws(function() { |
| 13 | + new MongoDB\Driver\Manager('mongodb://localhost:27017/', ['authMechanism' => 'GSSAPI', 'authSource' => 'admin']); |
| 14 | +}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 15 | + |
| 16 | +echo throws(function() { |
| 17 | + new MongoDB\Driver\Manager('mongodb://localhost:27017/?authMechanism=MONGODB-X509&authSource=admin'); |
| 18 | +}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 19 | + |
| 20 | +echo throws(function() { |
| 21 | + new MongoDB\Driver\Manager('mongodb://localhost:27017/', ['authMechanism' => 'MONGODB-X509', 'authSource' => 'admin']); |
| 22 | +}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 23 | + |
| 24 | +echo throws(function() { |
| 25 | + new MongoDB\Driver\Manager('mongodb://@localhost:27017/?authMechanism=SCRAM-SHA-1'); |
| 26 | +}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 27 | + |
| 28 | +echo throws(function() { |
| 29 | + new MongoDB\Driver\Manager('mongodb://localhost:27017/', ['username' => '', 'authMechanism' => 'SCRAM-SHA-1']); |
| 30 | +}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 31 | + |
| 32 | +echo throws(function() { |
| 33 | + new MongoDB\Driver\Manager('mongodb://localhost:27017/', ['password' => 'password', 'authMechanism' => 'MONGODB-X509']); |
| 34 | +}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 35 | + |
| 36 | +?> |
| 37 | +===DONE=== |
| 38 | +<?php exit(0); ?> |
| 39 | +--EXPECT-- |
| 40 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 41 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?authMechanism=GSSAPI&authSource=admin'. GSSAPI and X509 require "$external" authSource. |
| 42 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 43 | +Failed to parse URI options: GSSAPI and X509 require "$external" authSource. |
| 44 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 45 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?authMechanism=MONGODB-X509&authSource=admin'. GSSAPI and X509 require "$external" authSource. |
| 46 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 47 | +Failed to parse URI options: GSSAPI and X509 require "$external" authSource. |
| 48 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 49 | +Failed to parse MongoDB URI: 'mongodb://@localhost:27017/?authMechanism=SCRAM-SHA-1'. 'SCRAM-SHA-1' authentication mechanism requires username. |
| 50 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 51 | +Failed to parse URI options: 'SCRAM-SHA-1' authentication mechanism requires username. |
| 52 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 53 | +Failed to parse URI options: X509 authentication mechanism does not accept a password. |
| 54 | +===DONE=== |
0 commit comments