| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | ## |
| 4 | # Copyright 2019 Tech Mahindra Limited |
| 5 | # |
| 6 | # All Rights Reserved. |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. You may obtain |
| 10 | # a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 17 | # License for the specific language governing permissions and limitations |
| 18 | # under the License. |
| 19 | ## |
| 20 | |
| 21 | ## Change log: |
| 22 | # 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com |
| 23 | ## |
| 24 | |
| 25 | |
| 26 | *** Variables *** |
| 27 | ${token}= ${EMPTY} |
| 28 | ${HOST}= ${EMPTY} |
| 29 | |
| 30 | |
| 31 | *** Keywords *** |
| 32 | Get Auth Token |
| 33 | [Tags] auth_token |
| 34 | |
| 35 | ${nbi_host}= Get Environment Variable OSM_HOSTNAME |
| 36 | ${passed}= Run Keyword And Return Status Should Contain ${nbi_host} : |
| 37 | Run Keyword If ${passed} Set Dockerized Host ${nbi_host} |
| 38 | ... ELSE Set Standalone Host ${nbi_host} |
| 39 | |
| 40 | Create Session osmhit ${HOST} verify=${FALSE} debug=1 headers=${HEADERS} |
| 41 | |
| 42 | Log Many ${auth_token_uri} @{data} ${data} |
| 43 | |
| 44 | ${resp}= Post Request osmhit ${auth_token_uri} data=${data} |
| 45 | log ${resp} |
| 46 | |
| 47 | Pass Execution If ${resp.status_code} in ${success_status_code_list} Get Auth Token completed |
| 48 | |
| 49 | ${content}= To Json ${resp.content} |
| 50 | ${t}= Get From Dictionary ${content} _id |
| 51 | |
| 52 | Set Suite Variable ${token} ${t} |
| 53 | |
| 54 | |
| 55 | Set Dockerized Host |
| 56 | [Arguments] ${env_host} |
| 57 | |
| 58 | Set Suite Variable ${HOST} https://${env_host} |
| 59 | |
| 60 | |
| 61 | Set Standalone Host |
| 62 | [Arguments] ${env_host} |
| 63 | |
| 64 | Set Suite Variable ${HOST} https://${env_host}:9999 |