Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
9ebe54a9
Unverified
Commit
9ebe54a9
authored
Jan 10, 2020
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-511: Handle autoEncryptionOpts in MongoDB\Client
parent
b2cd2866
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
Client.php
src/Client.php
+8
-0
ClientTest.php
tests/ClientTest.php
+16
-0
No files found.
src/Client.php
View file @
9ebe54a9
...
@@ -99,6 +99,14 @@ class Client
...
@@ -99,6 +99,14 @@ class Client
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" driver option'
,
$driverOptions
[
'typeMap'
],
'array'
);
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" driver option'
,
$driverOptions
[
'typeMap'
],
'array'
);
}
}
if
(
isset
(
$driverOptions
[
'autoEncryption'
][
'keyVaultClient'
]))
{
if
(
$driverOptions
[
'autoEncryption'
][
'keyVaultClient'
]
instanceof
self
)
{
$driverOptions
[
'autoEncryption'
][
'keyVaultClient'
]
=
$driverOptions
[
'autoEncryption'
][
'keyVaultClient'
]
->
manager
;
}
elseif
(
!
$driverOptions
[
'autoEncryption'
][
'keyVaultClient'
]
instanceof
Manager
)
{
throw
InvalidArgumentException
::
invalidType
(
'"keyVaultClient" autoEncryption option'
,
$driverOptions
[
'autoEncryption'
][
'keyVaultClient'
],
[
self
::
class
,
Manager
::
class
]);
}
}
$this
->
uri
=
(
string
)
$uri
;
$this
->
uri
=
(
string
)
$uri
;
$this
->
typeMap
=
isset
(
$driverOptions
[
'typeMap'
])
?
$driverOptions
[
'typeMap'
]
:
null
;
$this
->
typeMap
=
isset
(
$driverOptions
[
'typeMap'
])
?
$driverOptions
[
'typeMap'
]
:
null
;
...
...
tests/ClientTest.php
View file @
9ebe54a9
...
@@ -20,6 +20,20 @@ class ClientTest extends TestCase
...
@@ -20,6 +20,20 @@ class ClientTest extends TestCase
$this
->
assertEquals
(
'mongodb://127.0.0.1/'
,
(
string
)
$client
);
$this
->
assertEquals
(
'mongodb://127.0.0.1/'
,
(
string
)
$client
);
}
}
/**
* @doesNotPerformAssertions
*/
public
function
testConstructorAutoEncryptionOpts
()
{
$autoEncryptionOpts
=
[
'keyVaultClient'
=>
new
Client
(
static
::
getUri
()),
'keyVaultNamespace'
=>
'default.keys'
,
'kmsProviders'
=>
[
'aws'
=>
[
'accessKeyId'
=>
'abc'
,
'secretAccessKey'
=>
'def'
]],
];
new
Client
(
static
::
getUri
(),
[],
[
'autoEncryption'
=>
$autoEncryptionOpts
]);
}
/**
/**
* @dataProvider provideInvalidConstructorDriverOptions
* @dataProvider provideInvalidConstructorDriverOptions
*/
*/
...
@@ -37,6 +51,8 @@ class ClientTest extends TestCase
...
@@ -37,6 +51,8 @@ class ClientTest extends TestCase
$options
[][]
=
[
'typeMap'
=>
$value
];
$options
[][]
=
[
'typeMap'
=>
$value
];
}
}
$options
[][]
=
[
'autoEncryption'
=>
[
'keyVaultClient'
=>
'foo'
]];
return
$options
;
return
$options
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment