|
42 | 42 | with: |
43 | 43 | ruby-version: ${{ matrix.ruby }} |
44 | 44 | bundler-cache: true |
| 45 | + - name: Update openssl on macOS |
| 46 | + if: runner.os == 'macOS' |
| 47 | + run: | |
| 48 | + brew update |
| 49 | + brew upgrade openssl@3 || true |
45 | 50 | - name: Chef Omnibus download Test |
46 | 51 | run: bundle exec mixlib-install download chef |
47 | 52 | - name: Chef Licensed download Test |
@@ -194,10 +199,10 @@ jobs: |
194 | 199 | cat install_licensed.sh |
195 | 200 | - name: Verify license_id is present in script |
196 | 201 | run: | |
197 | | - if grep -q "license_id='test-license-12345'" install_licensed.sh; then |
198 | | - echo "✓ License ID found pre-set in script" |
| 202 | + if grep -q 'license_id="test-license-12345"' install_licensed.sh; then |
| 203 | + echo "License ID found pre-set in script" |
199 | 204 | else |
200 | | - echo "✗ License ID not found in script" |
| 205 | + echo "License ID not found in script" |
201 | 206 | exit 1 |
202 | 207 | fi |
203 | 208 | test-install-ps1-with-license: |
@@ -227,9 +232,124 @@ jobs: |
227 | 232 | - name: Verify license_id is present in script |
228 | 233 | run: | |
229 | 234 | $content = Get-Content install_licensed.ps1 -Raw |
230 | | - if ($content -match "install -license_id 'test-license-12345'") { |
231 | | - Write-Host "✓ License ID found in install command" |
| 235 | + if ($content -match "license_id = 'test-license-12345'") { |
| 236 | + Write-Host "License ID found in install command" |
232 | 237 | } else { |
233 | | - Write-Host "✗ License ID not found in script" |
| 238 | + Write-Host "License ID not found in script" |
234 | 239 | exit 1 |
235 | 240 | } |
| 241 | + test-script-generator-unix: |
| 242 | + name: Test ScriptGenerator on Linux |
| 243 | + runs-on: ubuntu-latest |
| 244 | + steps: |
| 245 | + - name: Checkout code |
| 246 | + uses: actions/checkout@v6 |
| 247 | + - name: Setup Ruby |
| 248 | + uses: ruby/setup-ruby@v1 |
| 249 | + with: |
| 250 | + ruby-version: 3.4 |
| 251 | + bundler-cache: true |
| 252 | + - name: Test ScriptGenerator without license_id |
| 253 | + run: | |
| 254 | + bundle exec ruby -e " |
| 255 | + require 'bundler/setup' |
| 256 | + require 'mixlib/install/script_generator' |
| 257 | +
|
| 258 | + # Generate script without license_id |
| 259 | + generator = Mixlib::Install::ScriptGenerator.new('latest', false, { |
| 260 | + omnibus_url: 'https://omnitruck.chef.io/install.sh' |
| 261 | + }) |
| 262 | + script = generator.install_command |
| 263 | +
|
| 264 | + puts '=== Generated Script (no license) ===' |
| 265 | + puts script |
| 266 | + puts '===================================' |
| 267 | +
|
| 268 | + # Verify expected content |
| 269 | + raise 'Missing chef_omnibus_url' unless script.include?('chef_omnibus_url') |
| 270 | + raise 'Missing version' unless script.include?('version=') |
| 271 | + puts 'Script generated successfully without license_id' |
| 272 | + " |
| 273 | + - name: Test ScriptGenerator with license_id |
| 274 | + run: | |
| 275 | + bundle exec ruby -e " |
| 276 | + require 'bundler/setup' |
| 277 | + require 'mixlib/install/script_generator' |
| 278 | +
|
| 279 | + # Generate script with license_id |
| 280 | + generator = Mixlib::Install::ScriptGenerator.new('latest', false, { |
| 281 | + omnibus_url: 'https://omnitruck.chef.io/install.sh', |
| 282 | + license_id: 'test-license-unix-123' |
| 283 | + }) |
| 284 | + script = generator.install_command |
| 285 | +
|
| 286 | + puts '=== Generated Script (with license) ===' |
| 287 | + puts script |
| 288 | + puts '========================================' |
| 289 | +
|
| 290 | + # Verify license_id is in install_flags |
| 291 | + raise 'Missing license_id in install_flags' unless script.include?('-l test-license-unix-123') |
| 292 | + puts 'License ID correctly added to install_flags' |
| 293 | + " |
| 294 | + test-script-generator-windows: |
| 295 | + name: Test ScriptGenerator on Windows |
| 296 | + runs-on: windows-latest |
| 297 | + steps: |
| 298 | + - name: Enable long paths on Windows |
| 299 | + run: | |
| 300 | + New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force -ErrorAction SilentlyContinue |
| 301 | + git config --global core.longpaths true |
| 302 | + - name: Checkout code |
| 303 | + uses: actions/checkout@v6 |
| 304 | + - name: Setup Ruby |
| 305 | + uses: ruby/setup-ruby@v1 |
| 306 | + with: |
| 307 | + ruby-version: 3.4 |
| 308 | + bundler-cache: true |
| 309 | + - name: Create test script without license_id |
| 310 | + run: | |
| 311 | + @" |
| 312 | + require 'bundler/setup' |
| 313 | + require 'mixlib/install/script_generator' |
| 314 | +
|
| 315 | + generator = Mixlib::Install::ScriptGenerator.new('latest', true, { |
| 316 | + omnibus_url: 'https://omnitruck.chef.io/install.sh' |
| 317 | + }) |
| 318 | +
|
| 319 | + script = generator.install_command |
| 320 | + puts '=== Generated Script (no license) ===' |
| 321 | + puts script |
| 322 | + puts '===================================' |
| 323 | +
|
| 324 | + unless script.include?('chef_metadata_url') && script.include?('version') |
| 325 | + raise 'Missing required variables' |
| 326 | + end |
| 327 | +
|
| 328 | + puts 'Script generated successfully without license_id' |
| 329 | + "@ | Out-File -FilePath test_no_license.rb -Encoding utf8 |
| 330 | + - name: Test ScriptGenerator without license_id |
| 331 | + run: bundle exec ruby test_no_license.rb |
| 332 | + - name: Create test script with license_id |
| 333 | + run: | |
| 334 | + @" |
| 335 | + require 'bundler/setup' |
| 336 | + require 'mixlib/install/script_generator' |
| 337 | +
|
| 338 | + generator = Mixlib::Install::ScriptGenerator.new('latest', true, { |
| 339 | + omnibus_url: 'https://omnitruck.chef.io/install.sh', |
| 340 | + license_id: 'test-license-win-456' |
| 341 | + }) |
| 342 | +
|
| 343 | + script = generator.install_command |
| 344 | + puts '=== Generated Script (with license) ===' |
| 345 | + puts script |
| 346 | + puts '========================================' |
| 347 | +
|
| 348 | + unless script.include?('$license_id = "test-license-win-456"') |
| 349 | + raise 'Missing license_id variable' |
| 350 | + end |
| 351 | +
|
| 352 | + puts 'License ID correctly added as PowerShell variable' |
| 353 | + "@ | Out-File -FilePath test_with_license.rb -Encoding utf8 |
| 354 | + - name: Test ScriptGenerator with license_id |
| 355 | + run: bundle exec ruby test_with_license.rb |
0 commit comments