Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <#
  2. .SYNOPSIS
  3. Create and run test suite
  4. .DESCRIPTION
  5. Submit a multi-case test suite to v3 of the test-center API and execute it
  6. .PARAMETER UserID
  7. ID of the user executing the test. Must be the same as that used in your hostname creation previously
  8. .EXAMPLE
  9. > .\New-AkaUTests.ps1 -UserID example
  10. #>
  11. Param(
  12. [Parameter(Mandatory)]
  13. [string]
  14. $UserID,
  15. [Parameter()]
  16. [string]
  17. $EdgeRCFile,
  18. [Parameter()]
  19. [string]
  20. $Section,
  21. [Parameter()]
  22. [string]
  23. $AccountSwitchKey
  24. )
  25. $CommonParams = @{
  26. EdgeRCFile = $EdgeRCFile
  27. Section = $Section
  28. AccountSwitchKey = $AccountSwitchKey
  29. }
  30. # 1. Create test suite with child objects
  31. $TestSuiteJSON = @"
  32. {
  33. "testSuiteName": "AkaULab-$UserID-TestSuite",
  34. "isLocked": false,
  35. "isStateful": false,
  36. "testCases": [
  37. {
  38. "clientProfile": {
  39. "client": "CURL",
  40. "ipVersion": "IPV4"
  41. },
  42. "condition": {
  43. "conditionExpression": "Response code is one of \"302\""
  44. },
  45. "testRequest": {
  46. "requestMethod": "GET",
  47. "testRequestUrl": "https://{{userId}}mastertflab.akaudevops.com"
  48. }
  49. },
  50. {
  51. "clientProfile": {
  52. "client": "CURL",
  53. "ipVersion": "IPV4"
  54. },
  55. "condition": {
  56. "conditionExpression": "Response header \"X-Akamai-Staging\" has a value that equals \"ESSL\""
  57. },
  58. "testRequest": {
  59. "requestMethod": "GET",
  60. "testRequestUrl": "https://{{userId}}mastertflab.akaudevops.com"
  61. }
  62. },
  63. {
  64. "clientProfile": {
  65. "client": "CURL",
  66. "ipVersion": "IPV4"
  67. },
  68. "condition": {
  69. "conditionExpression": "Caching option is cache with max-age of \"30\" days"
  70. },
  71. "testRequest": {
  72. "requestMethod": "GET",
  73. "testRequestUrl": "https://{{userId}}mastertflab.akaudevops.com/assets/public/images/JuiceShop_Logo.png"
  74. }
  75. },
  76. {
  77. "clientProfile": {
  78. "client": "CURL",
  79. "ipVersion": "IPV4"
  80. },
  81. "condition": {
  82. "conditionExpression": "Response code is one of \"302\""
  83. },
  84. "testRequest": {
  85. "requestMethod": "GET",
  86. "testRequestUrl": "https://{{userId}}mastertflab-test.akaudevops.com"
  87. }
  88. },
  89. {
  90. "clientProfile": {
  91. "client": "CURL",
  92. "ipVersion": "IPV4"
  93. },
  94. "condition": {
  95. "conditionExpression": "Response header \"X-Test-Environment\" has a value that equals \"true\""
  96. },
  97. "testRequest": {
  98. "requestMethod": "GET",
  99. "testRequestUrl": "https://{{userId}}mastertflab-test.akaudevops.com"
  100. }
  101. },
  102. {
  103. "clientProfile": {
  104. "client": "CURL",
  105. "ipVersion": "IPV4"
  106. },
  107. "condition": {
  108. "conditionExpression": "Response header \"cache-control\" has a value that contains \"no-store\""
  109. },
  110. "testRequest": {
  111. "requestMethod": "GET",
  112. "testRequestUrl": "https://{{userId}}mastertflab-test.akaudevops.com/style.css"
  113. }
  114. },
  115. {
  116. "clientProfile": {
  117. "client": "CURL",
  118. "ipVersion": "IPV4"
  119. },
  120. "condition": {
  121. "conditionExpression": "Response code is one of \"403\""
  122. },
  123. "testRequest": {
  124. "testRequestUrl": "https://{{userId}}mastertflab.akaudevops.com/?pasword='OR%201=1",
  125. "requestMethod": "GET"
  126. }
  127. },
  128. {
  129. "clientProfile": {
  130. "client": "CURL",
  131. "ipVersion": "IPV4"
  132. },
  133. "condition": {
  134. "conditionExpression": "Response code is one of \"403\""
  135. },
  136. "testRequest": {
  137. "testRequestUrl": "https://{{userId}}mastertflab.akaudevops.com/",
  138. "requestMethod": "GET",
  139. "requestHeaders": [
  140. {
  141. "headerName": "blockme",
  142. "headerValue": "true",
  143. "headerAction": "ADD"
  144. }
  145. ]
  146. }
  147. },
  148. {
  149. "clientProfile": {
  150. "client": "CURL",
  151. "ipVersion": "IPV4"
  152. },
  153. "condition": {
  154. "conditionExpression": "Response code is one of \"403\""
  155. },
  156. "testRequest": {
  157. "testRequestUrl": "https://{{userId}}mastertflab.akaudevops.com/rest/user/login",
  158. "requestMethod": "GET"
  159. }
  160. },
  161. {
  162. "clientProfile": {
  163. "client": "CURL",
  164. "ipVersion": "IPV4"
  165. },
  166. "condition": {
  167. "conditionExpression": "Response code is one of \"403\""
  168. },
  169. "testRequest": {
  170. "testRequestUrl": "https://{{userId}}mastertflab.akaudevops.com/",
  171. "requestMethod": "GET",
  172. "requestHeaders": [
  173. {
  174. "headerName": "X-Forwarded-For",
  175. "headerValue": "101.110.112.0",
  176. "headerAction": "ADD"
  177. }
  178. ]
  179. }
  180. },
  181. {
  182. "clientProfile": {
  183. "client": "CURL",
  184. "ipVersion": "IPV4"
  185. },
  186. "condition": {
  187. "conditionExpression": "Response header \"set-cookie\" has a value that contains \"language=ko_KR\""
  188. },
  189. "testRequest": {
  190. "testRequestUrl": "https://{{userId}}mastertflab.akaudevops.com/",
  191. "requestMethod": "GET",
  192. "requestHeaders": [
  193. {
  194. "headerName": "X-Forwarded-For",
  195. "headerValue": "168.126.63.1",
  196. "headerAction": "ADD"
  197. }
  198. ]
  199. }
  200. }
  201. ],
  202. "variables": [
  203. {
  204. "variableName": "userId",
  205. "variableValue": "$UserID"
  206. }
  207. ]
  208. }
  209. "@
  210. try {
  211. $TestSuite = Invoke-AkamaiRestMethod -Method POST -Path '/test-management/v3/functional/test-suites/with-child-objects' -Body $TestSuiteJSON @CommonParams
  212. }
  213. catch {
  214. Write-Error "Error creating test suite. Cannot continue"
  215. Write-Error $_
  216. return
  217. }
  218. # 2. Execute Test Suite
  219. $TestExecutionJSON = @"
  220. {
  221. "functional": {
  222. "testSuiteExecutions": [
  223. {
  224. "testSuiteId": $($TestSuite.success.testSuiteId)
  225. }
  226. ]
  227. },
  228. "targetEnvironment": "STAGING",
  229. "note": "Executing test suite for user $UserID",
  230. "sendEmailOnCompletion": false
  231. }
  232. "@
  233. try {
  234. $Run = Invoke-AkamaiRestMethod -Method POST -Path '/test-management/v3/test-runs' -Body $TestExecutionJSON @CommonParams
  235. }
  236. catch {
  237. Write-Error "Error executing test suite $($TestSuite.success.testSuiteId). Cannot continue"
  238. Write-Error $_
  239. return
  240. }
  241. Write-Host -ForegroundColor Green "Test suite $($TestSuite.success.testSuiteId) created. Wait a few minutes before retrieving test run results with ID: $($Run.testRunId)"