diff options
author | Dag Wieers <dag@wieers.com> | 2018-05-17 19:18:18 +0200 |
---|---|---|
committer | ansibot <ansibot@users.noreply.github.com> | 2018-05-17 19:18:18 +0200 |
commit | 0fba72ce3cc52a9ab9cc1b84ed787f9b2d29f236 (patch) | |
tree | 7c3951a45724a552267bffed3000814b63fa594e /test/integration/targets/uri | |
parent | docs: Suggest get_url or uri for file checksum validation (#40087) (diff) | |
download | ansible-0fba72ce3cc52a9ab9cc1b84ed787f9b2d29f236.tar.xz ansible-0fba72ce3cc52a9ab9cc1b84ed787f9b2d29f236.zip |
uri: Add form-urlencoded support to body_format (#37188)
* uri: Add form-urlencoded support to body_format
This PR adds form-urlencoded support so the user does not need to take
care of correctly encode input and have the same convenience as using
JSON.
This fixes #37182
* Various fixes
* Undo documentation improvements
No longer my problem
* Fix the remaining review comments
Diffstat (limited to 'test/integration/targets/uri')
-rw-r--r-- | test/integration/targets/uri/tasks/main.yml | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/integration/targets/uri/tasks/main.yml b/test/integration/targets/uri/tasks/main.yml index 78e8c35741..69f62f8702 100644 --- a/test/integration/targets/uri/tasks/main.yml +++ b/test/integration/targets/uri/tasks/main.yml @@ -334,6 +334,62 @@ register: result failed_when: result.json.headers['Content-Type'] != 'text/json' +- name: Validate body_format form-urlencoded using dicts works + uri: + url: https://{{ httpbin_host }}/post + method: POST + body: + user: foo + password: bar!#@ |&82$M + submit: Sign in + body_format: form-urlencoded + return_content: yes + register: result + +- name: Assert form-urlencoded dict input + assert: + that: + - result is successful + - result.json.headers['Content-Type'] == 'application/x-www-form-urlencoded' + - result.json.form.password == 'bar!#@ |&82$M' + +- name: Validate body_format form-urlencoded using lists works + uri: + url: https://{{ httpbin_host }}/post + method: POST + body: + - [ user, foo ] + - [ password, bar!#@ |&82$M ] + - [ submit, Sign in ] + body_format: form-urlencoded + return_content: yes + register: result + +- name: Assert form-urlencoded list input + assert: + that: + - result is successful + - result.json.headers['Content-Type'] == 'application/x-www-form-urlencoded' + - result.json.form.password == 'bar!#@ |&82$M' + +- name: Validate body_format form-urlencoded of invalid input fails + uri: + url: https://{{ httpbin_host }}/post + method: POST + body: + - foo + - bar: baz + body_format: form-urlencoded + return_content: yes + register: result + ignore_errors: yes + +- name: Assert invalid input fails + assert: + that: + - result is failure + - "'failed to parse body as form_urlencoded: too many values to unpack' in result.msg" + - name: Test client cert auth, no certs uri: url: "https://ansible.http.tests/ssl_client_verify" |