Skip to content

Commit

Permalink
fix: adjust headers token in case of multitenancy and auth type
Browse files Browse the repository at this point in the history
  • Loading branch information
vladislavploaia committed Jun 7, 2024
1 parent b2b40c1 commit 395828c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
12 changes: 5 additions & 7 deletions tests/robot/_resources/keywords/admin_keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Resource template_opt1.4_keywords.robot
[Arguments] ${multitenancy_token}=${None}
IF '${multitenancy_token}' != '${None}'
Set To Dictionary ${headers} Authorization=Bearer ${multitenancy_token}
END
IF '${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH'
ELSE IF ('${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH') and '${multitenancy_token}' == '${None}'
Set To Dictionary ${headers} &{authorization}
END
Create Session ${SUT} ${ADMIN_BASEURL} debug=2
Expand Down Expand Up @@ -97,11 +96,10 @@ Resource template_opt1.4_keywords.robot
... Needs `${versioned_object_uid}` var from e.g. `commit composition (JSON)` KW.
[Arguments] ${multitenancy_token}=${None}

IF '${multitenancy_token}' != '${None}'
Set To Dictionary ${headers} Authorization=Bearer ${multitenancy_token}
END
IF '${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH'
Set To Dictionary ${headers} &{authorization}
IF '${multitenancy_token}' != '${None}'
Set To Dictionary ${headers} Authorization=Bearer ${multitenancy_token}
ELSE IF ('${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH') and '${multitenancy_token}' == '${None}'
Set To Dictionary ${headers} &{authorization}
END
Create Session ${SUT} ${ADMIN_BASEURL} debug=2
... verify=False
Expand Down
14 changes: 6 additions & 8 deletions tests/robot/_resources/keywords/aql_query_keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ PUT /definition/query/{qualified_query_name}/{version}
... {random_query_qualified_name}/{random_query_version}
[Arguments] ${query_to_store} ${format}=json ${multitenancy_token}=${None}
&{headers} Create Dictionary
IF '${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH'
IF '${multitenancy_token}' != '${None}'
Set To Dictionary ${headers} Authorization=Bearer ${multitenancy_token}
ELSE IF ('${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH') and '${multitenancy_token}' == '${None}'
Set To Dictionary ${headers} &{authorization}
END
IF '${format}' == 'json'
Expand All @@ -331,9 +333,6 @@ PUT /definition/query/{qualified_query_name}/{version}
Set To Dictionary ${headers} Content-Type=text/plain
${query} Set Variable ${query_to_store}
END
IF '${multitenancy_token}' != '${None}'
Set To Dictionary ${headers} Authorization=Bearer ${multitenancy_token}
END
Create Session ${SUT} ${BASEURL} debug=2
${random_version} Generate Version Number To Store Query Multitenancy
Set Test Variable ${random_query_version} ${random_version}
Expand All @@ -357,13 +356,12 @@ GET /definition/query/{qualified_query_name} / including {version}
... Returns {resp_query}, query from response.
[Arguments] ${qualif_name} ${multitenancy_token}=${None}
&{headers} Create Dictionary Content-Type=application/json
IF '${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH'
Set To Dictionary ${headers} &{authorization}
END
Create Session ${SUT} ${BASEURL} debug=2
IF '${multitenancy_token}' != '${None}'
Set To Dictionary ${headers} Authorization=Bearer ${multitenancy_token}
ELSE IF ('${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH') and '${multitenancy_token}' == '${None}'
Set To Dictionary ${headers} &{authorization}
END
Create Session ${SUT} ${BASEURL} debug=2
${resp} GET On Session ${SUT}
... /definition/query/${qualif_name}
... expected_status=anything
Expand Down
9 changes: 3 additions & 6 deletions tests/robot/_resources/keywords/composition_keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,10 @@ commit composition

&{headers}= Create Dictionary Prefer=return=${prefer}
... openEHR-VERSION.lifecycle_state=${lifecycle}
IF '${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH'
Set To Dictionary ${headers} &{authorization}
END

IF '${multitenancy_token}' != '${None}'
Set To Dictionary ${headers}
... Authorization=Bearer ${multitenancy_token}
Set To Dictionary ${headers} Authorization=Bearer ${multitenancy_token}
ELSE IF ('${AUTH_TYPE}' == 'BASIC' or '${AUTH_TYPE}' == 'OAUTH') and '${multitenancy_token}' == '${None}'
Set To Dictionary ${headers} &{authorization}
END

Set Test Variable ${headers} ${headers}
Expand Down

0 comments on commit 395828c

Please sign in to comment.