*** Settings ***
Documentation    Smoke tests for cloud infrastructure resource handlers
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Cloud Handler Protocol Conformance
    [Documentation]    Verify CloudResourceHandler satisfies ResourceHandler
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    protocol-check    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    protocol-check-ok

AWS Credential Resolution From Env Vars
    [Documentation]    Verify AWS credential resolution from environment variables
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    aws-resolve    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    aws-resolve-ok

GCP Credential Resolution From Env Vars
    [Documentation]    Verify GCP credential resolution from environment variables
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    gcp-resolve    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    gcp-resolve-ok

Azure Credential Resolution From Env Vars
    [Documentation]    Verify Azure credential resolution from environment variables
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    azure-resolve    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    azure-resolve-ok

Cloud Handler Stub Raises NotImplementedError
    [Documentation]    Verify cloud handler resolve raises NotImplementedError for valid config
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    stub-resolve    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    stub-resolve-ok

Cloud Handler Missing Creds Raises ValueError
    [Documentation]    Verify cloud handler raises ValueError for missing credentials
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    missing-creds    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    missing-creds-ok

Cloud Sandbox Strategy Stubs
    [Documentation]    Verify cloud sandbox strategy methods raise NotImplementedError
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    sandbox-stubs    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    sandbox-stubs-ok

AWS Profile Resolution
    [Documentation]    Verify AWS profile name resolves as credential source
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    aws-profile    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    aws-profile-ok

Cloud Builtin Types Registered
    [Documentation]    Verify cloud hierarchy types are in _BUILTIN_TYPES
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    builtin-types    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    builtin-types-ok
