From ffe16b792701bae47e2ffddc10298cb24f87e81e Mon Sep 17 00:00:00 2001 From: William Petit Date: Mon, 10 Aug 2020 16:48:05 +0200 Subject: [PATCH] Pa11y: Injection des identifiants Basic Auth dans la configuration --- resources/com/cadoles/pa11y/patty.json.tmpl | 6 ++++++ vars/pa11y.groovy | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/resources/com/cadoles/pa11y/patty.json.tmpl b/resources/com/cadoles/pa11y/patty.json.tmpl index 9e4d519..919bfa9 100644 --- a/resources/com/cadoles/pa11y/patty.json.tmpl +++ b/resources/com/cadoles/pa11y/patty.json.tmpl @@ -2,5 +2,11 @@ "chromeLaunchConfig": { "args": ["--disable-dev-shm-usage", "--no-sandbox", "--disable-gpu"], "ignoreHTTPSErrors": true + }, + "headers": { + {{if not (empty .PA11Y_USERNAME)}} + {{ $credentials := print .PA11Y_USERNAME ":" .PA11Y_PASSWORD }} + "Authorization": "Basic {{b64enc $credentials}}" + {{end}} } } \ No newline at end of file diff --git a/vars/pa11y.groovy b/vars/pa11y.groovy index 4e0b667..f03400b 100644 --- a/vars/pa11y.groovy +++ b/vars/pa11y.groovy @@ -1,10 +1,15 @@ def audit(String url, Map params = [:]) { def reporter = params.reporter ? params.reporter : 'html' + def username = params.username ? params.username : ''; + def password = params.password ? params.password : ''; + def pa11yImage = buildDockerImage() def dockerArgs = """ -e PA11Y_REPORTER='${reporter}' -e PA11Y_URL='${url}' + -e PA11Y_USERNAME='${username}' + -e PA11Y_PASSWORD='${password}' """ pa11yImage.inside(dockerArgs) {