{ "info": { "_postman_id": "7573cc79-8d9a-4dfd-8b2e-1c4079752653", "name": "DID Web Discovery Tutorial", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Get Access Token", "event": [ { "listen": "test", "script": { "exec": [ "// Token requests are expected to return a `200 Success` response code. Any", "// other response code should trigger a failure.", "pm.test(\"must return `200 Success` status\", function() {", " pm.response.to.have.status(200);", "})", "", "// The response should include an `access_token` value - this will be presented", "// to authenticated API endpoints in the `Authentication` header (see the last", "// testing code block for details on how this is persisted).", "pm.test(\"response body must include non-empty access_token\", function () {", " const { access_token } = pm.response.json()", " pm.expect(access_token).to.be.a('string').that.is.not.empty;", "});", "", "// The type of `access_token` returned by the token request is expected to be", "// `Bearer`.", "pm.test(\"response body must represent `Bearer` token\", function() {", " const { token_type } = pm.response.json()", " pm.expect(token_type).to.equal(\"Bearer\");", "});", "", "// The returned data includes an `expires_in` field that indicates time until", "// token expiration. Validate that this value is a whole number greater than", "// zero, as anything less than or equal to zero means that the `access_token`", "// is already expired.", "pm.test(\"returned token must expire in the future\", function() {", " const { expires_in } = pm.response.json()", " pm.expect(expires_in).to.be.above(0);", "});", "", "// The returned `access_token` value is persisted as a Postman collection", "// variable that can be accessed by other requests in the collection by calling", "// `pm.collectionVariables.get(\"access_token\")`.", "pm.test(\"`access_token` persisted to collectionVariables\", function() {", " const { access_token } = pm.response.json()", " pm.collectionVariables.set(\"access_token\", access_token);", "});" ], "type": "text/javascript" } } ], "request": { "method": "POST", "header": [], "body": { "mode": "urlencoded", "urlencoded": [ { "key": "audience", "value": "{{TOKEN_AUDIENCE}}", "type": "text" }, { "key": "client_id", "value": "{{CLIENT_ID}}", "type": "text" }, { "key": "client_secret", "value": "{{CLIENT_SECRET}}", "type": "text" }, { "key": "grant_type", "value": "client_credentials", "type": "text" }, { "key": "scope", "value": "{{CLIENT_SCOPE}}", "type": "text" } ] }, "url": { "raw": "{{TOKEN_ENDPOINT}}", "host": [ "{{TOKEN_ENDPOINT}}" ] } }, "response": [] }, { "name": "Get Organization DIDs", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"must include valid JSON response body\", function() {", " pm.response.json(); // will throw on parse failure", "});", "", "// The response JSON must include a didDocument property that contains the", "// resolved DID document.", "pm.test(\"didDocument must be present in response body\", function() {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('didDocument');", "});", "", "// Service array is used to look up traceability API service endpoint", "pm.test(\"Response must include 'service' array\", function() {", " const { service } = pm.response.json().didDocument;", " pm.expect(service).to.be.an('array').that.is.not.empty;", "});", "", "// Service array must be correctly defined in DID document", "pm.test(\"'service' array must define Traceability API service endpoint\", function() {", " const { service } = pm.response.json().didDocument;", " const entry = service.find((s) => s.type == \"TraceabilityAPI\");", " pm.expect(entry).to.be.an('object').that.is.not.empty;", " pm.expect(entry.serviceEndpoint).to.be.a('string').that.is.not.empty;", "});", "", "// If a verificationMethod property is present, the controller property must", "// match the didDocument.id property.", "pm.test(\"verification method controller must match did subject\", function() {", " const { didDocument } = pm.response.json();", " const vm = didDocument.verificationMethod || [];", " vm.forEach((m) => pm.expect(m.controller).to.equal(didDocument.id));", "});" ], "type": "text/javascript" } } ], "protocolProfileBehavior": { "disabledSystemHeaders": {} }, "request": { "auth": { "type": "bearer", "bearer": [ { "key": "token", "value": "{{access_token}}", "type": "string" } ] }, "method": "GET", "header": [ { "key": "Accept", "value": "application/json", "type": "text" } ], "url": { "raw": "{{API_BASE_URL}}/identifiers/{{ORGANIZATION_DID_WEB}}", "host": [ "{{API_BASE_URL}}" ], "path": [ "identifiers", "{{ORGANIZATION_DID_WEB}}" ] } }, "response": [] } ], "event": [ { "listen": "prerequest", "script": { "type": "text/javascript", "exec": [ "pm.request.headers.add({key: 'User-Agent', value: 'W3C Traceability Interop Tests'});" ] } }, { "listen": "test", "script": { "type": "text/javascript", "exec": [ "" ] } } ], "variable": [ { "key": "access_token", "value": "" } ] }