SeUniVr / RestTestGen

A framework for automated black-box testing of RESTful APIs.
Apache License 2.0
38 stars 9 forks source link

Can explain how to configure rtg_config.json? #1

Closed jiaxian-lin closed 2 years ago

jiaxian-lin commented 2 years ago

I don't know how to configure the value of “authCommand” and the default value gives an error on execution. image

10:34:15.508 [main] ERROR io.resttestgen.core.cli.App - Error while creating the environment
java.io.IOException: Cannot run program "echo": CreateProcess error=2, ϵͳ�Ҳ���ָ�����ļ���
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
    at java.base/java.lang.Runtime.exec(Runtime.java:592)
    at java.base/java.lang.Runtime.exec(Runtime.java:416)
    at java.base/java.lang.Runtime.exec(Runtime.java:313)
    at io.resttestgen.core.Environment.setUp(Environment.java:73)
    at io.resttestgen.core.cli.App.main(App.java:53)
Caused by: java.io.IOException: CreateProcess error=2, ϵͳ�Ҳ���ָ�����ļ���
Caused by: java.io.IOException: CreateProcess error=2, ϵͳ�Ҳ���ָ�����ļ���

    at java.base/java.lang.ProcessImpl.create(Native Method)
    at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:487)
    at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:154)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
    ... 6 more

Execution failed for task ':App.main()'.
> Process 'command 'C:/Users/42511/.jdks/corretto-11.0.14.1/bin/java.exe'' finished with non-zero exit value -1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
davidecorradini commented 2 years ago

Hello, the value of authCommand should be a bash command whose output is a JSON array containing a list of authentication tokens.

The command echo <SOMETHING> is used to output a custom string, and it is useful in this case to provide static token(s). More complex commands can be used, such as python scripts that retrieve token(s) by authenticating with the REST API.

The output format of the command should be similar to the following:

[
  {
    "name": "Authorization",
    "value": "Bearer: <TOKEN>",
    "in": "header",
    "timeout": 300
  }
]

In this case, we tell RestTestGen that it must add a parameter with name Authorization and value Bearer: <TOKEN> in the header of each request. We also tell the tool that the script should be re-executed every 300 seconds in order to refresh the token.

In your particular case, it seems that RestTestGen could not run the command echo. I am not sure if this is a problem of your machine, or if it is a problem of RestTestGen on Windows. In fact, at the moment, we only tested our tool on Linux. While we further investigate the problem, I would suggest running RestTestGen on Linux.

jiaxian-lin commented 2 years ago

thx for your reply! But when I run RestTestGen in ubuntu, I got this ERROR, I don't know why and this open API file is converted by Swagger Editor image

this is a part of my API file:

/projects/{id}/fork:
  post:
      tags:
        - projects-api
      parameters:
        - name: id
          schema:
            type: integer
          required: true
          in: path
          description: The ID or URL-encoded path of the project.
        - name: path
          schema:
            type: string
          in: query
          required: true
        - name: name
          schema:
            type: string
          in: query
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: The name assigned to the resultant project after forking.
                namespace_id:
                  type: integer
                  description: The ID of the namespace that the project is forked to.
                namespace_path:
                  type: string
                  description: The path of the namespace that the project is forked to.
                namespace:
                  oneOf:
                    - type: integer
                    - type: string
                  description:
                    (Deprecated) The ID or path of the namespace that the
                    project is forked to.
                path:
                  type: string
                  description: The path assigned to the resultant project after forking.
      responses:
        '200':
          description: success
jiaxian-lin commented 2 years ago

Can you tell me how to fix this @davidecorradini

davidecorradini commented 2 years ago

Can you tell me how to fix this @davidecorradini

I replied on the other issue. Davide