EvoMaster icon indicating copy to clipboard operation
EvoMaster copied to clipboard

',' or ']' expected, got 'Admin', JSON standard does not allow such tokens, ',' or ']' expected, got 'Admin'

Open naveensabavath opened this issue 10 months ago • 1 comments

hi @arcuri82 Please Reply ASAP

  • The API is returning responses with the Content-Type: " application / problem+json " instead of the expected " application/json ", causing schema validation failures in OpenAPI tests.

  • The JSON response body contains syntax errors (e.g., missing commas, incorrect brackets, or invalid characters).
    
  • Also, It is generating more test cases in Evomaster_faults_Test but nothing in Evomaster_successes_Test ( Sometimes only 2 Test cases Generates )

@Test @Timeout(60) public void test_216() throws Exception {

    // Fault200. Received A Response From API That Is Not Valid According To Its Schema. POST:/v1.0/login -> Response Content-Type header 'application/problem+json' does not match any allowed types. Must be one of: [application/json].
    given().accept("*/*")
            .header("Authorization", "Bearer eyJhxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") // BearerAuth
            .header("x-EMextraHeader123", "42")
            .contentType("application/json")
            .body(" {\"productId\":\"lHH\", \"requestType\":\"EVOMASTER\", \"provider\":\"GOOGLE\", \"totp\":\"_EM_2079_XYZ_\", \"organisationId\":\"q3lnU\", \"platformDetails\":{ " + 
                " \"_EM_2080_XYZ_\":[\"_EM_2081_XYZ_\", \"_EM_2082_XYZ_\", \"_EM_2083_XYZ_\"] " + 
                " , " + 
                " \"_EM_2084_XYZ_\":[\"_EM_2085_XYZ_\"] " + 
                " , " + 
                " \"5\":[\"G4G5EGDvQtyXRQj5\", \"{\"664afc3ca589ffa4e7eeda5db\":[\"AP\"]}\"] " +    "  GETTING  SYNTAX ERROR  HERE  "
                " }, \"systemLogin\":false} ")
            .post(baseUrlOfSut + "/v1.0/login?" + 
                "EMextraParam123=_EM_142_XYZ_&" + 
                "mask=_EM_2087_XYZ_")
            .then()
            .statusCode(400)
            .assertThat()
            .contentType("application/problem+json")    //   "   WHY AM IT IS WRITTING PROBLEM + JSON  "
            .body("'type'", containsString("about:blank"))
            .body("'title'", containsString("Bad Request"))
            .body("'status'", numberMatches(400.0))
            .body("'detail'", containsString("Failed to read request"))
            .body("'instance'", containsString("/v1.0/login"))
            .body("'properties'", nullValue());
}

naveensabavath avatar Feb 13 '25 04:02 naveensabavath

Hi, EM is correct here. The API is providing a response that is not valid according to its defining OpenAPI schema. You get the error message: Response Content-Type header 'application/problem+json' does not match any allowed types. Must be one of: [application/json].

application/problem+json and application/json are not the same. As a schema fault is detected, the test is put under Evomaster_faults_Test and not under Evomaster_successes_Test

arcuri82 avatar Feb 13 '25 12:02 arcuri82