@@ -169,15 +169,20 @@ START_TEST(test_cache_encrypt_no_secret) {
169169
170170 /* get cfg and temporarily remove the secret to simulate missing passphrase */
171171 oidc_cfg_t * cfg = oidc_test_cfg_get ();
172- const char * old_secret = cfg -> crypto_passphrase . secret1 ;
172+ const char * old_secret = oidc_cfg_crypto_passphrase_secret1_get ( cfg , r ) ;
173173 cfg -> crypto_passphrase .secret1 = NULL ;
174174 cfg -> cache .encrypt = 1 ;
175175
176- /* set should fail when encryption is on but no secret is set */
176+ /* fail when value is too short and compression fails */
177177 ck_assert_int_eq (oidc_cache_set (r , OIDC_CACHE_SECTION_SESSION , "nokey" , "v" , expiry ), FALSE);
178178
179- /* get should also fail */
180- ck_assert_int_eq (oidc_cache_get (r , OIDC_CACHE_SECTION_SESSION , "nokey" , & value ), FALSE);
179+ /* do not fail when encryption is on but no secret is set (long enough value to compress) */
180+ ck_assert_int_eq (oidc_cache_set (r , OIDC_CACHE_SECTION_SESSION , "nokey" ,
181+ "vadadfsssssssssssssssssssssssssssssssssssssssssssssssssssssssss" , expiry ),
182+ TRUE);
183+
184+ /* get should not fail because a secret should be generated */
185+ ck_assert_int_eq (oidc_cache_get (r , OIDC_CACHE_SECTION_SESSION , "nokey" , & value ), TRUE);
181186
182187 /* restore secret */
183188 cfg -> crypto_passphrase .secret1 = (char * )old_secret ;
@@ -199,8 +204,8 @@ START_TEST(test_cache_second_passphrase_retry) {
199204
200205 /* prepare cfg and secrets */
201206 oidc_cfg_t * cfg = oidc_test_cfg_get ();
202- const char * old_s1 = cfg -> crypto_passphrase . secret1 ;
203- const char * old_s2 = cfg -> crypto_passphrase . secret2 ;
207+ const char * old_s1 = oidc_cfg_crypto_passphrase_secret1_get ( cfg , r ) ;
208+ const char * old_s2 = oidc_cfg_crypto_passphrase_secret2_get ( cfg ) ;
204209 int old_encrypt = cfg -> cache .encrypt ;
205210
206211 /* set initial secret and ensure encryption is enabled */
@@ -270,8 +275,8 @@ START_TEST(test_cache_secret1_empty_secret2_fallback) {
270275
271276 /* prepare cfg and secrets */
272277 oidc_cfg_t * cfg = oidc_test_cfg_get ();
273- const char * old_s1 = cfg -> crypto_passphrase . secret1 ;
274- const char * old_s2 = cfg -> crypto_passphrase . secret2 ;
278+ const char * old_s1 = oidc_cfg_crypto_passphrase_secret1_get ( cfg , r ) ;
279+ const char * old_s2 = oidc_cfg_crypto_passphrase_secret2_get ( cfg ) ;
275280 int old_encrypt = cfg -> cache .encrypt ;
276281
277282 /* set initial secret and ensure encryption is enabled */
@@ -337,8 +342,8 @@ START_TEST(test_cache_compression_enabled_set_get) {
337342 /* verify encryption+compression works by trying to create a JWT with the current cfg secret */
338343 oidc_cfg_t * cfg = oidc_test_cfg_get ();
339344 oidc_crypto_passphrase_t passphrase ;
340- passphrase .secret1 = cfg -> crypto_passphrase . secret1 ;
341- passphrase .secret2 = cfg -> crypto_passphrase . secret2 ;
345+ passphrase .secret1 = oidc_cfg_crypto_passphrase_secret1_get ( cfg , r ) ;
346+ passphrase .secret2 = oidc_cfg_crypto_passphrase_secret2_get ( cfg ) ;
342347 char * encoded = NULL ;
343348 apr_byte_t forced_no_compress = FALSE;
344349 if (!oidc_util_jwt_create (r , & passphrase , "probe" , & encoded )) {
@@ -368,8 +373,8 @@ START_TEST(test_cache_compression_enabled_second_passphrase) {
368373
369374 /* prepare cfg and secrets */
370375 oidc_cfg_t * cfg = oidc_test_cfg_get ();
371- const char * old_s1 = cfg -> crypto_passphrase . secret1 ;
372- const char * old_s2 = cfg -> crypto_passphrase . secret2 ;
376+ const char * old_s1 = oidc_cfg_crypto_passphrase_secret1_get ( cfg , r ) ;
377+ const char * old_s2 = oidc_cfg_crypto_passphrase_secret2_get ( cfg ) ;
373378 int old_encrypt = cfg -> cache .encrypt ;
374379
375380 /* set initial secret and ensure encryption is enabled */
@@ -379,8 +384,8 @@ START_TEST(test_cache_compression_enabled_second_passphrase) {
379384
380385 /* verify encryption+compression works for this cfg; fall back to no-compress if not */
381386 oidc_crypto_passphrase_t passphrase ;
382- passphrase .secret1 = cfg -> crypto_passphrase . secret1 ;
383- passphrase .secret2 = cfg -> crypto_passphrase . secret2 ;
387+ passphrase .secret1 = oidc_cfg_crypto_passphrase_secret1_get ( cfg , r ) ;
388+ passphrase .secret2 = oidc_cfg_crypto_passphrase_secret2_get ( cfg ) ;
384389 char * encoded = NULL ;
385390 apr_byte_t forced_no_compress = FALSE;
386391 if (!oidc_util_jwt_create (r , & passphrase , "probe" , & encoded )) {
@@ -428,8 +433,8 @@ START_TEST(test_cache_compression_enabled_empty_secret2_fallback) {
428433
429434 /* prepare cfg and secrets */
430435 oidc_cfg_t * cfg = oidc_test_cfg_get ();
431- const char * old_s1 = cfg -> crypto_passphrase . secret1 ;
432- const char * old_s2 = cfg -> crypto_passphrase . secret2 ;
436+ const char * old_s1 = oidc_cfg_crypto_passphrase_secret1_get ( cfg , r ) ;
437+ const char * old_s2 = oidc_cfg_crypto_passphrase_secret2_get ( cfg ) ;
433438 int old_encrypt = cfg -> cache .encrypt ;
434439
435440 cfg -> crypto_passphrase .secret1 = "cmp_origsecret012345678901234567" ;
@@ -438,8 +443,8 @@ START_TEST(test_cache_compression_enabled_empty_secret2_fallback) {
438443
439444 /* verify encryption+compression works; fall back to no-compress if not */
440445 oidc_crypto_passphrase_t passphrase2 ;
441- passphrase2 .secret1 = cfg -> crypto_passphrase . secret1 ;
442- passphrase2 .secret2 = cfg -> crypto_passphrase . secret2 ;
446+ passphrase2 .secret1 = oidc_cfg_crypto_passphrase_secret1_get ( cfg , r ) ;
447+ passphrase2 .secret2 = oidc_cfg_crypto_passphrase_secret2_get ( cfg ) ;
443448 char * encoded2 = NULL ;
444449 apr_byte_t forced_no_compress = FALSE;
445450 if (!oidc_util_jwt_create (r , & passphrase2 , "probe" , & encoded2 )) {
0 commit comments