name: Check firewall SSO Start
testcases:

- name: check_mock_history_request
  steps:
  - type: exec
    script: |
      curl -s http://{{.firewall_sso.https.host}}:{{.firewall_sso.https.port_config}}/history | jq '.[-1].request'
    assertions:
      - result.code ShouldEqual 0
      - result.systemout ShouldNotBeBlank
      - result.systemoutjson.path ShouldEqual "/api/"
      - result.systemoutjson.method ShouldEqual "POST"
      - result.systemoutjson.query_params.key ShouldEqual [{{.firewall_sso.https.password}}]
    retry: 10
    delay: 1

- name: check_mock_history_request_body_string
  steps:
  - type: exec
    script: |
      curl -s http://{{.firewall_sso.https.host}}:{{.firewall_sso.https.port_config}}/history | jq -r '.[-1].request.body' | cut -d '=' -f 2  | sed 's/\+/%20/g' | sed -e "s/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g" | xargs -0 echo -e | python3 -c 'import sys, json, xmltodict; print(json.dumps(xmltodict.parse(sys.stdin.read())))'
    assertions:
      - result.code ShouldEqual 0
      - result.systemout ShouldNotBeBlank
      - result.systemoutjson.uid-message.payload.login.entry.@name ShouldEqual "{{.ad_domain_user}}"
