Skip to content

Commit

Permalink
Update Matrix login request and add corresponding logout request (#287)
Browse files Browse the repository at this point in the history
* Update Matrix login request and add corresponding logout request

* Add tests for getMatrixOpenIDToken
  • Loading branch information
Johennes authored Dec 12, 2024
1 parent 67fac4c commit 597c982
Showing 1 changed file with 96 additions and 15 deletions.
111 changes: 96 additions & 15 deletions samples/postman/VZD-FHIR-Directory/FHIRDirectorySearchAPI.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"info": {
"_postman_id": "e209af5a-de99-4131-9e3a-029a4dca22d2",
"_postman_id": "f5b3a56a-e045-4f00-9645-ebf1077c380a",
"name": "FHIRDirectorySearchAPI",
"description": "Um die Requests nutzen zu können, müssen die folgenden Variablen im verwendeten Environment gesetzt werden:\n\n- matrix_server - Url vom zu verwendenden Matrix Homeserver\n \n- matrix_user - Username für den Login auf dem Matrix Homeserver\n \n- matrix_passwd - Password für den User auf dem Matrix Homeserver\n \n- fhir_server - Url vom zu verwendenden VZD-FHIR-Directory\n \n\nUm die Such-Requests verwenden zu können wird ein searchToken benötigt. Dieses wird automatisch im Environment hinterlegt, wenn die Requests:\n\n1. matrixServerLogin\n \n2. getMatrixOpenIDToken\n \n3. getSearchAccessToken\n \n\nin der genannten Reihenfolge erfolgreich nacheinander aufgerufen wurden.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "29292558"
"_exporter_id": "40068010"
},
"item": [
{
Expand All @@ -14,14 +14,22 @@
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();\r",
"pm.globals.set(\"userId\", jsonData.user_id);\r",
"pm.globals.set(\"accessToken\", jsonData.access_token)\r",
"pm.test(\"succeeds\", () => {\r",
" pm.response.to.have.status(200);\r",
"});\r",
"\r",
"const json = pm.response.json();\r",
"const accessToken = json.access_token;\r",
"\r",
"pm.test(\"has access token\", () => {\r",
" pm.expect(accessToken).to.not.be.oneOf([undefined, null]);\r",
"});\r",
"\r",
"pm.globals.set(\"accessToken\", accessToken);\r",
""
],
"type": "text/javascript"
"type": "text/javascript",
"packages": {}
}
}
],
Expand All @@ -44,14 +52,14 @@
}
},
"url": {
"raw": "{{matrix_server}}/_matrix/client/r0/login",
"raw": "{{matrix_server}}/_matrix/client/v3/login",
"host": [
"{{matrix_server}}"
],
"path": [
"_matrix",
"client",
"r0",
"v3",
"login"
]
}
Expand All @@ -65,13 +73,29 @@
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();\r",
"pm.globals.set(\"matrixopenidtoken\", jsonData.access_token)\r",
"pm.globals.set(\"matrix_server_name\", jsonData.matrix_server_name)\r",
"pm.test(\"succeeds\", () => {\r",
" pm.response.to.have.status(200);\r",
"});\r",
"\r",
"const json = pm.response.json();\r",
"const accessToken = json.access_token;\r",
"\r",
"pm.test(\"has access token\", () => {\r",
" pm.expect(accessToken).to.not.be.oneOf([undefined, null]);\r",
"});\r",
"\r",
"const serverName = json.matrix_server_name;\r",
"\r",
"pm.test(\"has server name\", () => {\r",
" pm.expect(serverName).to.not.be.oneOf([undefined, null]);\r",
"});\r",
"\r",
" "
"pm.globals.set(\"matrixopenidtoken\", accessToken);\r",
"pm.globals.set(\"matrix_server_name\", serverName);\r",
""
],
"type": "text/javascript"
"type": "text/javascript",
"packages": {}
}
}
],
Expand All @@ -98,7 +122,7 @@
}
},
"url": {
"raw": "{{matrix_server}}/_matrix/client/v3/user/{{userId}}/openid/request_token",
"raw": "{{matrix_server}}/_matrix/client/v3/user/{{matrix_user}}/openid/request_token",
"host": [
"{{matrix_server}}"
],
Expand All @@ -107,7 +131,7 @@
"client",
"v3",
"user",
"{{userId}}",
"{{matrix_user}}",
"openid",
"request_token"
]
Expand Down Expand Up @@ -406,6 +430,63 @@
}
},
"response": []
},
{
"name": "matrixServerLogout",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"succeeds\", () => {\r",
" pm.response.to.have.status(200);\r",
"});\r",
"\r",
"pm.globals.set(\"accessToken\", null);\r",
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"packages": {},
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"strictSSL": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"url": {
"raw": "{{matrix_server}}/_matrix/client/v3/logout",
"host": [
"{{matrix_server}}"
],
"path": [
"_matrix",
"client",
"v3",
"logout"
]
}
},
"response": []
}
]
}

0 comments on commit 597c982

Please sign in to comment.