HubNext
Help
Help Development

Development: sites and request testing

A mode for development teams: send a request to a test server right from a task, see the response and put the result into a comment with one click. Every request is stored in a log.

Where to find it

The system administrator turns the mode on (System modules → Development). After that a Development item appears in the menu under "Tasks and to-dos": Sites (head and above) and Request log (manager and above). The Test button is in every task card for everyone with the User role or higher.

Sites

A site is an address HubNext is allowed to send requests to. Any other address cannot be used. Sites are added by a head.

  1. Click Add site.
  2. Fill in Name, Environment, Scheme, IP or domain and, if needed, Port and Base path (for example /api/v1).
  3. In Common headers you can set a token: Authorization: Bearer .... Headers are stored encrypted and are not shown after saving.
  4. If you need SQL requests, fill in the Database block: Driver, if needed DB host and DB port, Database, User and Password. The password is stored encrypted and is not shown after saving. Create a read-only account for HubNext.
  5. Click Save.

The screen shows our server IP: allow it on your side, otherwise your server may reject the requests.

Sending to a site with the prod environment is blocked. Requests go to dev and stage only. Internal addresses (127.0.0.1, 10.x, 192.168.x networks and the like) are blocked too.

Request library

The Request library holds requests the whole organization uses: method, path, headers, body, expected code and a default site. Anyone with the User role or higher can view and use them; managers and above create, edit and delete them (the Add request button).

  • You can use variables in the path, headers and body: {{task_code}} (the task the request is run from), {{site.host}}, {{site.title}}, {{date}} (today's date). They are substituted on send.
  • Secret headers (Authorization, Cookie, X-Api-Key and similar) cannot be set in a request: tokens live in the common headers of the site. Do not put passwords or tokens into the request body either: the library is open to the whole organization.
  • Every request shows the result of its last run, and a manager sees a link to the log for that request.
  • You can check a request right in the library: the Run button (the triangle in the row) opens a window where you pick the Site (the request's site by default) and shows the response code, headers and body (a table of rows for SQL). The run is written to the log like a normal send. For SQL only sites with a configured database are listed.

Collections

On the Collections tab of the library, requests are grouped into a set that runs in one go. Managers and above create and edit collections (the Add collection button); anyone with the User role or higher can run them and see the history.

  1. Click Add collection, enter the Name and, if needed, a Default site.
  2. Add steps with Add step (up to 20, the same request can be added several times) and arrange them with the arrows.
  3. Choose whether to stop if a step does not pass: the remaining steps are then skipped and not sent.
  4. In the Run a collection block choose the collection, the Site and optionally enter a Task (code), then click Run. The run goes to one site chosen at run time; prod sites are blocked.

The result shows the outcome (Passed, Failed or Error), the counters and a table of steps with the response code, time and reason (for example "skipped: a previous step did not pass"). If the run is linked to a task, an Add the result to the task button appears: the comment contains a summary and the list of steps without response bodies. You can also run a collection from the Test window in a task card.

Every step is a normal request: the same checks and log entry. Run history keeps the latest runs of a collection, and a manager sees a link to the log for them. If a request is deleted from the library it disappears from the collections too. A whole run is limited to 100 seconds: when the time is up the remaining steps are skipped.

SQL requests

If a site has a database configured, the Test window gets an HTTP / SQL switch, and the request library can store requests of the SQL type. SQL runs read-only.

  • One SELECT statement is allowed. INSERT, UPDATE, DELETE, DROP, several statements separated by ;, SELECT ... INTO, FOR UPDATE and functions such as sleep or locks are rejected. In addition the session is opened in read-only mode, so nothing can be written to the database even by an account with write permissions.
  • The result is at most 100 rows (a note under the table says when there are more) and a request is limited to 10 seconds. Values of columns named password, token, secret, api_key and similar are replaced with *** everywhere: in the window, in the comment and in the log.
  • Free-form SQL is entered by managers and above. A user can run a library request but cannot change its text.
  • Add to task puts the request and the first result rows into a comment. Run is not possible on a prod site.
  • SQL can be added to a collection as a step together with HTTP requests: such a step runs on the database of the same site. In a collection an SQL step passes if the request ran; the log shows its row count.
  • MySQL and MariaDB are supported now. The PostgreSQL option appears once the pdo_pgsql extension is installed on the server.

Testing a request from a task

  1. In the task card click Test.
  2. If needed, pick a request in From the library: the site, method, path, headers, body and expected code are filled in. Choose the Site and Method, enter the Path (after the base path) and, if needed, headers and a request body. In Expected response code you can say which code counts as success; by default any 2xx code does.
  3. Click Send. You will see the result (Passed, Failed or Error), the response code, time, headers and body.
  4. Click Add to task, check the text and click Add comment. The comment contains the site, the request, the result and the response body.

Everyone who sees the task will see the comment. In the log and in the comment passwords and tokens are replaced with ***. The history of requests for this task is shown at the bottom of the window. A manager can save the typed request to the library with the To the library button.

Limits: up to 60 requests per minute per person, request body up to 256 KB, response up to 1 MB, 20 seconds timeout, redirects are not followed.

Request log

The Request log shows all requests of the organization: time, who sent it, site, request, response code and result. You can filter by task, site and result; Details opens the request and response headers and bodies.

The log is not cleaned automatically: entries are only added. Bodies longer than 64 KB are truncated in the log.

See also