From 12e2e849ab6c76de031d60dd944dcf80961cec0b Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 23 Jul 2024 22:01:54 +0200 Subject: [PATCH] add test for deploy cfconfig to set empty value to empty --- .github/workflows/bad-cfconfig.yml | 17 +++++++++++++- .../.CFConfig-empty-cacheHandlers.json | 3 +++ custom/bad-cfconfig/debug.cfm | 22 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 custom/bad-cfconfig/.CFConfig-empty-cacheHandlers.json diff --git a/.github/workflows/bad-cfconfig.yml b/.github/workflows/bad-cfconfig.yml index 31d6870..c08fffc 100644 --- a/.github/workflows/bad-cfconfig.yml +++ b/.github/workflows/bad-cfconfig.yml @@ -97,7 +97,6 @@ jobs: env: check_extensions: B737ABC4-D43F-4D91-8E8E973E37C40D1B:2.0.0.28-SNAPSHOT - - name: Copy .CFConfig-newer-extension.json5 into /deploy if: always() run: | @@ -115,6 +114,22 @@ jobs: check_extensions: B737ABC4-D43F-4D91-8E8E973E37C40D1B:2.0.0.28-SNAPSHOT check_extensions_since: 6.1.1 + - name: Copy .CFConfig-empty-cacheHandlers.json5 into /deploy + if: always() + run: | + mkdir -p /home/runner/work/_actions/lucee/script-runner/main/temp/lucee/lucee-server/deploy/ + cp -a ${{ github.workspace }}/custom/bad-cfconfig/.CFConfig-empty-cacheHandlers.json5 /home/runner/work/_actions/lucee/script-runner/main/temp/lucee/lucee-server/deploy/.CFConfig.json + - name: Check good .CFConfig with newer image extension ( via /deploy ) + uses: lucee/script-runner@main + if: always() + with: + webroot: ${{ github.workspace }}/custom/bad-cfconfig + execute: /debug.cfm + luceeVersionQuery: ${{ matrix.luceeVersion }} + preCleanup: false + env: + expect_empty_config: cacheHandlers + - name: Check bad .CFConfig with unknown extension version LUCEE_BASE_CONFIG uses: lucee/script-runner@main if: always() diff --git a/custom/bad-cfconfig/.CFConfig-empty-cacheHandlers.json b/custom/bad-cfconfig/.CFConfig-empty-cacheHandlers.json new file mode 100644 index 0000000..23e6ea5 --- /dev/null +++ b/custom/bad-cfconfig/.CFConfig-empty-cacheHandlers.json @@ -0,0 +1,3 @@ +{ + "cacheHandlers": {} +} \ No newline at end of file diff --git a/custom/bad-cfconfig/debug.cfm b/custom/bad-cfconfig/debug.cfm index ec602e1..f28100d 100644 --- a/custom/bad-cfconfig/debug.cfm +++ b/custom/bad-cfconfig/debug.cfm @@ -91,6 +91,7 @@ check_extensions = server.system.environment.check_extensions ?: ""; check_extensions_since = server.system.environment.check_extensions_since ?: ""; + expect_empty_config = server.system.environment.expect_empty_config ?: "";\ // don't crash on older versions if ( len( check_extensions_since ) ) { @@ -149,6 +150,27 @@ } } } + + if ( len( expect_empty_config ) ) { + _logger( "" ); + _logger( "expect_empty_config: #expect_empty_config#" ) + expect_empty_config = ListToArray( expect_empty_config, "," ); + + cfconfig = deserializeJSON( fileRead( expandPath('{lucee-config}.CFConfig.json') ) ); + + loop array=expect_empty_config item="prop"{ + if ( !structKeyExists( cfconfig, "prop" ) ){ + _logger( "ERROR: cfconfig property doesn't exist [#prop#]", true); + } else if ( isSimpleValue (config[prop ] ) ) { + _logger( "ERROR: cfconfig property [#prop#] should be an array or struct, [#cfconfig[ prop ].toJson()#]", true); + } else if ( len( cfconfig[ prop] ) != 0 ){ + _logger( "ERROR: cfconfig property [#prop#] should be empty [#cfconfig[ prop ].toJson()# ]", true); + } + } + } + + + if ( structKeyExists( logs, "err.log" ) && len( logs["err.log"] ?: "" ) ) { _logger( logs[ "err.log" ] , true);