*** Settings ***
Documentation    Smoke tests for automation profile guards
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_automation_profiles.py

*** Test Cases ***
Guard Allows Tool Within Limits
    [Documentation]    Guard allows tool when under call limit
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    guard-allow    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    guard-allow-ok

Guard Blocks Tool On Denylist
    [Documentation]    Guard blocks tool that is on the denylist
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    guard-deny    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    guard-deny-ok

Guard Blocks Exceeding Max Calls
    [Documentation]    Guard blocks when call limit exceeded
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    guard-max-calls    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    guard-max-calls-ok

Guard Blocks Exceeding Cost Budget
    [Documentation]    Guard blocks when cost budget exceeded
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    guard-cost    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    guard-cost-ok

Guard Write Approval
    [Documentation]    Guard requires approval for writes
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    guard-write    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    guard-write-ok

Guard Apply Approval
    [Documentation]    Guard requires approval for apply phase
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    guard-apply    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    guard-apply-ok

Profile From YAML
    [Documentation]    Load profile with guards from YAML
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    from-yaml    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    from-yaml-ok

Effective Profile Resolution
    [Documentation]    Effective profile resolution precedence
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    resolution    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    resolution-ok

Guard Summary
    [Documentation]    Print guard feature summary
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    summary    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    summary-ok
