# Testing Authentication with Ansible

**URL:** <https://forum.ansible.com/t/testing-authentication-with-ansible/31762>\
**Category:** Ansible Project\
**Created:** [December 4, 2019, 8:16pm UTC](https://forum.ansible.com/t/testing-authentication-with-ansible/31762 "2019-12-04T20:16:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cade\_Lambert](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Cade\_Lambert](https://forum.ansible.com/u/Cade_Lambert)\
**Post date:** [December 4, 2019, 8:16pm UTC](https://forum.ansible.com/t/testing-authentication-with-ansible/31762/1 "2019-12-04T20:16:13Z")

</div>

We have a CMS web application that we’d like to ensure is up and accessible. I was using the URI module to check the login page for a proper response code, but I’d like to go a step further and test that a set of credentials can actually log into the site. I’ve tried messing around with some of the examples on the URI module documentation to no avail. Has anyone done something like this before?

---

<div class="post-metadata">

**Author:** ![Adam](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@Adam](https://forum.ansible.com/u/Adam)\
**Post date:** [December 5, 2019, 2:20pm UTC](https://forum.ansible.com/t/testing-authentication-with-ansible/31762/2 "2019-12-05T14:20:08Z")

</div>

We’ve been experimenting using Selenium for things like this. It’s not simple and will probably make your head hurt (it makes mine hurt), but it is very flexible for things like this.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [December 5, 2019, 4:17pm UTC](https://forum.ansible.com/t/testing-authentication-with-ansible/31762/3 "2019-12-05T16:17:11Z")

</div>

> We've been experimenting using Selenium for things like this. It's not simple and will probably make your head hurt (it  
> makes mine hurt), but it is very flexible for things like this.

There are numerous crawlers around that can be used for that task if you can't stomach Selenium.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Cade\_Lambert](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Cade\_Lambert](https://forum.ansible.com/u/Cade_Lambert)\
**Post date:** [March 5, 2020, 2:59pm UTC](https://forum.ansible.com/t/testing-authentication-with-ansible/31762/4 "2020-03-05T14:59:08Z")

</div>

Circling back around to this. What do you mean by crawlers? Any you’d recommend.

I did notice the URI module can pass credentials to a site, but when I try that it works with any credentials, even non-existent or incorrect credentials, so I’m not totally sure what that is actually doing because it can’t be correctly authenticating.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [March 10, 2020, 9:09pm UTC](https://forum.ansible.com/t/testing-authentication-with-ansible/31762/5 "2020-03-10T21:09:22Z")

</div>

I think you should be able to do this with uri module, but you might need to check the http response code as well. An unsuccessful http request with basic authentication will return a response from the server, but it will typically not have a 200 (OK) response code, but instead have something like a 401 Unauthorised or 403 Forbidden response.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Cade\_Lambert](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Cade\_Lambert](https://forum.ansible.com/u/Cade_Lambert)\
**Post date:** [March 11, 2020, 12:16pm UTC](https://forum.ansible.com/t/testing-authentication-with-ansible/31762/6 "2020-03-11T12:16:12Z")

</div>

I’ve tried it with the URI module and I don’t believe it’s doing what I’d like. It will return a successful authentication even when I use incorrect credentials, so I’m not sure what it’s really doing.
