Commit Graph

65 Commits (d5e6dc0990cb22efc05dda405dfa1e49f60359f5)

Author SHA1 Message Date
Javier Sánchez Parra 1fdb7e6d1c #915 Add commands and procedures to procedure creation
Adds the possibility to create a procedure with commands and other
procedures integrated as steps.

Note: "steps" parameter is optional and "steps" array object order
defines execution order.

Request:
POST /procedure/add
{
  "center": "1",
  "name": "procedure",
  "description": "My procedure",
  "steps": [
             {
               "command": "wol",
               "params": { "type": "broadcast" }
             },
             {
               "procedure": 22
             },
             {
               "command": "poweroff",
               "params": {}
             }
           ]
}

Response:
200 OK

This commit also updates unit tests for /procedure/add POST method to
include steps.
2021-06-10 17:00:01 +02:00
Javier Sánchez Parra 41fad11408 #942 Add POST /procedure/add method
This method adds a procedure associated with a center to the database.
Required payload parameters are center and name, description is
optional.

Note: ogServer does not allow to add more than one procedure with the
same name and center.

Request:
POST /procedure/add
{
  "center": "1"
  "name": "procedure1"
  "description": "My procedure"
}

Response:
200 OK

This commit also adds unit tests for /procedure/add POST method.
2021-05-31 13:01:47 +02:00
Javier Sánchez Parra 29e7641e91 #915 Add /room/add POST method
Adds POST method to add rooms (labs), required payload parameters are
name, netmask and center; any additional attributes are optional.

Required JSON:
        { "center": 0,
          "name": "classroom10",
          "netmask": "255.255.255.0" }

Full JSON:
        { "center": 0,
          "name": "classroom11",
          "netmask": "255.255.255.0",
          "group": 0,
          "location": "First floor",
          "gateway": "192.168.56.1",
          "ntp": "hora.cica.es",
          "dns": "1.1.1.1",
          "remote": True }

This commit also adds unit tests for /room/add POST method.
2021-04-20 12:05:42 +02:00
Javier Sánchez Parra c2c6ce93b1 #915 Add large HTTP response test
This commit adds a test for HTTP responses that are too large to fit in
ogServer response buffer.

It also moves the basic sql data used for the other tests to its own
file, easing its reuse in several files.
2021-04-19 19:05:15 +02:00
Javier Sánchez Parra 8015f85b04 #915 Add GET /oglive/test REST API function
This function returns the installed and available ogLiveS in the server
to be booted from.

Request:
GET /oglive/list
NO BODY

Response
200 OK
{
  "oglive": [
    {
      "distribution": "bionic",
      "kernel": "5.4.0-40-generic",
      "architecture": "amd64",
      "revision": "r20200629",
      "directory": "ogLive-5.4.0-r20200629",
      "iso": "ogLive-bionic-5.4.0-40-generic-amd64-r20200629.85eceaf.iso"
    },
    {
      "distribution": "bionic",
      "kernel": "5.0.0-27-generic",
      "architecture": "amd64",
      "revision": "r20190830",
      "directory": "ogLive-5.0.0-r20190830",
      "iso": "ogLive-bionic-5.0.0-27-generic-amd64-r20190830.7208cc9.iso"
    }
  ],
  "default": 0
}

This commit also adds tests for GET /oglive/test.
2021-04-05 18:00:56 +02:00
Diego Crespo Quinta d9e1521a16 #1004 Add GET /images test
Fix incorrect error if json is missing.
2021-03-30 16:11:45 +02:00
Diego Crespo Quinta 1c2a0cad8b Fix GET /hardware test url 2021-03-23 01:41:33 +01:00
Javier Sánchez Parra 7caffaf56c #915 Fix big request test
ogServer now responses with "413 Payload Too Large" when the payload is
too large.
2021-02-23 11:38:06 +01:00
Javier Sánchez Parra 031e5708d3 #915 Fix test POST /wol
Commit e4cb91b changed MAC and netmask retrieving, now ogServer take these
addresses from the database instead of from the JSON.

Remove MAC and netmask from the JSON body.
2021-02-23 10:46:46 +01:00
OpenGnSys Support Team 0a09c5b09c #1022 increase maximum API REST request size
Software inventory generates a request larger that 64 Kbytes.
Rise the maximum API REST request size to 128 Kbytes.
2021-02-04 13:29:24 +01:00
Isabel Arrans 1472ff276f #915 add test POST /client/delete 2020-12-17 19:18:54 +01:00
Diego Crespo Quinta 1ed772ba80 #915 Fix GET /software test 2020-12-15 20:03:46 +01:00
Isabel Arrans 10b07ba2b9 #915 Fix test POST /client/add 2020-12-15 20:02:46 +01:00
Isabel Arrans 646355d3c7 #915 Fix GET /client/info test 2020-12-15 20:01:51 +01:00
Diego Crespo Quinta be9816eb4e #915 Add GET /software test 2020-12-12 19:32:39 +01:00
Diego Crespo Quinta ca633e62fe #915 Add GET /hardware test 2020-12-12 19:32:11 +01:00
Isabel Arrans 6386d37bf9 #915 Test for GET /client/info and POST /client/add 2020-12-11 23:16:43 +01:00
Diego Crespo Quinta a043fca7f8 #915 Add POST /mode test 2020-12-02 09:50:03 +01:00
Diego Crespo Quinta 5b42e34b59 #915 Fix POST /setup test
Add new type field to json.
2020-12-02 09:48:13 +01:00
Diego Crespo Quinta aeb53bd351 #915 Test GET /scopes
And fix ogserver, report error if GET /scopes have a JSON body.
2020-12-01 19:29:37 +01:00
Diego Crespo Quinta 727f31a88b #915 add GET /session test 2020-11-17 00:33:23 +01:00
Isabel Arrans 8bb855344c #915 test malformed body in GET /client/setup 2020-11-10 14:47:47 +01:00
Isabel Arrans 09a064c3ff #915 fix POST /hardware test 2020-10-27 17:05:01 +01:00
Isabel Arrans b11608152e #915 restore more tests 2020-10-24 12:53:11 +02:00
Diego Crespo Quinta 45711db04f #915 Fix expected returned codes in GET /session and GET /software tests
Fix incorrect status code.
2020-10-22 22:37:36 +02:00
Diego Crespo Quinta 1d451acff5 #915 Fix several test errors
Test 0006: add json to GET /session and update expected return code.
Test 0012: add json to GET /software and update expected return code (200),
in this case json fields are integer, not string.
Test 0020: remove it, /image/create/incremental does not exist anymore.
Test 0021: same as before for /image/restore/basic
Test 0022: same as before for /image/restore/incremental
Test 0023: rename to test_0020.
2020-10-22 18:58:56 +02:00
Roberto Hueso Gómez abd2b913d8 #915 Test malformed payload for POST commands
This patch includes tests for the remaining REST API commands:

	POST /shell/output
	POST /session
	POST /poweroff
	POST /reboot
	POST /stop
	POST /refresh
	POST /hardware
	POST /software
	POST /image/create
	POST /image/restore
	POST /setup
	POST /image/create/basic
	POST /image/create/incremental
	POST /image/restore/basic
	POST /image/restore/incremental
	POST /run/schedule

This test covers requests that are missing one of the parameters in its
payload.
2019-11-14 14:51:13 +01:00
Roberto Hueso Gómez 1cdbc5facf #915 Test malformed payload for POST /shell/run
This test covers requests that do not contain 1 of the parameters in their
payloads.
2019-11-13 14:16:02 +01:00
Roberto Hueso Gómez 682d3b6b17 #915 Test malformed payload for POST /wol
This test covers requests that do not contain 1 of the parameters in their
payloads.
2019-11-13 14:16:01 +01:00
Roberto Hueso Gómez 4d98bdf5f6 #915 Test malformed payload for POST /clients
This test covers requests that do not contain 1 of the parameters in their
payloads.
2019-11-13 14:15:58 +01:00
Roberto Hueso Gómez 65cc7c17e2 #915 Extend REST API POST no payload tests to all remaining tests.
This patch extends tests for requests without any payload in the following REST
API POST functions:

- /clients
- /wol
- /shell/run
- /shell/output
- /session
- /poweroff
- /reboot
- /stop
- /refresh
- /hardware
- /software
2019-11-13 14:15:56 +01:00
Roberto Hueso Gómez 6c91d147c1 #915 Rename POST /image/setup for /setup in REST API
This patch renames the setup command to avoid semantic confusion.
2019-11-13 14:15:43 +01:00
Roberto Hueso Gómez ee2e16ac96 #915 Adapt POST /shell/run test to the 'echo' parameter 2019-11-12 21:37:11 +01:00
Roberto Hueso Gómez 64b470514b #915 Fix ogAdmServer POST /software test parameters
This patch adds missing parameters to the test JSON.
2019-11-06 11:16:22 +01:00
Roberto Hueso Gómez 2bc2490d00 #915 Add test for POST /run/schedule REST API
This test covers 3 scenarios:

1. Correct usage.
2. Incorrect usage, without payload.
3. Incorrect usage, use this command with GET.
2019-10-31 13:18:48 +01:00
Roberto Hueso Gómez 1f55beb8f5 #915 Add test for POST /image/restore/incremental REST API
This test covers 3 scenarios:

1. Correct usage.
2. Incorrect usage, without payload.
3. Incorrect usage, use this command with GET.
2019-10-31 13:18:48 +01:00
Roberto Hueso Gómez 20f935bb65 #915 Add test for POST /image/restore/basic REST API
This test covers 3 scenarios:

1. Correct usage.
2. Incorrect usage, without payload.
3. Incorrect usage, use this command with GET.
2019-10-31 13:18:48 +01:00
Roberto Hueso Gómez b5722de3fb #915 Add test for POST /image/create/incremental REST API
This test covers 3 scenarios:

1. Correct usage.
2. Incorrect usage, without payload.
3. Incorrect usage, use this command with GET.
2019-10-31 13:18:48 +01:00
Roberto Hueso Gómez 713070ab10 #915 Add test for POST /image/create/basic REST API
This test covers 3 scenarios:

1. Correct usage.
2. Incorrect usage, without payload.
3. Incorrect usage, use this command with GET.
2019-10-31 13:18:48 +01:00
Roberto Hueso Gómez 1436d44cc6 #915 Add test for POST /image/setup REST API
This test covers 3 scenarios:

1. Correct usage.
2. Incorrect usage, without payload.
3. Incorrect usage, use this command with GET.
2019-10-31 13:18:48 +01:00
Roberto Hueso Gómez ba3b1ad543 #915 Add test for POST /image/restore REST API
This test covers 3 scenarios:

1. Correct usage.
2. Incorrect usage, without payload.
3. Incorrect usage, use this command with GET.
2019-10-31 13:18:48 +01:00
Roberto Hueso Gómez b4d2890460 #915 Add test for POST /image/create REST API
This test covers 3 scenarios:

1. Correct usage.
2. Incorrect usage, without payload.
3. Incorrect usage, use this command with GET.
2019-10-31 13:18:48 +01:00
Roberto Hueso Gómez c1c89e196c #915: Return 400 status code in POST methods when no payload is attached
If no payload is attached to method that requires a payload, then the API
returns a 400 status code (following RFC 7231) instead of the previous 404.

test_0001_get_clients.py is also modified to fit the new status code.
2019-09-19 16:06:03 +02:00
Roberto Hueso Gómez 55edb404b7 #915: Fix incorrect method and code in invalid GET requests
Some tests should perform GET requests however they incorrectly use POST.
Return codes for these tests have also been fixed.
2019-09-18 17:40:41 +02:00
Roberto Hueso Gómez 72b6c26a49 #915: Remove duplicated test
This test is already performed in test_0001_get_clients.py
2019-09-18 17:40:41 +02:00
Roberto Hueso Gómez 741524f59b #915: more descriptive function name in test
This test sends a POST with no body, which is illegal, use a function
name that describes this.
2019-09-18 17:40:41 +02:00
Javier Sánchez Parra 46d791ae44 #915 add test for too large HTTP request fields
This test checks for wrong headers HTTP requests:

	1. POST /clients with a content length larger than a signed int.
	2. POST /clients with an auth token larger than 63 characters.
2019-09-10 11:10:34 +02:00
Javier Sánchez Parra 784495f5d5 #915 adds test for too large HTTP request
This test checks for too large HTTP requests, for example:

	POST /clients

with a body of 4096 bytes.
2019-09-04 20:13:11 +02:00
Javier Sánchez Parra e397e7930f #915 add missing brackets to WOL API test json
Without the brackets the call works (200 response) but the ogAdmServer
does not send the WOL packets.
2019-08-28 17:53:19 +02:00
Javier Sánchez Parra 8903c6819e #915 adds tests for a non existent method
This test adds four new error test cases:

1. Non existent method with POST.
2. Non existent method with GET.
3. Non existent method with POST but with wrong API token.
4. Non existent method with POST but without json.
2019-07-15 09:53:40 +02:00