diff --git a/API.md b/API.md
index 76591bd9..4b14809a 100644
--- a/API.md
+++ b/API.md
@@ -271,7 +271,9 @@ Als de server gestart is met `STORE_HTTP_REQUESTS` variabel gezet op
OOAPI en RIO endpoint gelogd te krijgen. Om deze gegevens te krijgen
moet de query parameter `http-messages=true` doorgegeven worden bij
het aanmaken van een job en wordt het status object uitgebreid met
-`http-messages`.
+`http-messages`. De http-messages array bevat maps met "req" en "res"
+keys. Wanneer het een json response betreft, dan bevat "res" naast "body"
+(de string-representatie van de json) ook een "json-body" met de json zelf.
```
POST /job/dry-run/upsert/courses/ffeeddcc-bbaa-0099-8877-665544332211?http-messages=true
@@ -292,7 +294,8 @@ POST /job/dry-run/upsert/courses/ffeeddcc-bbaa-0099-8877-665544332211?http-messa
},
"res": {
"status": 404,
- "body": null
+ "body": "{\"course\":{...",
+ "json-body": {"course":{}}
}
}, {
"req": "...",
diff --git a/src/nl/surf/eduhub_rio_mapper/endpoints/api.clj b/src/nl/surf/eduhub_rio_mapper/endpoints/api.clj
index 1ee4ec5f..30015c00 100644
--- a/src/nl/surf/eduhub_rio_mapper/endpoints/api.clj
+++ b/src/nl/surf/eduhub_rio_mapper/endpoints/api.clj
@@ -17,7 +17,8 @@
;; .
(ns nl.surf.eduhub-rio-mapper.endpoints.api
- (:require [clojure.spec.alpha :as s]
+ (:require [clojure.data.json :as json]
+ [clojure.spec.alpha :as s]
[clojure.string :as str]
[compojure.core :refer [GET POST]]
[compojure.route :as route]
@@ -95,22 +96,38 @@
(assoc :status http-status/ok
:body (metrics/prometheus-render-metrics (count-queues-fn) (fetch-jobs-by-status) schac-home-to-name))))))
+(defn json-request-headers? [headers]
+ (let [accept (get headers "Accept")]
+ (and accept
+ (str/starts-with? accept "application/json"))))
+
+;; For json requests (requests with a json Accept header) add a :json-body key to the response with the
+;; same content as the response body, only with the json parsed, instead of as a raw string.
+(defn add-single-parsed-json-response [{{headers :headers :as req} :req, {status :status, body :body} :res}]
+ {:pre [req status body]}
+ {:req req
+ :res (cond-> {:status status :body body}
+ (json-request-headers? headers)
+ (assoc :json-body (json/read-str body :key-fn keyword)))})
+
(defn wrap-status-getter
[app {:keys [status-getter-fn]}]
(fn status-getter [req]
- (let [res (app req)]
- (if-let [token (:token res)]
- (with-mdc {:token token}
- (if-let [status (status-getter-fn token)]
- (assoc res
- :status http-status/ok
- :body (if (= "false" (get-in req [:params :http-messages] "false"))
- (dissoc status :http-messages)
- status))
- (assoc res
- :status http-status/not-found
- :body {:status :unknown})))
- res))))
+ (let [res (app req)
+ token (:token res)
+ show-http-messages? (= "true" (get-in req [:params :http-messages] "false"))]
+ (if (nil? token)
+ res
+ (let [job-status (status-getter-fn token)]
+ (if (nil? job-status)
+ {:status http-status/not-found
+ :token token
+ :body {:status :unknown}}
+ {:status http-status/ok
+ :token token
+ :body (cond-> job-status
+ show-http-messages?
+ (assoc :http-messages (map add-single-parsed-json-response (:http-messages job-status))))}))))))
(defn wrap-uuid-validator [app]
(fn uuid-validator [req]
diff --git a/test/fixtures/http-messages-1.json b/test/fixtures/http-messages-1.json
new file mode 100644
index 00000000..e254d4b9
--- /dev/null
+++ b/test/fixtures/http-messages-1.json
@@ -0,0 +1,81 @@
+{
+ "started-at": "2024-11-05T12:07:17.626096Z",
+ "token": "166f8f6e-babd-4a90-8c6c-459297f39612",
+ "status": "done",
+ "resource": "program/0f212491-c96a-4141-8718-86d40a4ebfd3",
+ "http-messages": [
+ {
+ "req": {
+ "url": "https://gateway.test.surfeduhub.nl/programs/0f212491-c96a-4141-8718-86d40a4ebfd3?returnTimelineOverrides=true",
+ "method": "get",
+ "headers": {
+ "X-Route": "endpoint=endpoint01.sandbox.jomco.nl",
+ "Accept": "application/json; version=5",
+ "traceparent": "00-ec27b43a8ddee76bfc75359bc94d0915-a631da46d361df1b-00"
+ }
+ },
+ "res": {
+ "status": 200,
+ "body": "{\"gateway\":{\"requestId\":\"4sDvfqnJPUykQAPaoosX06\",\"traceparent_trace_id\":\"ec27b43a8ddee76bfc75359bc94d0915\",\"traceparent_id\":\"ae53d54ab932928b\",\"request\":\"/programs/0f212491-c96a-4141-8718-86d40a4ebfd3?returnTimelineOverrides=true\",\"endpoints\":{\"endpoint01.sandbox.jomco.nl\":{\"url\":\"https://proxy.swift.surfsara.nl/v1/KEY_8e0eecf8d38141f7aa98bc3078fc9ccd/rio-mapper-test-suite/programs/0f212491-c96a-4141-8718-86d40a4ebfd3?returnTimelineOverrides=true\",\"responseCode\":200,\"headers\":{\"content-length\":\"3879\",\"content-type\":\"application/json\"}}}},\"responses\":{\"endpoint01.sandbox.jomco.nl\":{\"fieldsOfStudy\":\"0612\",\"teachingLanguage\":\"eng\",\"studyLoad\":{\"value\":155,\"studyLoadUnit\":\"ects\"},\"organization\":\"cafecafe-cafe-cafe-cafe-cafecafecafe\",\"level\":\"nt2-2\",\"educationSpecification\":\"3bdce4da-bd3d-4b1d-8ee5-f60cb22f739b\",\"name\":[{\"language\":\"en-GB\",\"value\":\"Some a program\"},{\"language\":\"nl-NL\",\"value\":\"Zomaar een programma\"}],\"sector\":\"secondary vocational education\",\"validFrom\":\"2008-10-18\",\"addresses\":[{\"countryCode\":\"NL\",\"city\":\"Morra\",\"geoLocation\":{\"longitude\":88,\"latitude\":0},\"addressType\":\"teaching\",\"streetNumber\":23,\"postalCode\":\"4184QU\",\"street\":\"Tollenslaan\",\"additional\":\"a\"}],\"programType\":\"program\",\"primaryCode\":{\"codeType\":\"crohoCreboCode\",\"code\":\"60740\"},\"modeOfDelivery\":[\"on campus\",\"distance-learning\",\"hybrid\",\"online\"],\"duration\":\"P1DT30H4S\",\"qualificationAwarded\":\"Phd\",\"link\":\"https://universiteit-van-morra.nl/programs/0f212491-c96a-4141-8718-86d40a4ebfd3\",\"coordinators\":[\"cafecafe-cafe-cafe-cafe-cafecafecafe\"],\"otherCodes\":[{\"codeType\":\"crohoCreboCode\",\"code\":\"60740\"}],\"validTo\":\"2023-12-18\",\"modeOfStudy\":\"dual training\",\"assessment\":[{\"language\":\"en-GB\",\"value\":\"..\"},{\"language\":\"nl-NL\",\"value\":\"..\"}],\"description\":[{\"language\":\"en-GB\",\"value\":\"..\"},{\"language\":\"nl-NL\",\"value\":\"..\"}],\"levelOfQualification\":\"2\",\"consumers\":[{\"alliances\":[{\"name\":\"lde\",\"enrollmentForOwnStudents\":\"broker\",\"type\":\"broadening\",\"visibleForOwnStudents\":false,\"selection\":true,\"theme\":\"13\"}],\"consumerKey\":\"eduxchange\"},{\"educationOffererCode\":\"110A133\",\"acceleratedRoute\":\"no_accelerated_route\",\"consentParticipationSTAP\":\"permission_not_granted\",\"deficiency\":\"deficiencies\",\"studyChoiceCheck\":\"no_study_choice_check\",\"consumerKey\":\"rio\",\"requirementsActivities\":\"requirements\",\"propaedeuticPhase\":\"no_propaedeutic_phase\",\"educationLocationCode\":\"107X215\"}],\"programId\":\"0f212491-c96a-4141-8718-86d40a4ebfd3\",\"firstStartDate\":\"2010-01-31\",\"resources\":[\"Lelieveldt, H. Course guide. Sage.Miles, M.\",\"- lecture hand-outs and additional book chapters will be available online. Sage. Mourato (2006).\",\"B. Practical manual Soil Pollution and Soil Protection. .\"],\"qualificationRequirements\":[{\"language\":\"en-GB\",\"value\":\"..\"},{\"language\":\"nl-NL\",\"value\":\"..\"}],\"abbreviation\":\"TEC\",\"learningOutcomes\":[[{\"language\":\"en-GB\",\"value\":\"..\"},{\"language\":\"nl-NL\",\"value\":\"..\"}],[{\"language\":\"en-GB\",\"value\":\"..\"},{\"language\":\"nl-NL\",\"value\":\"..\"}],[{\"language\":\"en-GB\",\"value\":\"..\"},{\"language\":\"nl-NL\",\"value\":\"..\"}],[{\"language\":\"en-GB\",\"value\":\"..\"},{\"language\":\"nl-NL\",\"value\":\"..\"}]],\"admissionRequirements\":[{\"language\":\"en-GB\",\"value\":\"..\"},{\"language\":\"nl-NL\",\"value\":\"..\"}],\"enrollment\":[{\"language\":\"en-GB\",\"value\":\"..\"},{\"language\":\"nl-NL\",\"value\":\"..\"}]}}}"
+ }
+ },
+ {
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bdb/B01Nevo0mOGVLZ2PDPnEeX66WAHdtRSUAHoqjOlAXpVI5KKoi7/N8fazqUBRhKRnPKOcushkpWd5SbbaH9F7dV8nXQGS/hWDswldml7xZp4Qt2WWLdh0PtIU6c3e6BbWf6U6vG6sZwKBxuTR8k0UruOILIWI0pTUpu3dNEoCf4+RQdl7MUF4+01nntD6TlyK/NuoWNTDNk34k99PMdENSNIcjA2fxNZiEL7tqmJug+ctb+UFpjs5UM/8zr/xPtogljB4QJfyXx9KYqKcdj36i8k7wnGCqPhbtwSS0x/s4iIIbw/SCNxfd6r2Wp4YBQxJDdzkI0ZOQ25fbtvUOauzAyCPVRpvEg8HMchbTISCjDVSPWxiW3TirAejS+A7Dw=2024-11-05T12:07:17.782Z2024-11-05T12:17:17.782Zhttp://duo.nl/contract/DUO_RIO_Raadplegen_OnderwijsOrganisatie_V4/opvragen_aangebodenOpleidinghttp://www.w3.org/2005/08/addressing/anonymous?oin=0000000700025BE00000215709b0-b7ce-4106-8f03-77c1936dbfd9https://duo.nl/RIO/services/raadplegen4.0?oin=0000000180086647200069becd5d-adb4-4b7d-a5a7-ce35515b37de0000000700025BE00000000000018008664720002024-11-05T12:07:17.779Z0f212491-c96a-4141-8718-86d40a4ebfd3",
+ "headers": {
+ "SOAPAction": "http://duo.nl/contract/DUO_RIO_Raadplegen_OnderwijsOrganisatie_V4/opvragen_aangebodenOpleiding",
+ "traceparent": "00-ec27b43a8ddee76bfc75359bc94d0915-ff668f1b21759b70-00"
+ }
+ },
+ "res": {
+ "status": 200,
+ "body": "\nhttp://www.w3.org/2005/08/addressing/anonymous?oin=0000000700025BE00000http://duo.nl/contract/DUO_RIO_Raadplegen_OnderwijsOrganisatie_V4/opvragen_aangebodenOpleidingurn:uuid:b7a22d93-d568-4653-9384-9da5d0d949ff215709b0-b7ce-4106-8f03-77c1936dbfd9http://www.w3.org/2005/08/addressing/anonymous?oin=000000018008664720002024-11-05T12:07:18Z2024-11-05T12:12:18ZMIIHkzCCBXugAwI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5SrB8BRXRYYdD0gtwO15RRCh0PHZTCEx+rWI8NxXO/Yn+l3xU+5P1/MlAeiSVYBy7QHx70vqzboeCQ4y8+hFsrP0O3hP7+FW0T404bJoAe4V/lQm/zVp2oUgtFzfk8SxLSiPERJeuG4a7IxkzTSmU17Za1q2DgIyrFc3xdHvPFofli+pMmmKtJTFb4yxPChOvHWK3O1V+ZW5GOPVT3OKtX98xlAYpE6d33hNLwIgGYw+wUl/owM9J3gMMe0+jX95lnjFGyBxWkDJVbzrXOx69W03TxqSslprIfluRhN9/jmcI8gzB+Mrk5o0qnjfFAXfsUFyhw1dfHUy3gzo2SF3IUCeqmvS/yR+Vdk/Dl/raOFJbC8dphxzHZsASEX5bY56IWxMXzPb6JSoKKSAEwTBshnz+YEJpLcpJruausdtnpQ25h02tC0FuGkz8whSgF1zCxBtOfMrEGNkz3snlobqqCWYF/fL3mT6Tl0=69becd5d-adb4-4b7d-a5a7-ce35515b37de000000018008664720000000000700025BE000002024-11-05T12:07:17.779Ztrue0f212491-c96a-4141-8718-86d40a4ebfd3110A1331016O0261107X2152008-10-182010-01-312023-12-182008-10-18Zomaar een programmaSome a program..deficientieDEFICIENTIESversneldTrajectGEEN_VERSNELD_TRAJECTeigenNaamKortTECpropedeutischeFaseGEEN_PROPEDEUTISCHE_FASEeisenWerkzaamhedenEISENstudiekeuzecheckGEEN_STUDIEKEUZE_CHECKwebsitehttps://universiteit-van-morra.nl/programs/0f212491-c96a-4141-8718-86d40a4ebfd31234qwe12Odeelnemersplaatsen200.0opleidingsvormKLASSIKAAL2019-05-012019-08-242019-09-242019-08-01JA2023-06-15TOTALE_VERPLICHTE_KOSTEN340.84eigenAangebodenOpleidingSleutel0f212491-c96a-4141-8718-86d40a4ebfd3vormDUAALvoertaalENGtoestemmingDeelnameSTAPGEEN_TOESTEMMING_VERLEEND"
+ }
+ },
+ {
+ "req": {
+ "url": "https://gateway.test.surfeduhub.nl/programs/0f212491-c96a-4141-8718-86d40a4ebfd3/offerings?pageSize=250&consumer=rio",
+ "method": "get",
+ "headers": {
+ "X-Route": "endpoint=endpoint01.sandbox.jomco.nl",
+ "Accept": "application/json; version=5",
+ "traceparent": "00-ec27b43a8ddee76bfc75359bc94d0915-fa1b7e4093a53dff-00"
+ }
+ },
+ "res": {
+ "status": 200,
+ "body": "{\"gateway\":{\"requestId\":\"4RdVaATgrb0lnEI4RX1lLa\",\"traceparent_trace_id\":\"ec27b43a8ddee76bfc75359bc94d0915\",\"traceparent_id\":\"78a5cefd378ebc6d\",\"request\":\"/programs/0f212491-c96a-4141-8718-86d40a4ebfd3/offerings?pageSize=250&consumer=rio\",\"endpoints\":{\"endpoint01.sandbox.jomco.nl\":{\"url\":\"https://proxy.swift.surfsara.nl/v1/KEY_8e0eecf8d38141f7aa98bc3078fc9ccd/rio-mapper-test-suite/programs/0f212491-c96a-4141-8718-86d40a4ebfd3/offerings?pageSize=250&consumer=rio\",\"responseCode\":200,\"headers\":{\"content-length\":\"2787\",\"content-type\":\"application/json\"}}}},\"responses\":{\"endpoint01.sandbox.jomco.nl\":{\"pageSize\":10,\"pageNumber\":1,\"hasPreviousPage\":false,\"hasNextPage\":false,\"totalPages\":1,\"items\":[{\"offeringId\":\"cafecafe-cafe-cafe-cafe-cafecafecafe\",\"primaryCode\":{\"codeType\":\"identifier\",\"code\":\"1234qwe12\"},\"offeringType\":\"component\",\"academicSession\":\"cafecafe-cafe-cafe-cafe-cafecafecafe\",\"name\":[{\"language\":\"en-GB\",\"value\":\"some-program-offering\"}],\"abbreviation\":\"Test-INFOMQNM-20FS\",\"description\":[{\"language\":\"en-GB\",\"value\":\"..\"}],\"teachingLanguage\":\"nld\",\"modeOfDelivery\":[\"situated\"],\"maxNumberStudents\":200,\"enrolledNumberStudents\":150,\"pendingNumberStudents\":50,\"minNumberStudents\":15,\"resultExpected\":true,\"resultValueType\":\"1-10\",\"link\":\"https://osiris.uu.nl/osiris_student_uuprd/OnderwijsCatalogusZoekCursus.do#submitForm?cursuscode=INFOMQNM\",\"otherCodes\":[{\"codeType\":\"identifier\",\"code\":\"1234qwe12\"}],\"consumers\":[{\"consumerKey\":\"rio\",\"explanationRequiredPermission\":\"Toestemming is vereist omdat we daarom vragen.\",\"requiredPermissionRegistration\":\"yes\",\"registrationStatus\":\"open\"}],\"ext\":{},\"startDate\":\"2019-08-21\",\"endDate\":\"2023-06-15\",\"enrollStartDate\":\"2019-05-01\",\"enrollEndDate\":\"2019-08-01\",\"flexibleEntryPeriodStart\":\"2019-08-24\",\"flexibleEntryPeriodEnd\":\"2019-09-24\",\"addresses\":[{\"addressType\":\"postal\",\"street\":\"Moreelsepark\",\"streetNumber\":\"48\",\"additional\":[{\"language\":\"en-GB\",\"value\":\"On the other side of the road\"}],\"postalCode\":\"3511 EP\",\"city\":\"Utrecht\",\"countryCode\":\"NL\",\"geolocation\":{\"latitude\":52.089123,\"longitude\":5.113337},\"ext\":{}}],\"priceInformation\":[{\"costType\":\"total costs\",\"amount\":\"340.84\",\"vatAmount\":\"40\",\"amountWithoutVat\":\"300.84\",\"currency\":\"EUR\",\"displayAmount\":[{\"language\":\"nl-NL\",\"value\":\"€380,84\"},{\"language\":\"en-US\",\"value\":\"$401.17\"}],\"ext\":{}}],\"program\":\"0f212491-c96a-4141-8718-86d40a4ebfd3\"}],\"ext\":{}}}}"
+ }
+ }
+ ],
+ "action": "dry-run-upsert",
+ "finished-at": "2024-11-05T12:07:18.371300Z",
+ "attributes": {
+ "begindatum": {
+ "diff": false
+ },
+ "eigenNaamInternationaal": {
+ "diff": false
+ },
+ "eigenNaamAangebodenOpleiding": {
+ "diff": false
+ },
+ "cohorten": {
+ "diff": false
+ },
+ "aangebodenOpleidingCode": "0f212491-c96a-4141-8718-86d40a4ebfd3",
+ "eigenOmschrijving": {
+ "diff": false
+ },
+ "status": "found",
+ "onderwijsaanbiedercode": {
+ "diff": false
+ },
+ "onderwijslocatiecode": {
+ "diff": false
+ }
+ },
+ "created-at": "2024-11-05T12:07:16.671379Z"
+}
diff --git a/test/nl/surf/eduhub_rio_mapper/endpoints/api_test.clj b/test/nl/surf/eduhub_rio_mapper/endpoints/api_test.clj
index 7adbe96f..e021a3ab 100644
--- a/test/nl/surf/eduhub_rio_mapper/endpoints/api_test.clj
+++ b/test/nl/surf/eduhub_rio_mapper/endpoints/api_test.clj
@@ -17,7 +17,9 @@
;; .
(ns nl.surf.eduhub-rio-mapper.endpoints.api-test
- (:require [clojure.test :refer :all]
+ (:require [clojure.data.json :as json]
+ [clojure.test :refer :all]
+ [clojure.walk :as walk]
[nl.jomco.http-status-codes :as http-status]
[nl.surf.eduhub-rio-mapper.endpoints.api :as api]
[nl.surf.eduhub-rio-mapper.endpoints.status :as status]
@@ -354,7 +356,6 @@
(cond-> (app {:token "test-error"})
:created-at (assoc-in [:body :created-at] true)
:finished-at (assoc-in [:body :finished-at] true))))
-
(status/purge! config)))
(deftest jobqueue
@@ -362,3 +363,20 @@
req (assoc-in req [:headers "x-callback"] "https://google.com/")]
(is (= http-status/ok (:status (api-routes req))))
(is (= "https://google.com/" (::job/callback-url @last-job)))))
+
+;; In the http-messages, generally keywords are used for keys, except for the headers, there we use strings.
+(defn- stringify-headers [{req :req, res :res}]
+ {:res res
+ :req (assoc req :headers (walk/stringify-keys (:headers req)))})
+
+(deftest status-http-messages
+ (let [http-message (-> (slurp "test/fixtures/http-messages-1.json")
+ (json/read-str :key-fn keyword)
+ :http-messages
+ first
+ stringify-headers
+ api/add-single-parsed-json-response)]
+ (is (string? (get-in http-message [:res :body])))
+ (is (map? (get-in http-message [:res :json-body])))
+ (is (= "/programs/0f212491-c96a-4141-8718-86d40a4ebfd3?returnTimelineOverrides=true"
+ (get-in http-message [:res :json-body :gateway :request])))))