mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-04-26 01:48:06 +02:00
03fcb6b9ef
* Use non-breaking space in OS axis labels * Revise titles and Manager construction in autoEncryption tests * Define CSFLE_KEY_VAULT_NS and CSFLE_LOCAL_KEY constants The value for CSFLE_KEY_VAULT_NS is based on the example from PHPLIB-826. This was not required but helps makes all tests consistent and will make it easier if we need to add functionality to a helper to drop the key vault collection before a test. Using CSFLE_LOCAL_KEY allows removal of a duplicated string literal in various CSFLE tests. Although the new constant wasn't required for all tests (empty strings worked fine to satisfy option validation), using a constant helps ensure consistency across the test suite. Also use create_test_manager() in more places when basic.inc is included. The remaining instances of direct Manager construction should only be in tests where basic.inc isn't used.
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
--TEST--
|
|
MongoDB\Driver\ClientEncryption::createDataKey() with invalid keyAltNames
|
|
--SKIPIF--
|
|
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
|
|
<?php skip_if_not_libmongocrypt(); ?>
|
|
<?php skip_if_not_live(); ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
require_once __DIR__ . "/../utils/basic.inc";
|
|
|
|
$tests = [
|
|
['keyAltNames' => 'foo'],
|
|
['keyAltNames' => [0 => []]],
|
|
['keyAltNames' => ['foo' => []]],
|
|
];
|
|
|
|
$manager = create_test_manager();
|
|
$clientEncryption = $manager->createClientEncryption([
|
|
'keyVaultNamespace' => CSFLE_KEY_VAULT_NS,
|
|
'kmsProviders' => ['local' => ['key' => new MongoDB\BSON\Binary(CSFLE_LOCAL_KEY, 0)]],
|
|
]);
|
|
|
|
foreach ($tests as $opts) {
|
|
echo throws(function () use ($clientEncryption, $opts) {
|
|
$clientEncryption->createDataKey('local', $opts);
|
|
}, MongoDB\Driver\Exception\InvalidArgumentException::class), "\n";
|
|
}
|
|
|
|
?>
|
|
===DONE===
|
|
<?php exit(0); ?>
|
|
--EXPECT--
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected keyAltNames to be array, string given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected keyAltName with index "0" to be string, array given
|
|
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
|
|
Expected keyAltName with index "foo" to be string, array given
|
|
===DONE===
|