{"info":{"_postman_id":"d7ddd198-7dd0-4ab2-8459-fa118d0e29a4","name":"1_Sessions","description":"<html><head></head><body><p>Create, Delete and View iLO sessions. Use of the Postman <code>test</code> facility to capture the session Token and Session Location during the session creation.  </p>\n<p>Read the <a href=\"https://developer.hpe.com/blog/managing-ilo-sessions-with-redfish\">Managing iLO sessions with Redfish</a> article to better understand iLO session management.</p>\n<p><a href=\"https://documenter.getpostman.com/view/3625509/RzfmEST5\">Published</a></p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"3625509","collectionId":"d7ddd198-7dd0-4ab2-8459-fa118d0e29a4","publishedId":"RzfmEST5","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"publishDate":"2020-03-13T14:53:40.000Z"},"item":[{"name":"Create Session","event":[{"listen":"test","script":{"id":"1eb9a163-e871-4ec0-b843-82c96d7d14f4","exec":["pm.environment.set(\"Token\", pm.response.headers.get(\"X-Auth-Token\"))","// TBD: test if Location header contains 'https://<ip>' ","// https://learning.postman.com/docs/writing-scripts/script-references/test-examples/#get-started-with-tests","pm.environment.set(\"SessionLocation\", pm.response.headers.get(\"Location\"))","","","console.log(\"Token:\", pm.variables.get(\"Token\")); ","console.log(\"SessionLocation:\", pm.variables.get(\"SessionLocation\")); "],"type":"text/javascript","packages":{}}},{"listen":"prerequest","script":{"id":"5d0044a0-f74c-4ff3-b7a6-cfe107496b37","exec":[""],"type":"text/javascript","packages":{}}}],"id":"ca6358bb-ce0b-4c07-88f5-e91a2576df32","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"UserName\": \"{{BmcUser}}\",\n    \"Password\": \"{{BmcPasswd}}\"\n}"},"url":"{{BmcURL}}/redfish/v1/SessionService/Sessions","description":"<p>Get Session Token</p>\n","urlObject":{"path":["redfish","v1","SessionService","Sessions"],"host":["{{BmcURL}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"ca6358bb-ce0b-4c07-88f5-e91a2576df32"},{"name":"Create AD Session","event":[{"listen":"test","script":{"id":"1eb9a163-e871-4ec0-b843-82c96d7d14f4","exec":["pm.environment.set(\"Token\", postman.getResponseHeader(\"X-Auth-Token\"));","pm.environment.set(\"SessionLocation\", postman.getResponseHeader(\"Location\"));","","","//console.log(\"Token:\", pm.variables.get(\"Token\")); ","//console.log(\"SessionLocation:\", pm.variables.get(\"SessionLocation\")); "],"type":"text/javascript"}}],"id":"e2d98df8-742c-4477-9d93-994b550dfae4","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n\t\"UserName\": \"{{ActiveDirectoryUser}}\",\n\t\"Password\": \"{{ActiveDirectoryPasswd}}\"\n\t\n}\n"},"url":"{{iloURI}}/redfish/v1/SessionService/Sessions/","description":"<p>Get Session Token</p>\n","urlObject":{"path":["redfish","v1","SessionService","Sessions",""],"host":["{{iloURI}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"e2d98df8-742c-4477-9d93-994b550dfae4"},{"name":"Create TFA Session","event":[{"listen":"test","script":{"id":"1eb9a163-e871-4ec0-b843-82c96d7d14f4","exec":["pm.environment.set(\"Token\", postman.getResponseHeader(\"X-Auth-Token\"));","pm.environment.set(\"SessionLocation\", postman.getResponseHeader(\"Location\"));","","","//console.log(\"Token:\", pm.variables.get(\"Token\")); ","//console.log(\"SessionLocation:\", pm.variables.get(\"SessionLocation\")); "],"type":"text/javascript"}}],"id":"b5584e55-2b9a-4b2b-a0fa-977a0746afc1","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"UserName\": \"{{ActiveDirectoryUser}}\",\n    \"Password\": \"{{ActiveDirectoryPasswd}}\",\n    \"Token\": \"123456\"\n}"},"url":"{{iloURI}}/redfish/v1/SessionService/Sessions/","description":"<p>Get Session Token</p>\n","urlObject":{"path":["redfish","v1","SessionService","Sessions",""],"host":["{{iloURI}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"b5584e55-2b9a-4b2b-a0fa-977a0746afc1"},{"name":"Session Collection","event":[{"listen":"test","script":{"id":"43481402-97ba-4d30-9a28-bc6e14228909","exec":[""],"type":"text/javascript"}}],"id":"0cc6ed27-c4a1-4b0c-9f7f-17f311c7adf1","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"GET","header":[{"key":"X-Auth-Token","value":"{{Token}}"},{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"}],"url":"{{BmcURL}}/redfish/v1/SessionService/Sessions/","description":"<p>Get Session Token</p>\n","urlObject":{"path":["redfish","v1","SessionService","Sessions",""],"host":["{{BmcURL}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"0cc6ed27-c4a1-4b0c-9f7f-17f311c7adf1"},{"name":"Manager Max Sessions","id":"3bdfebb1-e614-4f05-bab7-34047bc65ba2","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-Token","value":"{{Token}}"}],"body":{"mode":"raw","raw":""},"url":"{{BmcURL}}/redfish/v1/Managers/{{ManagerId}}/?$select=GraphicalConsole/MaxConcurrentSessions, CommandShell/MaxConcurrentSessions,SerialConsole/MaxConcurrentSessions","description":"<p>iLO top level</p>\n","urlObject":{"path":["redfish","v1","Managers","{{ManagerId}}",""],"host":["{{BmcURL}}"],"query":[{"key":"$select","value":"GraphicalConsole/MaxConcurrentSessions, CommandShell/MaxConcurrentSessions,SerialConsole/MaxConcurrentSessions"}],"variable":[]}},"response":[],"_postman_id":"3bdfebb1-e614-4f05-bab7-34047bc65ba2"},{"name":"Delete iLO Session","event":[{"listen":"test","script":{"id":"b2b25c1e-241f-4abe-afe8-159806c51c49","exec":["pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include(\"Success\");","});","","// Environment Cleanup","pm.environment.unset('PowerState'); ","pm.environment.unset('PostState');  ","pm.environment.unset('SmartArrayDiscovery');","pm.environment.unset('Token');","pm.environment.unset('SessionLocation');"],"type":"text/javascript"}}],"id":"019ea64a-f68a-4b42-9c61-568b95a80991","request":{"auth":{"type":"noauth","isInherited":false},"method":"DELETE","header":[{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-Token","value":"{{Token}}"}],"body":{"mode":"raw","raw":""},"url":"{{SessionLocation}}","description":"<p>DELETE Session</p>\n","urlObject":{"host":["{{SessionLocation}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"019ea64a-f68a-4b42-9c61-568b95a80991"},{"name":"Delete a Non-iLO Session","event":[{"listen":"test","script":{"id":"b2b25c1e-241f-4abe-afe8-159806c51c49","exec":["pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include(\"Success\");","});","","// Environment Cleanup","pm.environment.unset('PowerState'); ","pm.environment.unset('PostState');  ","pm.environment.unset('SmartArrayDiscovery');","pm.environment.unset('Token');","pm.environment.unset('SessionLocation');"],"type":"text/javascript"}}],"id":"e4672ba7-905f-4462-aa2d-7d4b48ad8961","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"DELETE","header":[{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-Token","value":"{{Token}}"}],"body":{"mode":"raw","raw":""},"url":"{{BmcURL}}{{SessionLocation}}","description":"<p>DELETE Session</p>\n","urlObject":{"host":["{{BmcURL}}{{SessionLocation}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"e4672ba7-905f-4462-aa2d-7d4b48ad8961"},{"name":"Delete AppAccount","event":[{"listen":"test","script":{"id":"b2b25c1e-241f-4abe-afe8-159806c51c49","exec":["pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include(\"Success\");","});","",""],"type":"text/javascript","packages":{}}}],"id":"8148e8e1-60b3-47cf-9384-0d7d5163f9a0","request":{"auth":{"type":"noauth","isInherited":false},"method":"DELETE","header":[{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-Token","value":"{{Token}}"}],"body":{"mode":"raw","raw":""},"url":"{{BmcURL}}/redfish/v1/AccountService/Oem/Hpe/AppAccounts/65606/","description":"<p>DELETE Session</p>\n","urlObject":{"path":["redfish","v1","AccountService","Oem","Hpe","AppAccounts","65606",""],"host":["{{BmcURL}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"8148e8e1-60b3-47cf-9384-0d7d5163f9a0"},{"name":"SessionsWithBasicAuthentication","event":[{"listen":"test","script":{"id":"43481402-97ba-4d30-9a28-bc6e14228909","type":"text/javascript","exec":[""]}}],"id":"5606fb65-83e2-4962-baf7-1d2dc1eccd0d","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{iloUser}}"},{"key":"password","value":"{{iloPasswd}}"}]},"isInherited":false},"method":"GET","header":[{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"}],"url":"{{iloURI}}/redfish/v1/SessionService/Sessions/","description":"<p>Get Sessions using Basic Authentication, case of problems with the Token generation mechanism.</p>\n","urlObject":{"path":["redfish","v1","SessionService","Sessions",""],"host":["{{iloURI}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"5606fb65-83e2-4962-baf7-1d2dc1eccd0d"},{"name":"Create COM session","event":[{"listen":"test","script":{"id":"95422d5c-5c74-4e32-934f-9cc8ef9d1d26","exec":["const responseJson = pm.response.json();\r","\r","// Set environment variables\r","pm.environment.set(\"COM_Token\", responseJson.access_token);\r","\r","// Display in console. To see the console, go to View / Show Postman Console\r","console.log(\"COM Token:\", pm.environment.get(\"COM_Token\")); \r","\r","// Display in Test Results\r","pm.test(\"COM session token = \" + pm.environment.get(\"COM_Token\")); "],"type":"text/javascript"}}],"id":"a89c80cb-0d05-4ff9-91f5-7d31a5c083c2","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"urlencoded","urlencoded":[{"key":"grant_type","value":"client_credentials","type":"text"},{"key":"client_id","value":"{{ClientID}}","type":"text"},{"key":"client_secret","value":"{{ClientSecret}}","type":"text"}]},"url":"https://sso.common.cloud.hpe.com/as/token.oauth2","description":"<p>See HPE Greenlake for Compute Ops Management API</p>\n<p><a href=\"https://developer.greenlake.hpe.com/docs/greenlake/services/compute-ops/public/openapi/compute-ops-latest/overview/\">https://developer.greenlake.hpe.com/docs/greenlake/services/compute-ops/public/openapi/compute-ops-latest/overview/</a></p>\n","urlObject":{"protocol":"https","path":["as","token.oauth2"],"host":["sso","common","cloud","hpe","com"],"query":[],"variable":[]}},"response":[],"_postman_id":"a89c80cb-0d05-4ff9-91f5-7d31a5c083c2"},{"name":"Check-Warranty session","event":[{"listen":"test","script":{"id":"95422d5c-5c74-4e32-934f-9cc8ef9d1d26","exec":["const responseJson = pm.response.json();\r","\r","// Set environment variables\r","pm.environment.set(\"Warranty_Token\", responseJson.access_token);\r","\r","// Display in console. To see the console, go to View / Show Postman Console\r","console.log(\"Warranty Token:\", pm.environment.get(\"Warranty_Token\")); \r","\r","// Display in Test Results\r","pm.test(\"Warranty session token = \" + pm.environment.get(\"Warranty_Token\")); "],"type":"text/javascript"}}],"id":"628009f5-465f-4bea-93f3-90961e814fe5","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"urlencoded","urlencoded":[{"key":"grant_type","value":"client_credentials","type":"text"},{"key":"client_id","value":"{{ClientID}}","type":"text"},{"key":"client_secret","value":"{{ClientSecret}}","type":"text"}]},"url":"https://api-gw.support.hpe.com/apigwext/services/oauth/token","description":"<p>See HPE Greenlake for Compute Ops Management API</p>\n<p><a href=\"https://developer.greenlake.hpe.com/docs/greenlake/services/compute-ops/public/openapi/compute-ops-latest/overview/\">https://developer.greenlake.hpe.com/docs/greenlake/services/compute-ops/public/openapi/compute-ops-latest/overview/</a></p>\n","urlObject":{"protocol":"https","path":["apigwext","services","oauth","token"],"host":["api-gw","support","hpe","com"],"query":[],"variable":[]}},"response":[],"_postman_id":"628009f5-465f-4bea-93f3-90961e814fe5"},{"name":"Create OV Session","event":[{"listen":"test","script":{"id":"7afa8cfb-d334-412c-8a81-0c37e1e860a9","exec":["//pm.environment.set(\"Token\", postman.getResponseHeader(\"X-Auth-Token\"));\r","//pm.environment.set(\"SessionLocation\", postman.getResponseHeader(\"Location\"));\r","\r","//console.log(\"Token:\", pm.variables.get(\"Token\")); \r","//console.log(\"SessionLocation:\", pm.variables.get(\"SessionLocation\")); \r","\r","var jsonData = JSON.parse(responseBody);\r","postman.setEnvironmentVariable(\"sessionID\", jsonData.sessionID);\r","\r","var jsonData = JSON.parse(responseBody);\r","postman.setEnvironmentVariable(\"Token\", jsonData.sessionID);\r",""],"type":"text/javascript"}}],"id":"aab10b03-accb-4c5b-9bef-74bf438cf33b","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Accept","value":"application/json","type":"text"},{"key":"Content-Type","value":"application/json","type":"text"},{"key":"x-api-version","value":"2600","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"userName\": \"{{OvUserName}}\",\r\n    \"password\": \"{{OvPassword}}\"\r\n}","options":{"raw":{"language":"json"}}},"url":"{{OneViewURI}}/rest/login-sessions","urlObject":{"path":["rest","login-sessions"],"host":["{{OneViewURI}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"aab10b03-accb-4c5b-9bef-74bf438cf33b"},{"name":"Delete MyPostman Session","event":[{"listen":"test","script":{"id":"b2b25c1e-241f-4abe-afe8-159806c51c49","exec":["pm.test(\"Body matches string\", function () {","    pm.expect(pm.response.text()).to.include(\"Success\");","});","","// Environment Cleanup","pm.environment.unset('PowerState'); ","pm.environment.unset('PostState');  ","pm.environment.unset('SmartArrayDiscovery');","pm.environment.unset('Token');","pm.environment.unset('SessionLocation');"],"type":"text/javascript"}}],"id":"b8610650-f994-4269-b766-1ff3fb604349","request":{"auth":{"type":"noauth","isInherited":false},"method":"DELETE","header":[{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-Token","value":"{{Token}}"}],"body":{"mode":"raw","raw":""},"url":"{{SessionLocation}}","description":"<p>DELETE Session</p>\n","urlObject":{"host":["{{SessionLocation}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"b8610650-f994-4269-b766-1ff3fb604349"},{"name":"SessionTimeout","id":"421f0522-4593-40ac-8a64-e9d0100b1f7c","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{BmcUser}}"},{"key":"password","value":"{{BmcPasswd}}"}]},"isInherited":false},"method":"PATCH","header":[{"key":"Content-Type","value":"application/json","type":"text"},{"key":"OData-Version","value":"4.0","type":"text"},{"key":"If-Match","value":"W/\"1749112716\"","type":"text"}],"body":{"mode":"raw","raw":"{\n\"SessionTimeout\": 1800\n}","options":{"raw":{"language":"json"}}},"url":"{{BmcURL}}/redfish/v1/SessionService","description":"<p>unit of session timeout: second</p>\n<p>A PATCH of the <code>SessionTimeout</code> property may be needed with Cray XD670 / AMI BMC. The <code>if-Match=etag</code> pre-condition is required.</p>\n","urlObject":{"path":["redfish","v1","SessionService"],"host":["{{BmcURL}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"421f0522-4593-40ac-8a64-e9d0100b1f7c"},{"name":"SessionService","event":[{"listen":"test","script":{"id":"43481402-97ba-4d30-9a28-bc6e14228909","exec":[""],"type":"text/javascript","packages":{}}}],"id":"df4a5bcf-dea1-456b-9c05-a2da4ef0df9e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":{"basicConfig":[{"key":"username","value":"{{BmcUser}}"},{"key":"password","value":"{{BmcPasswd}}"}]},"isInherited":false},"method":"GET","header":[{"key":"OData-Version","value":"4.0"},{"key":"Content-Type","value":"application/json"}],"url":"{{BmcURL}}/redfish/v1/SessionService","description":"<p>Use the following to encode <code>username:password</code> into Base64:</p>\n<p><code>printf 'username:password` | base64 -</code></p>\n<p>With PowerShell:</p>\n<p><code>$string = \"usernme:password\"   $bytes = [System.Text.Encoding]::UTF8.GetBytes($string)   $base64EncodedString = [Convert]::ToBase64String($bytes)</code></p>\n","urlObject":{"path":["redfish","v1","SessionService"],"host":["{{BmcURL}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"df4a5bcf-dea1-456b-9c05-a2da4ef0df9e"}],"event":[{"listen":"prerequest","script":{"id":"fdcf0f0a-9b37-4928-820f-b291e56da7c4","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"f0401538-1ee2-411d-b80d-8b5445b1b70e","type":"text/javascript","exec":[""]}}]}