summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/uri/tasks/use_netrc.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
commit8a754e0858d922e955e71b253c139e071ecec432 (patch)
tree527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/uri/tasks/use_netrc.yml
parentInitial commit. (diff)
downloadansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz
ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/uri/tasks/use_netrc.yml')
-rw-r--r--test/integration/targets/uri/tasks/use_netrc.yml51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/integration/targets/uri/tasks/use_netrc.yml b/test/integration/targets/uri/tasks/use_netrc.yml
new file mode 100644
index 0000000..da745b8
--- /dev/null
+++ b/test/integration/targets/uri/tasks/use_netrc.yml
@@ -0,0 +1,51 @@
+- name: Write out netrc
+ copy:
+ dest: "{{ remote_tmp_dir }}/netrc"
+ content: |
+ machine {{ httpbin_host }}
+ login foo
+ password bar
+
+- name: Test Bearer authorization is failed with netrc
+ uri:
+ url: https://{{ httpbin_host }}/bearer
+ return_content: yes
+ headers:
+ Authorization: Bearer foobar
+ ignore_errors: yes
+ environment:
+ NETRC: "{{ remote_tmp_dir }}/netrc"
+ register: response_failed
+
+- name: assert Test Bearer authorization is failed with netrc
+ assert:
+ that:
+ - response_failed.json.token != 'foobar'
+ - "'Zm9vOmJhcg==' in response_failed.json.token"
+ fail_msg: "Was expecting 'foo:bar' in base64, but received: {{ response_failed }}"
+ success_msg: "Expected to fail because netrc is using Basic authentication by default"
+
+- name: Test Bearer authorization is successfull with use_netrc=False
+ uri:
+ url: https://{{ httpbin_host }}/bearer
+ use_netrc: false
+ return_content: yes
+ headers:
+ Authorization: Bearer foobar
+ environment:
+ NETRC: "{{ remote_tmp_dir }}/netrc"
+ register: response
+
+- name: assert Test Bearer authorization is successfull with use_netrc=False
+ assert:
+ that:
+ - response.status == 200
+ - response.json.token == 'foobar'
+ - response.url == 'https://{{ httpbin_host }}/bearer'
+ fail_msg: "Was expecting successful Bearer authentication, but received: {{ response }}"
+ success_msg: "Bearer authentication successfull when netrc is ignored."
+
+- name: Clean up
+ file:
+ dest: "{{ remote_tmp_dir }}/netrc"
+ state: absent \ No newline at end of file