|
1 | 1 | --TEST--
|
2 |
| -MongoDB\Driver\Manager::__construct(): tlsInsecure cannot be combined with tlsAllowInvalidHostnames |
| 2 | +MongoDB\Driver\Manager::__construct(): Test invalid URI option combinations |
3 | 3 | --FILE--
|
4 | 4 | <?php
|
5 | 5 |
|
6 | 6 | require_once __DIR__ . '/../utils/tools.php';
|
7 | 7 |
|
8 |
| -echo throws(function() { |
9 |
| - new MongoDB\Driver\Manager('mongodb://localhost:27017/?tlsInsecure=true&tlsAllowInvalidHostnames=true'); |
10 |
| -}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 8 | +$invalidCombinations = [ |
| 9 | + ['tlsInsecure', 'tlsAllowInvalidHostnames'], |
| 10 | + ['tlsInsecure', 'tlsAllowInvalidCertificates'], |
| 11 | + ['tlsInsecure', 'tlsDisableOCSPEndpointCheck'], |
| 12 | + ['tlsInsecure', 'tlsDisableCertificateRevocationCheck'], |
| 13 | + ['tlsAllowInvalidCertificates', 'tlsDisableOCSPEndpointCheck'], |
| 14 | + ['tlsAllowInvalidCertificates', 'tlsDisableCertificateRevocationCheck'], |
| 15 | +]; |
11 | 16 |
|
12 |
| -echo throws(function() { |
13 |
| - new MongoDB\Driver\Manager('mongodb://localhost:27017/', ['tlsInsecure' => true, 'tlsAllowInvalidHostnames' => true]); |
14 |
| -}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 17 | +foreach ($invalidCombinations as list($optionA, $optionB)) { |
| 18 | + foreach ([false, true] as $valueA) { |
| 19 | + foreach ([false, true] as $valueB) { |
| 20 | + echo throws(function() use ($optionA, $valueA, $optionB, $valueB) { |
| 21 | + new MongoDB\Driver\Manager(sprintf( |
| 22 | + 'mongodb://localhost:27017/?%s=%s&%s=%s', |
| 23 | + $optionA, |
| 24 | + $valueA ? 'true' : 'false', |
| 25 | + $optionB, |
| 26 | + $valueB ? 'true' : 'false' |
| 27 | + )); |
| 28 | + }, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
15 | 29 |
|
16 |
| -echo throws(function() { |
17 |
| - new MongoDB\Driver\Manager('mongodb://localhost:27017/?tlsInsecure=true', ['tlsAllowInvalidHostnames' => true]); |
18 |
| -}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 30 | + echo throws(function() use ($optionA, $valueA, $optionB, $valueB) { |
| 31 | + new MongoDB\Driver\Manager( |
| 32 | + sprintf( |
| 33 | + 'mongodb://localhost:27017/?%s=%s', |
| 34 | + $optionA, |
| 35 | + $valueA ? 'true' : 'false' |
| 36 | + ), |
| 37 | + [ $optionB => $valueB ] |
| 38 | + ); |
| 39 | + }, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 40 | + } |
| 41 | + } |
19 | 42 |
|
20 |
| -echo throws(function() { |
21 |
| - new MongoDB\Driver\Manager('mongodb://localhost:27017/?tlsAllowInvalidHostnames=true', ['tlsInsecure' => true]); |
22 |
| -}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; |
| 43 | + echo "\n"; |
| 44 | +} |
23 | 45 |
|
24 | 46 | ?>
|
25 | 47 | ===DONE===
|
26 | 48 | <?php exit(0); ?>
|
27 | 49 | --EXPECT--
|
28 | 50 | OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
| 51 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=false&tlsAllowInvalidHostnames=false'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 52 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 53 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 54 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 55 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=false&tlsAllowInvalidHostnames=true'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 56 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 57 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 58 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 59 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=true&tlsAllowInvalidHostnames=false'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 60 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 61 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 62 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
29 | 63 | Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=true&tlsAllowInvalidHostnames=true'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck.
|
30 | 64 | OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
31 | 65 | Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck.
|
| 66 | + |
| 67 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 68 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=false&tlsAllowInvalidCertificates=false'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 69 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 70 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 71 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 72 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=false&tlsAllowInvalidCertificates=true'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 73 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 74 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 75 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 76 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=true&tlsAllowInvalidCertificates=false'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 77 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 78 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 79 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 80 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=true&tlsAllowInvalidCertificates=true'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 81 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 82 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 83 | + |
| 84 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 85 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=false&tlsDisableOCSPEndpointCheck=false'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
32 | 86 | OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
33 | 87 | Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck.
|
34 | 88 | OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
| 89 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=false&tlsDisableOCSPEndpointCheck=true'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 90 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 91 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 92 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 93 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=true&tlsDisableOCSPEndpointCheck=false'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 94 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
35 | 95 | Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck.
|
| 96 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 97 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=true&tlsDisableOCSPEndpointCheck=true'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 98 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 99 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 100 | + |
| 101 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 102 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=false&tlsDisableCertificateRevocationCheck=false'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 103 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 104 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 105 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 106 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=false&tlsDisableCertificateRevocationCheck=true'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 107 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 108 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 109 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 110 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=true&tlsDisableCertificateRevocationCheck=false'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 111 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 112 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 113 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 114 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsInsecure=true&tlsDisableCertificateRevocationCheck=true'. tlsinsecure may not be specified with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 115 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 116 | +Failed to parse URI options: tlsinsecure may not be combined with tlsallowinvalidcertificates, tlsallowinvalidhostnames, tlsdisableocspendpointcheck, or tlsdisablecertificaterevocationcheck. |
| 117 | + |
| 118 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 119 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsAllowInvalidCertificates=false&tlsDisableOCSPEndpointCheck=false'. tlsallowinvalidcertificates may not be specified with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 120 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 121 | +Failed to parse URI options: tlsallowinvalidcertificates may not be combined with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 122 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 123 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsAllowInvalidCertificates=false&tlsDisableOCSPEndpointCheck=true'. tlsallowinvalidcertificates may not be specified with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 124 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 125 | +Failed to parse URI options: tlsallowinvalidcertificates may not be combined with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 126 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 127 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsAllowInvalidCertificates=true&tlsDisableOCSPEndpointCheck=false'. tlsallowinvalidcertificates may not be specified with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 128 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 129 | +Failed to parse URI options: tlsallowinvalidcertificates may not be combined with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 130 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 131 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsAllowInvalidCertificates=true&tlsDisableOCSPEndpointCheck=true'. tlsallowinvalidcertificates may not be specified with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 132 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 133 | +Failed to parse URI options: tlsallowinvalidcertificates may not be combined with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 134 | + |
| 135 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 136 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsAllowInvalidCertificates=false&tlsDisableCertificateRevocationCheck=false'. tlsallowinvalidcertificates may not be specified with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 137 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 138 | +Failed to parse URI options: tlsallowinvalidcertificates may not be combined with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 139 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 140 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsAllowInvalidCertificates=false&tlsDisableCertificateRevocationCheck=true'. tlsallowinvalidcertificates may not be specified with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 141 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 142 | +Failed to parse URI options: tlsallowinvalidcertificates may not be combined with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 143 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 144 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsAllowInvalidCertificates=true&tlsDisableCertificateRevocationCheck=false'. tlsallowinvalidcertificates may not be specified with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 145 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 146 | +Failed to parse URI options: tlsallowinvalidcertificates may not be combined with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 147 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 148 | +Failed to parse MongoDB URI: 'mongodb://localhost:27017/?tlsAllowInvalidCertificates=true&tlsDisableCertificateRevocationCheck=true'. tlsallowinvalidcertificates may not be specified with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 149 | +OK: Got MongoDB\Driver\Exception\InvalidArgumentException |
| 150 | +Failed to parse URI options: tlsallowinvalidcertificates may not be combined with tlsdisableocspendpointcheck or tlsdisablecertificaterevocationcheck. |
| 151 | + |
36 | 152 | ===DONE===
|
0 commit comments