*** Settings ***
Documentation    Smoke tests for Config CLI commands (set, get, list)
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER}    ${CURDIR}/helper_config_cli.py

*** Test Cases ***
Config List Shows Settings
    [Documentation]    Verify that ``config list`` outputs known settings
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-cli-list-ok

Config List JSON Format
    [Documentation]    Verify that ``config list --format json`` produces valid JSON
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-json    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-cli-list-json-ok

Config Set Get Roundtrip
    [Documentation]    Verify that ``config set`` followed by ``config get`` returns the value
    [Tags]    tdd_issue    tdd_issue_4302    tdd_expected_fail

    ${result}=    Run Process    ${PYTHON}    ${HELPER}    set-get-roundtrip    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-cli-set-get-roundtrip-ok

Config Secret Masking
    [Documentation]    Verify that secret values are masked in list output
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    secret-masking    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-cli-secret-masking-ok

Config Show Secrets Flag
    [Documentation]    Verify that ``--show-secrets`` flag is accepted
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    show-secrets    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-cli-show-secrets-ok

Config List With Filter
    [Documentation]    Verify that ``config list`` with regex filter works
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-filter    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-cli-list-filter-ok
