|
| 1 | +*** Settings *** |
| 2 | +Library Collections |
| 3 | +Library OperatingSystem |
| 4 | +Library secret.py |
| 5 | +Variables secret.py |
| 6 | + |
| 7 | + |
| 8 | +*** Variables *** |
| 9 | +${FROM_LITERAL: Secret} this fails |
| 10 | +${FROM_EXISTING: secret} ${VAR_FILE} |
| 11 | +${FROM_JOIN: secret} abc${VAR_FILE}efg |
| 12 | +${FROM_ENV: SECRET} %{SECRET=kala} |
| 13 | +${ENV_JOIN: SECRET} qwe%{SECRET=kala}rty |
| 14 | +@{LIST: Secret} ${VAR_FILE} %{SECRET=kala} |
| 15 | +@{LIST_LITERAL: secret} this fails ${VAR_FILE} %{SECRET=kala} |
| 16 | +&{DICT1: Secret} var_file=${VAR_FILE} env=%{SECRET=kala} |
| 17 | +&{DICT2: secret=secret} ${VAR_FILE}=%{SECRET=kala} |
| 18 | +&{DICT_LITERAL: secret} this=fails ok=${VAR_FILE} |
| 19 | + |
| 20 | + |
| 21 | +*** Test Cases *** |
| 22 | +Command line |
| 23 | + Should Be Equal ${CLI.value} From command line |
| 24 | + |
| 25 | +Variable section: Scalar |
| 26 | + Should Be Equal ${FROM_EXISTING.value} From variable file |
| 27 | + Should Be Equal ${FROM_ENV.value} kala |
| 28 | + Should Be Equal ${FROM_JOIN.value} abcFrom variable fileefg |
| 29 | + Should Be Equal ${ENV_JOIN.value} qwekalarty |
| 30 | + Variable Should Not Exist ${FROM_LITERAL} |
| 31 | + |
| 32 | +Variable section: List |
| 33 | + Should Be Equal ${LIST[0].value} From variable file |
| 34 | + Should Be Equal ${LIST[1].value} kala |
| 35 | + Variable Should Not Exist ${LIST_LITERAL} |
| 36 | + |
| 37 | +Variable section: Dict |
| 38 | + Should Be Equal ${DICT1.var_file.value} From variable file |
| 39 | + Should Be Equal ${DICT1.env.value} kala |
| 40 | + Should Be Equal ${{$DICT2[$VAR_FILE].value}} kala |
| 41 | + Variable Should Not Exist ${DICT_LITERAL} |
| 42 | + |
| 43 | +VAR: Env variable |
| 44 | + Set Environment Variable SECRET VALUE1 |
| 45 | + VAR ${secret: secret} %{SECRET} |
| 46 | + Should Be Equal ${secret.value} VALUE1 |
| 47 | + VAR ${x} SECRET |
| 48 | + Set Environment Variable SECRET VALUE2 |
| 49 | + VAR ${secret: secret} %{${x}} |
| 50 | + Should Be Equal ${secret.value} VALUE2 |
| 51 | + VAR ${secret: secret} %{INLINE_SECRET=inline_secret} |
| 52 | + Should Be Equal ${secret.value} inline_secret |
| 53 | + |
| 54 | +VAR: Join secret |
| 55 | + [Documentation] FAIL |
| 56 | + ... Setting variable '\${zz: secret}' failed: \ |
| 57 | + ... Value '111\${y}222' must have type 'Secret', got string. |
| 58 | + ${secret1} Library Get Secret 111 |
| 59 | + ${secret2} Library Get Secret 222 |
| 60 | + VAR ${x: secret} abc${secret1} |
| 61 | + Should Be Equal ${x.value} abc111 |
| 62 | + VAR ${y: int} 42 |
| 63 | + VAR ${x: secret} ${secret2}${y} |
| 64 | + Should Be Equal ${x.value} 22242 |
| 65 | + VAR ${x: secret} ${secret1}${secret2} |
| 66 | + Should Be Equal ${x.value} 111222 |
| 67 | + VAR ${x: secret} -${secret1}--${secret2}--- |
| 68 | + Should Be Equal ${x.value} -111--222--- |
| 69 | + VAR ${x: secret} -${y}--${secret1}---${y}----${secret2}----- |
| 70 | + Should Be Equal |
| 71 | + ... ${x.value} |
| 72 | + ... -42--111---42----222----- |
| 73 | + Set Environment Variable SECRET VALUE10 |
| 74 | + VAR ${secret: secret} 11%{SECRET}22 |
| 75 | + Should Be Equal ${secret.value} 11VALUE1022 |
| 76 | + VAR ${zz: secret} 111${y}222 |
| 77 | + |
| 78 | +VAR: Broken variable |
| 79 | + [Documentation] FAIL |
| 80 | + ... Setting variable '\${x: Secret}' failed: Variable '${borken' was not closed properly. |
| 81 | + VAR ${x: Secret} ${borken |
| 82 | +
|
| 83 | +Create: List |
| 84 | + [Documentation] FAIL |
| 85 | + ... Setting variable '\@{x: secret}' failed: \ |
| 86 | + ... Value 'this' must have type 'Secret', got string. |
| 87 | + ${secret} Library Get Secret |
| 88 | + VAR @{x: secret} ${secret} ${secret} |
| 89 | + Should Be Equal ${x[0].value} This is a secret |
| 90 | + Should Be Equal ${x[1].value} This is a secret |
| 91 | + VAR @{x: int|secret} 22 ${secret} 44 |
| 92 | + Should Be Equal ${x[0]} 22 type=int |
| 93 | + Should Be Equal ${x[1].value} This is a secret |
| 94 | + Should Be Equal ${x[2]} 44 type=int |
| 95 | + VAR @{x: secret} ${secret} this fails |
| 96 | +
|
| 97 | +Create: List by extending |
| 98 | + ${secret} Library Get Secret |
| 99 | + VAR @{x: secret} ${secret} ${secret} |
| 100 | + VAR @{x} @{x} @{x} |
| 101 | + Length Should Be ${x} 4 |
| 102 | + Should Be Equal ${x[0].value} This is a secret |
| 103 | + Should Be Equal ${x[1].value} This is a secret |
| 104 | + Should Be Equal ${x[2].value} This is a secret |
| 105 | + Should Be Equal ${x[3].value} This is a secret |
| 106 | +
|
| 107 | +Create: List of dictionaries |
| 108 | + ${secret} Library Get Secret |
| 109 | + VAR &{dict1: secret} key1=${secret} key2=${secret} |
| 110 | + VAR &{dict2: secret} key3=${secret} |
| 111 | + VAR @{list} ${dict1} ${dict2} |
| 112 | + Length Should Be ${list} 2 |
| 113 | + FOR ${d} IN @{list} |
| 114 | + Dictionaries Should Be Equal ${d} ${d} |
| 115 | + END |
| 116 | +
|
| 117 | +Create: Dictionary |
| 118 | + [Documentation] FAIL |
| 119 | + ... Setting variable '\&{x: secret}' failed: \ |
| 120 | + ... Value 'fails' must have type 'Secret', got string. |
| 121 | + ${secret} Library Get Secret |
| 122 | + VAR &{x: secret} key=${secret} |
| 123 | + Should Be Equal ${x.key.value} This is a secret |
| 124 | + VAR &{x: int=secret} 42=${secret} |
| 125 | + Should Be Equal ${x[42].value} This is a secret |
| 126 | + VAR &{x: secret} this=fails |
| 127 | +
|
| 128 | +Return value: Library keyword |
| 129 | + [Documentation] FAIL |
| 130 | + ... ValueError: Return value must have type 'Secret', got string. |
| 131 | + ${x} Library Get Secret |
| 132 | + Should Be Equal ${x.value} This is a secret |
| 133 | + ${x: Secret} Library Get Secret value of secret here |
| 134 | + Should Be Equal ${x.value} value of secret here |
| 135 | + ${x: secret} Library Not Secret |
| 136 | +
|
| 137 | +Return value: User keyword |
| 138 | + [Documentation] FAIL |
| 139 | + ... ValueError: Return value must have type 'Secret', got string. |
| 140 | + ${x} User Keyword: Return secret |
| 141 | + Should Be Equal ${x.value} This is a secret |
| 142 | + ${x: Secret} User Keyword: Return secret |
| 143 | + Should Be Equal ${x.value} This is a secret |
| 144 | + ${x: secret} User Keyword: Return string |
| 145 | +
|
| 146 | +User keyword: Receive not secret |
| 147 | + [Documentation] FAIL |
| 148 | + ... ValueError: Argument 'secret' must have type 'Secret', got string. |
| 149 | + User Keyword: Receive secret xxx ${None} |
| 150 | +
|
| 151 | +User keyword: Receive not secret var |
| 152 | + [Documentation] FAIL |
| 153 | + ... ValueError: Argument 'secret' must have type 'Secret', got string. |
| 154 | + VAR ${x} y |
| 155 | + User Keyword: Receive secret ${x} ${None} |
| 156 | +
|
| 157 | +Library keyword |
| 158 | + ${secret: secret} Library Get Secret |
| 159 | + User Keyword: Receive secret ${secret} This is a secret |
| 160 | +
|
| 161 | +Library keyword: not secret 1 |
| 162 | + [Documentation] FAIL |
| 163 | + ... ValueError: Argument 'secret' must have type 'Secret', got string. |
| 164 | + Library receive secret 111 |
| 165 | +
|
| 166 | +Library keyword: not secret 2 |
| 167 | + [Documentation] FAIL |
| 168 | + ... ValueError: Argument 'secret' must have type 'Secret', got integer. |
| 169 | + Library receive secret ${222} |
| 170 | +
|
| 171 | +Library keyword: TypedDict |
| 172 | + [Documentation] FAIL |
| 173 | + ... ValueError: Argument 'credential' got value \ |
| 174 | + ... '{'username': 'login@email.com', 'password': 'This fails'}' (DotDict) that cannot be converted to Credential: \ |
| 175 | + ... Item 'password' must have type 'Secret', got string. |
| 176 | + ${secret: secret} Library Get Secret |
| 177 | + VAR &{credentials} username=login@email.com password=${secret} |
| 178 | + ${data} Library Receive Credential ${credentials} |
| 179 | + Should Be Equal ${data} Username: login@email.com, Password: This is a secret |
| 180 | + VAR &{credentials} username=login@email.com password=This fails |
| 181 | + Library Receive Credential ${credentials} |
| 182 | +
|
| 183 | +Library keyword: List of secrets |
| 184 | + ${secret: secret} Library Get Secret |
| 185 | + VAR @{secrets: secret} ${secret} ${secret} |
| 186 | + ${data} Library List Of Secrets ${secrets} |
| 187 | + Should Be Equal ${data} This is a secret, This is a secret |
| 188 | +
|
| 189 | +
|
| 190 | +*** Keywords *** |
| 191 | +User Keyword: Receive secret |
| 192 | + [Arguments] ${secret: secret} ${expected: str} |
| 193 | + Should Be Equal ${secret.value} ${expected} |
| 194 | +
|
| 195 | +User Keyword: Return secret |
| 196 | + ${secret} Library Get Secret |
| 197 | + RETURN ${secret} |
| 198 | +
|
| 199 | +User Keyword: Return string |
| 200 | + RETURN This is a string |
0 commit comments