Skip to content
Snippets Groups Projects
Commit 0dbf1a70 authored by Martins, Laurent's avatar Martins, Laurent
Browse files

Merge branch 'robotframework' into 'main'

fix robotframework

See merge request pub/numeco/misis/misis-backend!108
parents 6e8b6fa4 4c8229d9
Branches
Tags
No related merge requests found
......@@ -29,8 +29,9 @@ include:
forceBuild: true
DockerfileContent: |-
FROM python:3.12.4-alpine3.20
RUN apk add curl
RUN pip install --no-cache-dir robotframework==7.0 robotframework-requests==0.9.7
RUN apk add curl libevent-2.1-7 libavif13
RUN pip install --no-cache-dir robotframework==7.0 robotframework-requests==0.9.7 pip install robotframework-browser
RUN rfbrowser init
release-database-empty-image:
needs: []
......
*** Settings ***
Library RequestsLibrary
Library Browser
*** Variables ***
${API_BASE_URL} http://%{APP_HOST}:8080
......@@ -11,19 +12,24 @@ ${CLIENT_SECRET} secret
*** Test Cases ***
Requête GET sans Authentification
${response}= GET ${API_BASE_URL}/suivis-de-site expected_status=401
${response}= GET ${API_BASE_URL}/suivis-de-site expected_status=200
${content}= Convert To String ${response.content}
Should Start With ${content} <!DOCTYPE html> strip_spaces=True
Should Start With ${response.url} http://%{KEYCLOAK_HOST}:8088/realms/quarkus/protocol/openid-connect/auth
*** Test Cases ***
Requête GET avec Authentification
Authenticate as Admin
${headers}= Create Dictionary accept=application/json Authorization=Bearer ${access_token}
${headers}= Create Dictionary accept=application/json Cookie=q_session\=${access_token}
${response}= GET ${API_BASE_URL}/suivis-de-site headers=${headers} expected_status=200
Log ${response}
*** Keywords ***
Authenticate as Admin
&{body}= Create Dictionary username=${USERNAME} password=${PASSWORD} grant_type=password client_id=${CLIENT_ID} client_secret=${CLIENT_SECRET} scope=openid
&{header}= Create Dictionary Content-Type=application/x-www-form-urlencoded
${response}= POST ${KEYCLOAK_TOKEN_URL} data=${body} headers=${header}
${access_token} Set Variable ${response.json()["access_token"]}
Log ${access_token}
New Page ${API_BASE_URL}/suivis-de-site
Type Text input#username ${USERNAME}
Type Text input#password ${PASSWORD}
Click button#kc-login
${cookie}= Get Cookie q_session
${access_token} Set Variable ${cookie.value}
Set Suite Variable ${access_token}
\ No newline at end of file
*** Settings ***
Library RequestsLibrary
Library Browser
*** Variables ***
${API_BASE_URL} http://%{APP_HOST}:8080
......@@ -16,7 +17,7 @@ En tant que 'user1', je ne dois pas avoir voir le suivi de site id '1'
[Tags] Suivi du site
Set Suite Variable ${suiviId} 1
Authenticate as User
${headers}= Create Dictionary Content-Type=application/json Authorization=Bearer ${access_token}
${headers}= Create Dictionary Content-Type=application/json Cookie=q_session\=${access_token}
${response}= GET ${API_BASE_URL}/suivis-de-site/{suiviId} headers=${headers} expected_status=404
#[GET] /suivis-de-site/settings/{suiviId}
......@@ -26,7 +27,7 @@ En tant que 'user1', je ne dois pas avoir accès aux paramètres du suivi de sit
[Tags] Paramètres du suivi de site
Set Suite Variable ${suiviId} 1
Authenticate as User
${headers}= Create Dictionary Content-Type=application/json Authorization=Bearer ${access_token}
${headers}= Create Dictionary Content-Type=application/json Cookie=q_session\=${access_token}
${response}= GET ${API_BASE_URL}/suivis-de-site/settings/${suiviId} headers=${headers} expected_status=404
#[POST] /suivis-de-site/settings/{suiviId}
......@@ -37,7 +38,7 @@ En tant que 'user1', je ne dois pas pouvoir modifier les paramètres du suivi de
Set Suite Variable ${suiviId} 1
Set Suite Variable ${body} [{"id": 1,"name": "Nouveau nom du Suivi","periodiciteDuSuivi": "QUOTIDIEN","methodeDeCreationDeGroupe": "MANUELLE","pages": [{"id": null,"url": "https://misis.developpement-durable.gouv.fr/"}]}]
Authenticate as User
${headers}= Create Dictionary Content-Type=application/json Authorization=Bearer ${access_token}
${headers}= Create Dictionary Content-Type=application/json Cookie=q_session\=${access_token}
${response}= POST ${API_BASE_URL}/suivis-de-site/settings/${suiviId} data=${body} headers=${headers} expected_status=404
#[DELETE] /suivis-de-site/settings/{suiviId}
......@@ -47,7 +48,7 @@ En tant que 'user1', je ne dois pas pouvoir supprimer le suivi de site id '1'
[Tags] Paramètres du suivi de site
Set Suite Variable ${suiviId} 1
Authenticate as User
${headers}= Create Dictionary Content-Type=application/json Authorization=Bearer ${access_token}
${headers}= Create Dictionary Content-Type=application/json Cookie=q_session\=${access_token}
${response}= DELETE ${API_BASE_URL}/suivis-de-site/settings/${suiviId} headers=${headers} expected_status=404
#[GET] /suivis-de-site/{suiviId}/groupe/{groupId}/liste-des-pages
......@@ -58,7 +59,7 @@ En tant que 'user1', je ne dois pas voir la liste de page du suivi de site id '1
Set Suite Variable ${suiviId} 1
Set Suite Variable ${groupId} 1
Authenticate as User
${headers}= Create Dictionary Content-Type=application/json Authorization=Bearer ${access_token}
${headers}= Create Dictionary Content-Type=application/json Cookie=q_session\=${access_token}
${response}= GET ${API_BASE_URL}/suivis-de-site/${suiviId}/groupe/${groupId}/liste-des-pages headers=${headers} expected_status=404
#[GET] /suivis-de-site/{suiviId}/groupe/{groupId}/liste-des-ressources
......@@ -69,7 +70,7 @@ En tant que 'user1', je ne dois pas voir les ressources du suivi de site id '1'
Set Suite Variable ${suiviId} 1
Set Suite Variable ${groupId} 1
Authenticate as User
${headers}= Create Dictionary Content-Type=application/json Authorization=Bearer ${access_token}
${headers}= Create Dictionary Content-Type=application/json Cookie=q_session\=${access_token}
${response}= GET ${API_BASE_URL}/suivis-de-site/${suiviId}/groupe/${groupId}/liste-des-ressources headers=${headers} expected_status=404
#[GET] /suivis-de-site/{suiviId}/groupe/{groupId}/statistiques/{statType}
......@@ -81,13 +82,15 @@ En tant que 'user1', je ne dois pas voir les statistiques du suivi de site id '1
Set Suite Variable ${groupId} 1
Set Suite Variable ${statType} 'IMAGES'
Authenticate as User
${headers}= Create Dictionary Content-Type=application/json Authorization=Bearer ${access_token}
${headers}= Create Dictionary Content-Type=application/json Cookie=q_session\=${access_token}
${response}= GET ${API_BASE_URL}/suivis-de-site/${suiviId}/groupe/${groupId}/statistiques/${statType} headers=${headers} expected_status=404
*** Keywords ***
Authenticate as User
&{body}= Create Dictionary username=${USERNAME} password=${PASSWORD} grant_type=password client_id=${CLIENT_ID} client_secret=${CLIENT_SECRET} scope=openid
&{header}= Create Dictionary Content-Type=application/x-www-form-urlencoded
${response}= POST ${KEYCLOAK_TOKEN_URL} data=${body} headers=${header}
${access_token} Set Variable ${response.json()["access_token"]}
New Page ${API_BASE_URL}/suivis-de-site
Type Text input#username ${USERNAME}
Type Text input#password ${PASSWORD}
Click button#kc-login
${cookie}= Get Cookie q_session
${access_token} Set Variable ${cookie.value}
Set Suite Variable ${access_token}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment