name: Teardown
testcases:
- name: get_login_token
  steps:
  - type: get_login_token

- name: get_ad_domain_id
  steps:
  - type: http
    method: GET
    url: '{{.pfserver_webadmin_url}}/api/v1/config/domains'
    ignore_verify_ssl: true
    headers:
      "Authorization": "{{.get_login_token.result.token}}"
      "Content-Type": "application/json"
    assertions:
      - result.statuscode ShouldEqual 200
    vars:
      domain_id:
        from: result.bodyjson.items.items0.id

- name: unset_domain_on_builtin_realms
  steps:
  - type: http
    method: PATCH
    url: '{{.pfserver_webadmin_url}}/api/v1/config/realm/DEFAULT'
    ignore_verify_ssl: true
    body: >-
      {
        "domain": null
      }
    headers:
      "Authorization": "{{.get_login_token.result.token}}"
      "Content-Type": "application/json"
    assertions:
      - result.statuscode ShouldEqual 200

  - type: http
    method: PATCH
    url: '{{.pfserver_webadmin_url}}/api/v1/config/realm/NULL'
    ignore_verify_ssl: true
    body: >-
      {
        "domain": null
      }
    headers:
      "Authorization": "{{.get_login_token.result.token}}"
      "Content-Type": "application/json"
    assertions:
      - result.statuscode ShouldEqual 200

- name: delete_realms
  steps:
  - type: http
    method: DELETE
    url: '{{.pfserver_webadmin_url}}/api/v1/config/realm/{{.ad_domain_upper}}'
    ignore_verify_ssl: true
    headers:
      "Authorization": "{{.get_login_token.result.token}}"
      "Content-Type": "application/json"
    assertions:
      - result.statuscode ShouldEqual 200

  - type: http
    method: DELETE
    url: '{{.pfserver_webadmin_url}}/api/v1/config/realm/{{.ad_dns_domain}}'
    ignore_verify_ssl: true
    headers:
      "Authorization": "{{.get_login_token.result.token}}"
      "Content-Type": "application/json"
    assertions:
      - result.statuscode ShouldEqual 200

- name: delete_domain
  steps:
  - type: http
    method: DELETE
    url: '{{.pfserver_webadmin_url}}/api/v1/config/domain/{{.get_ad_domain_id.domain_id}}'
    ignore_verify_ssl: true
    headers:
      "Authorization": "{{.get_login_token.result.token}}"
      "Content-Type": "application/json"
    assertions:
      - result.statuscode ShouldEqual 200

- name: delete_connection_profile
  steps:
  - type: http
    method: DELETE
    url: '{{.pfserver_webadmin_url}}/api/v1/config/connection_profile/{{.dot1x_eap_peap.profiles.wired.id}}'
    ignore_verify_ssl: true
    headers:
      "Authorization": "{{.get_login_token.result.token}}"
      "Content-Type": "application/json"
    assertions:
      - result.statuscode ShouldEqual 200

- name: delete_sources
  steps:
  - type: http
    method: DELETE
    url: '{{.pfserver_webadmin_url}}/api/v1/config/source/{{.dot1x_eap_peap.sources.ad_user.name}}'
    ignore_verify_ssl: true
    headers:
      "Authorization": "{{.get_login_token.result.token}}"
      "Content-Type": "application/json"
    assertions:
      - result.statuscode ShouldEqual 200

  - type: http
    method: DELETE
    url: '{{.pfserver_webadmin_url}}/api/v1/config/source/{{.dot1x_eap_peap.sources.ad_machine.name}}'
    ignore_verify_ssl: true
    headers:
      "Authorization": "{{.get_login_token.result.token}}"
      "Content-Type": "application/json"
    assertions:
      - result.statuscode ShouldEqual 200

