7
7
8
8
namespace Magento \GraphQlResolverCache \Model \Resolver \Result \Cache ;
9
9
10
+ use Magento \Framework \App \DeploymentConfig ;
11
+ use Magento \Framework \Config \ConfigOptionsListConstants ;
10
12
use Magento \GraphQl \Model \Query \ContextFactoryInterface ;
11
13
use Magento \GraphQlResolverCache \Model \Resolver \Result \CacheKey \CalculationException ;
12
14
use Magento \GraphQlResolverCache \Model \Resolver \Result \CacheKey \Calculator ;
15
17
use Magento \GraphQlResolverCache \Model \Resolver \Result \CacheKey \ParentValue \ProcessedValueFactorInterface ;
16
18
use Magento \GraphQlResolverCache \Model \Resolver \Result \ValueProcessorInterface ;
17
19
use Magento \TestFramework \Helper \Bootstrap ;
18
- use Psr \Log \LoggerInterface ;
19
20
20
21
/**
21
22
* Test for graphql resolver-level cache key calculator.
@@ -183,6 +184,8 @@ private function resetMocksForObjectManager(array $factorDataArray)
183
184
*/
184
185
public function keyFactorDataProvider ()
185
186
{
187
+ $ salt = Bootstrap::getObjectManager ()->get (DeploymentConfig::class)
188
+ ->get (ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY );
186
189
return [
187
190
'no factors ' => [
188
191
'factorProviders ' => [],
@@ -198,7 +201,7 @@ public function keyFactorDataProvider()
198
201
],
199
202
],
200
203
'parentResolverData ' => null ,
201
- 'expectedCacheKey ' => hash ('sha256 ' , strtoupper ('testValue ' )),
204
+ 'expectedCacheKey ' => hash ('sha256 ' , strtoupper ('testValue ' ) . " | $ salt " ),
202
205
],
203
206
'unsorted multiple factors ' => [
204
207
'factorProviders ' => [
@@ -219,7 +222,10 @@ public function keyFactorDataProvider()
219
222
],
220
223
],
221
224
'parentResolverData ' => null ,
222
- 'expectedCacheKey ' => hash ('sha256 ' , strtoupper ('a_testValue|b_testValue|c_testValue ' )),
225
+ 'expectedCacheKey ' => hash (
226
+ 'sha256 ' ,
227
+ strtoupper ('a_testValue|b_testValue|c_testValue ' ) . "| $ salt "
228
+ ),
223
229
],
224
230
'unsorted multiple factors with parent data ' => [
225
231
'factorProviders ' => [
@@ -242,7 +248,10 @@ public function keyFactorDataProvider()
242
248
'parentResolverData ' => [
243
249
'object_id ' => 123
244
250
],
245
- 'expectedCacheKey ' => hash ('sha256 ' , strtoupper ('a_testValue|object_123|c_testValue ' )),
251
+ 'expectedCacheKey ' => hash (
252
+ 'sha256 ' ,
253
+ strtoupper ('a_testValue|object_123|c_testValue ' ) . "| $ salt "
254
+ ),
246
255
],
247
256
'unsorted multifactor with no parent data and parent factored interface ' => [
248
257
'factorProviders ' => [
@@ -263,7 +272,10 @@ public function keyFactorDataProvider()
263
272
],
264
273
],
265
274
'parentResolverData ' => null ,
266
- 'expectedCacheKey ' => hash ('sha256 ' , strtoupper ('a_testValue|some value|c_testValue ' )),
275
+ 'expectedCacheKey ' => hash (
276
+ 'sha256 ' ,
277
+ strtoupper ('a_testValue|some value|c_testValue ' ) . "| $ salt "
278
+ ),
267
279
],
268
280
];
269
281
}
@@ -302,7 +314,10 @@ public function testValueProcessingIsCalledForParentValueFromCache()
302
314
]);
303
315
304
316
$ key = $ keyCalculator ->calculateCacheKey ($ value );
305
- $ this ->assertEquals ('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ' , $ key );
317
+ $ salt = Bootstrap::getObjectManager ()->get (DeploymentConfig::class)
318
+ ->get (ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY );
319
+ $ expectedResult = hash ('sha256 ' , "| $ salt " );
320
+ $ this ->assertEquals ($ expectedResult , $ key );
306
321
307
322
$ this ->objectManager ->removeSharedInstance ('TestValueFactorMock ' );
308
323
$ this ->objectManager ->removeSharedInstance ('TestContextFactorMock ' );
@@ -366,7 +381,10 @@ public function testValueProcessingIsNotCalledForParentValueFromResolver()
366
381
]);
367
382
368
383
$ key = $ keyCalculator ->calculateCacheKey ($ value );
369
- $ this ->assertEquals ('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ' , $ key );
384
+ $ salt = Bootstrap::getObjectManager ()->get (DeploymentConfig::class)
385
+ ->get (ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY );
386
+ $ expectedResult = hash ('sha256 ' , "| $ salt " );
387
+ $ this ->assertEquals ($ expectedResult , $ key );
370
388
371
389
$ this ->objectManager ->removeSharedInstance ('TestValueFactorMock ' );
372
390
$ this ->objectManager ->removeSharedInstance ('TestContextFactorMock ' );
@@ -404,7 +422,10 @@ public function testValueProcessingIsSkippedForContextOnlyFactors()
404
422
]);
405
423
406
424
$ key = $ keyCalculator ->calculateCacheKey ($ value );
407
- $ this ->assertEquals ('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ' , $ key );
425
+ $ salt = Bootstrap::getObjectManager ()->get (DeploymentConfig::class)
426
+ ->get (ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY );
427
+ $ expectedResult = hash ('sha256 ' , "| $ salt " );
428
+ $ this ->assertEquals ($ expectedResult , $ key );
408
429
409
430
$ this ->objectManager ->removeSharedInstance ('TestContextFactorMock ' );
410
431
}
0 commit comments