From 44acecf61e5a61c5fba8e76a7dc8d4be8b7e466b Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Sat, 24 Feb 2018 14:00:57 -0500 Subject: [PATCH] use basic auth by default for data setup --- awx/ui/test/e2e/api.js | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/awx/ui/test/e2e/api.js b/awx/ui/test/e2e/api.js index 47559c8961..f411e8ed56 100644 --- a/awx/ui/test/e2e/api.js +++ b/awx/ui/test/e2e/api.js @@ -8,15 +8,17 @@ import { AWX_E2E_PASSWORD } from './settings'; -let authenticated; - const session = axios.create({ baseURL: AWX_E2E_URL, xsrfHeaderName: 'X-CSRFToken', xsrfCookieName: 'csrftoken', httpsAgent: new https.Agent({ rejectUnauthorized: false - }) + }), + auth: { + username: AWX_E2E_USERNAME, + password: AWX_E2E_PASSWORD + } }); const getEndpoint = location => { @@ -27,36 +29,15 @@ const getEndpoint = location => { return `${AWX_E2E_URL}/api/v2${location}`; }; -const authenticate = () => { - if (authenticated) { - return Promise.resolve(); - } - - const uri = getEndpoint('/authtoken/'); - - const credentials = { - username: AWX_E2E_USERNAME, - password: AWX_E2E_PASSWORD - }; - - return session.post(uri, credentials).then(res => { - session.defaults.headers.Authorization = `Token ${res.data.token}`; - authenticated = true; - - return res; - }); -}; - const request = (method, location, data) => { const uri = getEndpoint(location); const action = session[method.toLowerCase()]; - return authenticate() - .then(() => action(uri, data)) + return action(uri, data) .then(res => { console.log([ // eslint-disable-line no-console res.config.method.toUpperCase(), - uri, + res.config.url, res.status, res.statusText ].join(' '));