Skip to content

Commit 781e640

Browse files
committed
Prepend encryption flag iue to platform metadata
Sending extra metadata in the handshake will allow us to detect when encryption is enabled. `iue` for In-Use Ecnryption was chosen to save bytes (as metadata will be truncated if it exceeds byte limit)
1 parent c6cecce commit 781e640

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

src/ValueObject/DriverOptions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ private function withDriverInfo(array $driver): self
129129
$mergedDriver['platform'] = $driver['platform'];
130130
}
131131

132+
if ($this->isAutoEncryptionEnabled()) {
133+
$mergedDriver['platform'] = trim(sprintf('iue %s', $driver['platform'] ?? ''));
134+
}
135+
132136
return new self(
133137
typeMap: $this->typeMap,
134138
builderEncoder: $this->builderEncoder,

tests/ValueObject/DriverOptionsTest.php

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,67 @@ public static function provideOptions(): \Generator
8888
]
8989
];
9090

91+
yield 'encryption enabled' => [
92+
['autoEncryption' => [
93+
'keyVaultNamespace' => 'foo',
94+
]],
95+
[
96+
'typeMap' => [
97+
'array' => BSONArray::class,
98+
'document' => BSONDocument::class,
99+
'root' => BSONDocument::class,
100+
],
101+
'autoEncryption' => [
102+
'keyVaultNamespace' => 'foo',
103+
],
104+
'builderEncoder' => new BuilderEncoder(),
105+
'driver' => [
106+
'name' => 'PHPLIB',
107+
'platform' => 'iue',
108+
]
109+
]
110+
];
111+
112+
yield 'encryption enabled with platform' => [
113+
[
114+
'autoEncryption' => [
115+
'keyVaultNamespace' => 'foo',
116+
],
117+
'driver' => [
118+
'platform' => 'bar'
119+
]
120+
],
121+
[
122+
'typeMap' => [
123+
'array' => BSONArray::class,
124+
'document' => BSONDocument::class,
125+
'root' => BSONDocument::class,
126+
],
127+
'autoEncryption' => [
128+
'keyVaultNamespace' => 'foo',
129+
],
130+
'builderEncoder' => new BuilderEncoder(),
131+
'driver' => [
132+
'name' => 'PHPLIB',
133+
'platform' => 'iue bar',
134+
]
135+
]
136+
];
137+
91138
yield 'extra options' => [
92139
[
93140
'typeMap' => [],
94141
'builderEncoder' => new BuilderEncoder(),
95142
'autoEncryption' => [],
96143
'some' => 'option',
97-
'some_other' => ['option' => 'too']
144+
'some_other' => ['option' => 'too'],
145+
'driver' => ['platform' => 'foo',]
98146
],
99147
[
100148
'builderEncoder' => new BuilderEncoder(),
101149
'driver' => [
102150
'name' => 'PHPLIB',
151+
'platform' => 'foo',
103152
],
104153
'some' => 'option',
105154
'some_other' => ['option' => 'too']

0 commit comments

Comments
 (0)