mirror of
https://github.com/j3ssie/osmedeus.git
synced 2026-09-11 20:27:47 +02:00
feat: add string utility functions and decision condition tests
- Add cut_to_file() and cut_space() utility functions for file processing and field extraction - Add comprehensive E2E tests for decision condition routing with function/command execution - Add test workflows for decision conditions and inline decision execution - Add short-mode skip guards to all cloud E2E tests to allow quick test runs - Register new functions in constants and goja runtime
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
name: test-decision-conditions
|
||||
kind: module
|
||||
description: Test condition-based decision routing with JS boolean expressions
|
||||
tags: test,decision,conditions
|
||||
|
||||
params:
|
||||
- name: target
|
||||
required: true
|
||||
- name: enable_extra
|
||||
type: string
|
||||
default: "true"
|
||||
- name: scan_depth
|
||||
type: string
|
||||
default: "3"
|
||||
|
||||
steps:
|
||||
# Step 1: Single condition match with function
|
||||
- name: check-target
|
||||
type: bash
|
||||
command: echo "Checking target"
|
||||
exports:
|
||||
has_target: "true"
|
||||
decision:
|
||||
conditions:
|
||||
- if: "{{has_target}}"
|
||||
function: "log_info('[COND] Target is present')"
|
||||
|
||||
# Step 2: Multiple conditions - all matching ones execute
|
||||
- name: check-flags
|
||||
type: bash
|
||||
command: echo "Checking flags"
|
||||
exports:
|
||||
flag_a: "true"
|
||||
flag_b: "true"
|
||||
flag_c: "false"
|
||||
decision:
|
||||
conditions:
|
||||
- if: "{{flag_a}}"
|
||||
function: "log_info('[COND-A] Flag A is true')"
|
||||
- if: "{{flag_b}}"
|
||||
function: "log_info('[COND-B] Flag B is true')"
|
||||
- if: "{{flag_c}}"
|
||||
function: "log_info('[COND-C] Flag C should not appear')"
|
||||
|
||||
# Step 3: Condition with inline command
|
||||
- name: check-extra
|
||||
type: bash
|
||||
command: echo "Checking extra"
|
||||
exports:
|
||||
run_extra: "{{enable_extra}}"
|
||||
decision:
|
||||
conditions:
|
||||
- if: "{{run_extra}}"
|
||||
command: echo "[COND-CMD] Extra command executed"
|
||||
|
||||
# Step 4: Condition with goto
|
||||
- name: check-skip
|
||||
type: bash
|
||||
command: echo "Checking skip condition"
|
||||
exports:
|
||||
should_skip: "true"
|
||||
decision:
|
||||
conditions:
|
||||
- if: "{{should_skip}}"
|
||||
function: "log_info('[COND-GOTO] Jumping to final')"
|
||||
goto: final-step
|
||||
|
||||
# This step should be skipped via goto
|
||||
- name: skipped-step
|
||||
type: bash
|
||||
command: echo "[SKIPPED] This should not appear"
|
||||
|
||||
# Step 5: Conditions coexisting with switch/cases
|
||||
- name: final-step
|
||||
type: bash
|
||||
command: echo "[FINAL] Scan complete for {{target}}"
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
name: test-decision-inline
|
||||
kind: module
|
||||
description: Test inline command/function execution in decision cases
|
||||
tags: test,decision,inline
|
||||
|
||||
params:
|
||||
- name: target
|
||||
required: true
|
||||
- name: scan_mode
|
||||
type: string
|
||||
default: "quick"
|
||||
|
||||
steps:
|
||||
# Step 1: Test inline function for visible output
|
||||
- name: detect-mode
|
||||
type: bash
|
||||
command: echo "Detecting scan mode"
|
||||
exports:
|
||||
mode: "{{scan_mode}}"
|
||||
decision:
|
||||
switch: "{{mode}}"
|
||||
cases:
|
||||
"quick":
|
||||
function: "log_info('[INLINE] Quick scan selected')"
|
||||
"deep":
|
||||
function: "log_info('[INLINE] Deep scan selected')"
|
||||
default:
|
||||
function: "log_info('[INLINE] Default mode selected')"
|
||||
|
||||
# Step 2: Test inline functions (plural) with multiple functions
|
||||
- name: setup-scan
|
||||
type: bash
|
||||
command: echo "Setting up scan"
|
||||
exports:
|
||||
setup_mode: "{{scan_mode}}"
|
||||
decision:
|
||||
switch: "{{setup_mode}}"
|
||||
cases:
|
||||
"quick":
|
||||
functions:
|
||||
- "log_info('[MULTI-FUNC-1] Configuring quick scan')"
|
||||
- "log_info('[MULTI-FUNC-2] Quick scan configured')"
|
||||
"deep":
|
||||
functions:
|
||||
- "log_info('[MULTI-FUNC-1] Configuring deep scan')"
|
||||
- "log_info('[MULTI-FUNC-2] Deep scan configured')"
|
||||
|
||||
# Step 3: Test inline command execution (verifiable via step table)
|
||||
- name: run-inline-cmd
|
||||
type: bash
|
||||
command: echo "Running inline command test"
|
||||
exports:
|
||||
cmd_mode: "{{scan_mode}}"
|
||||
decision:
|
||||
switch: "{{cmd_mode}}"
|
||||
cases:
|
||||
"quick":
|
||||
command: echo "quick inline command executed"
|
||||
"deep":
|
||||
command: echo "deep inline command executed"
|
||||
|
||||
# Step 4: Test inline commands (plural) - multiple bash commands
|
||||
- name: run-multi-cmd
|
||||
type: bash
|
||||
command: echo "Running multi-command test"
|
||||
exports:
|
||||
multi_mode: "{{scan_mode}}"
|
||||
decision:
|
||||
switch: "{{multi_mode}}"
|
||||
cases:
|
||||
"quick":
|
||||
commands:
|
||||
- echo "quick cmd 1"
|
||||
- echo "quick cmd 2"
|
||||
|
||||
# Step 5: Test inline function with goto (both execute)
|
||||
- name: branch-and-jump
|
||||
type: bash
|
||||
command: echo "Branch and jump phase"
|
||||
exports:
|
||||
jump_mode: "{{scan_mode}}"
|
||||
decision:
|
||||
switch: "{{jump_mode}}"
|
||||
cases:
|
||||
"quick":
|
||||
function: "log_info('[INLINE-GOTO] Quick inline before jump')"
|
||||
goto: final-step
|
||||
"deep":
|
||||
function: "log_info('[INLINE-GOTO] Deep inline before jump')"
|
||||
goto: final-step
|
||||
default:
|
||||
function: "log_info('[INLINE-GOTO] Default inline before jump')"
|
||||
goto: final-step
|
||||
|
||||
# This step should be skipped when goto is used
|
||||
- name: skipped-step
|
||||
type: bash
|
||||
command: echo "[SKIPPED] This should not appear"
|
||||
|
||||
- name: final-step
|
||||
type: bash
|
||||
command: echo "[FINAL] Scan complete for {{target}} in {{scan_mode}} mode"
|
||||
Reference in New Issue
Block a user