mse-rgaa: utilisation de credentials pour l'authentification basic auth

This commit is contained in:
wpetit 2022-09-14 09:14:34 +02:00
parent cff97b7e02
commit 3272427766
1 changed files with 47 additions and 46 deletions

View File

@ -1,13 +1,10 @@
import hudson.tasks.test.AbstractTestResultAction import hudson.tasks.test.AbstractTestResultAction
@Library("cadoles") _ @Library('cadoles') _
pipeline { pipeline {
parameters { parameters {
text(name: 'URLS', defaultValue: 'https://msedev.crous-toulouse.fr\nhttps://msedev.crous-toulouse.fr/envole/enregistrement\nhttps://msedev.crous-toulouse.fr/envole/page/faq\nhttps://msedev.crous-toulouse.fr/envole/page/?t=liens_utiles\nhttps://msedev.crous-toulouse.fr/envole/page/?t=mentions_legales\nhttps://msedev.crous-toulouse.fr/envole/message/new\nhttps://msedev.crous-toulouse.fr/envole/recuperation/email\nhttps://msedev.crous-toulouse.fr/envole/courriel/raz', description: 'Liste des URLs à tester, une par ligne') text(name: 'URLS', defaultValue: 'https://msedev.crous-toulouse.fr\nhttps://msedev.crous-toulouse.fr/envole/enregistrement\nhttps://msedev.crous-toulouse.fr/envole/page/faq\nhttps://msedev.crous-toulouse.fr/envole/page/?t=liens_utiles\nhttps://msedev.crous-toulouse.fr/envole/page/?t=mentions_legales\nhttps://msedev.crous-toulouse.fr/envole/message/new\nhttps://msedev.crous-toulouse.fr/envole/recuperation/email\nhttps://msedev.crous-toulouse.fr/envole/courriel/raz', description: 'Liste des URLs à tester, une par ligne')
string(name: 'USERNAME', defaultValue: '', description: "Nom d'utilisateur pour l'authentification Basic Auth, si nécessaire")
password(name: 'PASSWORD', defaultValue: '', description: "Mot de passe pour l'authentification Basic Auth, si nécessaire")
booleanParam(name: 'INCLUDE_WARNINGS', defaultValue: false, description: 'Inclure les avertissements') booleanParam(name: 'INCLUDE_WARNINGS', defaultValue: false, description: 'Inclure les avertissements')
booleanParam(name: 'INCLUDE_NOTICES', defaultValue: false, description: 'Inclure les notifications') booleanParam(name: 'INCLUDE_NOTICES', defaultValue: false, description: 'Inclure les notifications')
} }
@ -18,37 +15,45 @@ pipeline {
agent { agent {
node { node {
label "docker" label 'docker'
} }
} }
stages { stages {
stage("Run RGAA audit") { stage('Run RGAA audit') {
steps { steps {
script { script {
def urls = params.URLS.split('\n') def urls = params.URLS.split('\n')
def count = 0 def count = 0
urls.each { u -> urls.each { u ->
stage("Audit page '${u}'") { stage("Audit page '${u}'") {
def report = pa11y.audit(u.trim(), [ withCredentials([
reporter: 'junit', usernamePassword(
username: params.USERNAME, credentialsId: 'msedev-basic-auth',
password: params.PASSWORD, usernameVariable: 'MSEDEV_USERNAME',
standard: 'WCAG2AA', passwordVariable: 'MSEDEV_PASSWORD'
includeNotices: params.INCLUDE_NOTICES, )
includeWarnings: params.INCLUDE_WARNINGS, ]) {
]); def report = pa11y.audit(u.trim(), [
reporter: 'junit',
username: env.MSEDEV_USERNAME,
password: env.MSEDEV_PASSWORD,
standard: 'WCAG2AA',
includeNotices: params.INCLUDE_NOTICES,
includeWarnings: params.INCLUDE_WARNINGS,
])
writeFile file:"./report_${count}.xml", text:report writeFile file:"./report_${count}.xml", text:report
count++ count++
} }
} }
}
junit testResults: '*.xml', skipPublishingChecks: true junit testResults: '*.xml', skipPublishingChecks: true
rocketSend ( rocketSend(
channel: "#cnous-mse", channel: '#cnous-mse',
avatar: 'https://jenkins.cadol.es/static/b5f67753/images/headshot.png', avatar: 'https://jenkins.cadol.es/static/b5f67753/images/headshot.png',
message: """ message: """
Audit RGAA | ${testStatuses()} Audit RGAA | ${testStatuses()}
@ -59,7 +64,6 @@ pipeline {
""".stripIndent(), """.stripIndent(),
rawMessage: true, rawMessage: true,
) )
} }
} }
} }
@ -70,21 +74,18 @@ pipeline {
cleanWs() cleanWs()
} }
} }
} }
@NonCPS @NonCPS
def testStatuses() { def testStatuses() {
def testStatus = "" def testStatus = ''
AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class) AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
if (testResultAction != null) { if (testResultAction != null) {
def total = testResultAction.totalCount def total = testResultAction.totalCount
def failed = testResultAction.failCount def failed = testResultAction.failCount
def skipped = testResultAction.skipCount def skipped = testResultAction.skipCount
def passed = total - failed - skipped def passed = total - failed - skipped
testStatus = "Passant(s): ${passed}, Échoué(s): ${failed} ${testResultAction.failureDiffString}, Désactivé(s): ${skipped}" testStatus = "Passant(s): ${passed}, Échoué(s): ${failed} ${testResultAction.failureDiffString}, Désactivé(s): ${skipped}"
} }
return testStatus return testStatus
} }