ServiceV Pro: Default response unexpectedly replacing the scripted one
First thing first: I'm new to the ServiceV product, just got it few days ago. I'm creating a virt api where the following path is being used: /api/aicm/v1/subject/{subject_nr}/mandate/{creditor_id} where subject_nr and creditor_id represent the required TEMPLATE parameters. Beside the main success scenario (GET: -> HTTP 200 OK), where both arguments are made available in the URI, I'm trying to handle the following alternative scenarios in my virt api: a) GET: {subject_nr} is empty -> HTTP 400 Bad Request b) GET: {creditor_id} is empty -> HTTP 400 Bad Request c) GET: both {subject_nr} and {creditor_id} are empty -> HTTP 400 Bad Request The test paths associated with the four scenarios (1 main + 3 alts) are: 1. HTTP 200: /urds/wrd/api/aicm/v1/subject/0303200001/mandate/AB51TST405365330000 2. HTTP 400: /urds/wrd/api/aicm/v1/subject//mandate/AB51TST405365330000 3. HTTP 400: /urds/wrd/api/aicm/v1/subject/0303200001/mandate/ 4. HTTP 400: /urds/wrd/api/aicm/v1/subject//mandate/ I use the "Dispatch Strategy: Script" with default response returning HTTP 404 Not Found, and the following validation script to check the path arguments and return the appropriate response: assert log log.info("Executing dispatch script...") assert requestContext def props = requestContext.getProperties() assert props log.info("Request arguments: ${props}") def subNr = props["subject_nr"] def credId = props["creditor_id"] if (subNr.empty || credId.empty) { // return HTTP 400 return "GET 400 Bad Request" } log.info("subject_nr: ${subNr}") log.info("creditor_id: ${credId}") def isSubNrMatching = subNr ==~ /^\d{10}$/ log.info("subject_nr RegEx match is: ${isSubNrMatching}") def isCredIdMatching = credId ==~ /^(ab|AB)(\d{2})([a-zA-Z]{3})(\d{8})(0{4})$/ log.info("creditor_id RegEx match is: ${isCredIdMatching}") def areReqArgsValidated = isSubNrMatching && isCredIdMatching if (!areReqArgsValidated) { // return HTTP 400 return "GET 400 Bad Request" } log.info("Request arguments validated: ${areReqArgsValidated}") // return HTTP 200 return "GET 200 OK" Now, the problem is: Main success scenario and alternative scenario a) work just fine (meaning: in both cases I get the expected response dispatched by the script). With the remaining scenarios b) and c), a response with HTTP status code 404 is dispatched instead of the scripted one (400). This response is apparently not the default 404 response I created andselected in the "Default Response" drop-down list (which features a JSON payload in the body), for its body is empty. Additionally, no log output shows up in the script (or error) log tab, showing clearly thatthe dispatch strategy script is not executed. Any clue about why is this happening? Am I missing something fundamental, due to my lack of product knowledge?Solved6.4KViews0likes16CommentsCalculate value of variable using parameter default value and an on-scree object variable value
I have a parameter (InvoiceAmount),which has a default value of 1000. I have a variable (discount),whose valueI get from an on-screen object. I need to calculate the value of Amount (which is another vaiable). I need this value to be stored and entered into the text field of another on-screen object. The calculation is simple - Amount = Invoice Amount - Discount. I am not sure how to reference parameters and variable in VBScript. I keep getting an error that it is not running the test. I also tried 'Run Code Snippet' with value as Execute(KeywordTests.MY_Test.Parameters.Invoice_Amount - KeywordTests.MY_Test.Variables.Discount_Amount). However, it just enters this string as the value into the on-screen, text field instead of the calculated value. Any help or suggestions would be greatly appreciated. Deepa.Solved3.2KViews0likes7CommentsHow to put a parameter from a JSON URL response in a REST Request
Hello, For my project I need to read a JSON response through a URL. I've managed to do so, but now I should put a particular property into the REST Request. How can I do this please? So far: //cfr. https://www.leveluplunch.com/groovy/examples/get-webpage-content-url-uri/ //https://community.smartbear.com/t5/SoapUI-Pro/How-to-Parse-a-JSON-Response-Using-Groovy-Examples/td-p/155770 import groovy.json.JsonSlurper def getConceptSchemes = "https://LinkToMyEnvironment".toURL().getText() //parse json string using JsonSlurper - basically converts it to a groovy list def parsedJson = new groovy.json.JsonSlurper().parseText(getConceptSchemes) //get data def findAGC = parsedJson.find { it.name == 'ACTIVITY_GROUP' } log.info "result for specific beID: " + findAGC This gives me the answer from the Json response. This is a first step in my TestCase. The second step is a REST Request with parameter 'beId' that I need to fetch from the response. Response: {"beId":"d4f897d05508caa12d77d732ffbc652f821c0a16c2f457277c2565f0b890f62e","name":"ACTIVITY_GROUP","reportingAuthority":"KBO","links":[{"rel":"self","href":"http://LinktomyEnvironment/d4f897d05508caa12d77d732ffbc652f821c0a16c2f457277c2565f0b890f62e{?lang}"}]}, How can I do so please? Thanks in advance AABSolved2.2KViews0likes2CommentsUse dynamic parameters for TestItem
Hey, I would like to structure my test sequence via TestItems in TestComplete. But I ran into one problem: I want to start my TestItems (TI) out of the script with dynamic/changing parameters. Is this possible? I could not figure out, how to hand over a variable to the TI. Thank you for your help.Solved1.3KViews0likes1CommentParameter values not entering Security Test
Cross-posting from https://stackoverflow.com/q/59442082/8180615 Step in question has properties like this: "firstName": "${firstName}", "lastName": "${lastName}", "displayName": "${displayName}", etc. I tested this by running the test step itself, setting the first name property to "fff". The HTTP log showed that "fff" was sent, so no problem with the test step. In my fuzzing scan, I selected all of the properties I want to "fuzz": I was expecting that each fuzzed request would replace "firstName" with a random string, but what I am seeing instead is that every request has all of the fields blank. Sun Dec 22 08:10:34 IST 2019:DEBUG:>> " "firstName": "",[\n]" Sun Dec 22 08:10:34 IST 2019:DEBUG:>> " "lastName": "",[\n]" Sun Dec 22 08:10:34 IST 2019:DEBUG:>> " "displayName": "",[\n]" How do I get the fuzzing to be applied to my properties? From the on-line documentation: The Fuzzing Scan does just as described above; it generates totally random input for the specified request parameters for a specified number of requests, hoping to provoke some kind of unexpected . By default the generated values will be between 5 and 15 characters in lenght and mutated 100 times801Views0likes2Comments