Skip to content

Support for custom scalars in graphql black-box testing #1180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jberryman opened this issue Feb 25, 2025 · 1 comment
Open

Support for custom scalars in graphql black-box testing #1180

jberryman opened this issue Feb 25, 2025 · 1 comment

Comments

@jberryman
Copy link

Context

EvoMaster version: 3.4.0
Running with /opt/evomaster/bin/evomaster --blackBox true --maxTime 600s --ratePerMinute 60 --problemType GRAPHQL --bbTargetUrl http://localhost:3000/graphql

Issue

Our graphql API under test uses some custom scalars (e.g. int4), and it seems when these are in input position evomaster will use random strings (understandable), but then will generate a test case when we return the expected error. For example:

    @timeout_decorator.timeout(60)
    def test_2(self):
        
        headers = {}
        headers["content-type"] = "application/json"
        body = " { " + \
            " \"query\": \"  { EmployeeByID  (EmployeeId : \\\"QErAaRNm\\\")  {Address,Email,LastName,ReportsTo,Title}       } \" " + \
            " } "
        headers['Accept'] = "application/json"
        res_0 = requests \
                .post(self.baseUrlOfSut,
                    headers=headers, data=body)
        
        assert res_0.status_code == 200
        assert "application/json" in res_0.headers["content-type"]
        assert res_0.json()["data"]["EmployeeByID"] is None
        assert len(res_0.json()["errors"]) == 1
        assert res_0.json()["errors"][0]["message"] == "error from data source: error returned from database: invalid input syntax for type integer: \"QErAaRNm\""
        assert len(res_0.json()["errors"][0]["path"]) == 1
        assert res_0.json()["errors"][0]["path"][0] == "EmployeeByID"
        assert res_0.json()["errors"][0]["extensions"]["details"] is None

where in the schema we have EmployeeId int4!

So my issues/questions are:

  • is there some way to give evomaster hints about custom scalars we use?
  • the test case seems erroneous afaict as I mentioned; I probably need to read into what are the heuristics in use by evomaster
@arcuri82
Copy link
Collaborator

Hi @jberryman ,

thanks for reporting this. Currently, we have no support for custom scalar :( although it is something we should add in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants