Commit Graph

67 Commits (9c8a1390ff71ad5f31a9faf93d0f04fc798e3e90)

Author SHA1 Message Date
Roberto Hueso Gómez d1fc76c6b4 #942 Add REST API /schedule get function 2020-06-02 12:32:36 +02:00
OpenGnSys Support Team 83b242ce58 #942 Add support for scheduled tasks and commands
This field needs to be at least 31 bits long to store all days in a month.
Other fields are also set to 32 bits because unsigned int length can change
depending on the system.

We also need to support the three ways that the ogAdmAgent and the WebConsole
have to create an schedule. At first, we only supported the easiest
method:
	* Hour, day, month and year -> 10:00, 28, february, 2020

This commit adds these two ways to create an schedule:
	* Hour, week day, month and year -> 10:00, Monday, february,
	  2020
	* Hour, week, month and year -> 10:00, first week, february,
	  2020
2020-06-02 12:32:36 +02:00
OpenGnSys Support Team 96b9bb865c #942 Add /run/task to API REST
This patch adds a new command to the REST API to run tasks.

A task (tarea) is composed of procedures (procedimientos), each procedure is
composed of commands (acciones) that are represented through legacy sockHidra
parameters in the database.

This results in iterating over the task (tareas_acciones) table in the
database to fetch the list of procedures (procedimientos).

Then, this iterates over the list commands that compose a procedures
represented through procedimientos_acciones table.

Finally, this builds and sends the sockHidra legacy message for the client.

This patch includes an implementation of the Linux linked list.
2020-06-02 12:32:36 +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 2f7e9da5ab #915 Add POST "run/schedule" command to REST API in ogAdmServer
This patch implements the command "run/schedule" that kicks in pending commands
execution.

Request:

    POST /run/schedule
    {
        "clients": ["192.168.56.11"]
    }

Reply:
    200 OK

This patch also adds a simple test to cover correction of the command.
2019-10-25 14:12:09 +02:00
Javier Sánchez Parra 90672e4a25 #915 Add test for POST /image/restore/incremental command
This test covers correction of the command.
2019-10-11 11:57:08 +02:00
Roberto Hueso Gómez 45f414e32c #915 Add test for POST "image/create/incremental" command
This test covers correction of the command.
2019-10-11 11:57:08 +02:00
Javier Sánchez Parra 17eeac1284 #915 Add test for POST /image/restore/basic command
This test covers correction of the command.
2019-10-09 15:27:59 +02:00
Javier Sánchez Parra 74061887ee #915 Add test for POST /image/create/basic command
This test covers correction of the command.
2019-10-08 14:01:14 +02:00
Roberto Hueso Gómez ad4d4bdbbe Add test for POST /image/create command
This test covers correction of the command.
2019-10-07 11:15:28 +02:00
OpenGnSys Support Team e5cfdd6406 #915: adapt test to use id and profile fields
Update restore_image.json to use id and profile fields.
2019-10-01 12:59:50 +02:00
Roberto Hueso Gómez 1dde02e1ab #915: Add POST /image/restore command to REST API in ogAdmServer
This patch implements the command "image/create" that creates an image
in a client.

	Request:
		POST /image/restore
		{ "clients" : [ "192.168.56.11" ], "disk" : "1", "partition" : "1", "name" : "test", "repository" : "192.168.56.10", "type" : "UNICAST", "filesystem": "1", "image_id": "1"}
	Reply:
		200 OK
2019-10-01 12:56:10 +02:00
Roberto Hueso Gómez 1a8ada191f #915: Add POST /image/create command to REST API in ogAdmServer
This patch implements the command "image/create" that creates an image
in a client.

    Request:
            POST /image/create
	    { "clients" : [ "192.168.2.1" ], "disk" : "1", "partition" : "1", "code" : "1", "id" : "1", "name" : "test", "repository" : "192.168.2.2" }
    Reply:
            200 OK
2019-10-01 12:56:10 +02: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 882fec820e #915 check ogAdmServer binary existence when running pythong tests
Currently, if you try to run the python test without the ogAdmServer
binary, it will throw an exception.

This patch adds a check to ensure the existence of the ogAdmServer binary
at the beginning of the script.

 # python3 run-tests.py
 You need to build the ogAdmServer binary to run these tests :-)
2019-08-28 17:54:57 +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
Javier Sánchez Parra 9c7954b4cc #915 adds test for POST /software REST API
This test covers two two scenarios:

1. Correct usage.
2. Incorrect usage, use this command with GET (this returns http 405).
2019-07-15 09:51:22 +02:00
Javier Sánchez Parra 022774b255 #915 adds test for POST /hardware REST API
This test covers two two scenarios:

1. Correct usage.
2. Incorrect usage, use this command with GET (this returns http 405).
2019-07-15 09:51:03 +02:00
Javier Sánchez Parra e46b09ba2c #915 adds test for POST /refresh REST API
This test covers two two scenarios:

1. Correct usage.
2. Incorrect usage, use this command with GET (this returns http 405).
2019-07-15 09:50:43 +02:00
Javier Sánchez Parra 84c4544f61 #915 adds test for POST /stop REST API
This test covers two two scenarios:

1. Correct usage.
2. Incorrect usage, use this command with GET (this returns http 405).
2019-07-15 09:50:21 +02:00
Javier Sánchez Parra 5ea87f3c92 #915 adds test for POST /reboot REST API
This test covers two two scenarios:

1. Correct usage.
2. Incorrect usage, use this command with GET (this returns http 405).
2019-07-15 09:49:51 +02:00
Javier Sánchez Parra a914462bbf #915 adds test for POST /poweroff REST API
This test covers two two scenarios:

1. Correct usage.
2. Incorrect usage, use this command with GET (this returns http 405).
2019-07-15 09:49:04 +02:00
Javier Sánchez Parra a887c7b4c8 #915 tests correct command, /session
This should test /shell/run instead of /session
2019-07-15 09:47:38 +02:00
Javier Sánchez Parra 880cc90c14 #915 Improve test output using unittest discover
* Call the tests with python module unittest. In particular, the
  discover function.

* Rename tests files to meet the default requirements of discover
  function.
2019-07-05 17:41:26 +02:00
OpenGnSys Support Team b4a9fddf30 #915 add POST software command to REST API in ogAdmServer
This patch implements the command "software" that fetches the software
configuration from the clients.

Request:
        POST /software
        {"clients" : [ "192.168.2.1", "192.168.2.2" ]}
Reply:
        200 OK

This allows to refresh the software inventory from clients.
2019-07-03 02:56:07 +02:00
OpenGnSys Support Team 6b30dbc65c #915 add POST hardware command to REST API in ogAdmServer
This patch implements the command "hardware" that fetches the hardware
configuration from the clients.

Request:
	POST /hardware
        {"clients" : [ "192.168.2.1", "192.168.2.2" ]}
Reply:
        200 OK

This allows to refresh the hardware inventory from clients.
2019-07-03 02:56:07 +02:00
Javier Sánchez Parra eae2385f67 #915 Add API token to tests in ogAdmServer/tests/units/*
Add token parameter in REST API test infrastructure.
2019-06-24 13:50:43 +02:00
OpenGnSys Support Team fd305405b7 #915 add support for HTTP Authorization
Add APITOKEN= field to ogAdmServer.cfg to specify the REST API key.
2019-06-24 13:42:25 +02:00
Javier Sánchez Parra e45455ec82 #915 Remove unnecessary return in ogAdmServer/tests/run-tests.py
No need to explicit return call, remove it.
2019-06-12 11:02:47 +02:00