Commit Graph

44 Commits (74061887ee64f5f04c444be1341f83568bb8319e)

Author SHA1 Message Date
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
Javier Sánchez Parra b35438d27e #915 add test for POST /session REST API 2019-05-31 11:39:43 +02:00
Javier Sánchez Parra 496f5ebb49 #915 add test for POST /shell/output REST API 2019-05-31 11:39:29 +02:00
Javier Sánchez Parra 5312e73c91 #915 add test for POST /shell/run REST API 2019-05-31 11:39:06 +02:00
Javier Sánchez Parra 556aa6b858 #915 add test for POST /wol REST API 2019-05-31 11:39:01 +02:00
Javier Sánchez Parra c39b1f324e #915 add test for POST /clients REST API 2019-05-31 11:38:57 +02:00
Javier Sánchez Parra 1af2f4b55e #915 add test for GET /clients REST API 2019-05-31 11:38:52 +02:00
Javier Sánchez Parra 727a109f7d #915 add unit test infrastructure for REST API
This python script creates a database and starts ogAdmServer to run the
tests.  This requires root to be launched:

	# ./run-tests.py

From the 'tests' folder.
2019-05-31 11:35:42 +02:00
OpenGnSys Support Team 17f55b41c3 #915 add POST refresh command to REST API in ogAdmServer
Forces client to fetch and run any pending command from the server,
reload its local configuration file and re-start its selection menu.

curl -X POST http://127.0.0.1:8888/refresh -d @refresh.json

    Request
            POST /refresh
            {"clients": [ "192.168.2.1" ] }
    Reply:
            200 OK
2019-05-30 15:32:24 +02:00
OpenGnSys Support Team 1e6c889256 #915 add POST stop command to REST API in ogAdmServer
Stop the menu selection on client (through POST method):

curl -X POST http://127.0.0.1:8888/stop -d @stop.json

Request
	POST /stop
	{"clients": [ "192.168.2.1" ] }
Reply:
	200 OK
2019-05-30 15:32:22 +02:00
OpenGnSys Support Team 5f0191d73f #915 add POST reboot command to REST API in ogAdmServer
Reboot a client (through POST method):

        curl -X POST http://127.0.0.1:8888/reboot -d @reboot.json

Request
        POST /reboot
        {"clients": [ "192.168.2.1" ] }
Reply:
        200 OK
2019-05-30 15:32:18 +02:00
OpenGnSys Support Team 23fed47639 #915 add POST poweroff command to REST API in ogAdmServer
Power off a client (through POST method):

        curl -X POST http://127.0.0.1:8888/poweroff -d @poweroff.json

Request
        POST /poweroff
        {"clients": [ "192.168.2.1" ] }
Reply:
        200 OK
2019-05-30 15:32:01 +02:00
OpenGnSys Support Team 7ab5f0cbfb #915 add POST session command to REST API in ogAdmServer
Start a session on client (through POST method):

        curl -X POST http://127.0.0.1:8888/session -d @session.json

Request
        POST /session
        {"clients": [ "192.168.2.1" ] }
Reply:
        200 OK
2019-05-27 13:03:05 +02:00
OpenGnSys Support Team c6020f2ad1 #915 add POST shell/output command to REST API in ogAdmServer
Fetching result from run command on client (through GET method):

        curl -X POST http://127.0.0.1:8888/shell/output -d @post_shell_output.json

Request
        POST /shell/output
        {"clients": [ "192.168.2.1" ] }
Reply:
        200 OK
	{"clients": [ { "addr" : "192.168.2.1", "output" : "..." } ] }
2019-05-27 13:03:00 +02:00
OpenGnSys Support Team 7e4e5b5e08 #915 add run command to REST API in ogAdmServer
Run command on client (through POST method):

	curl -X POST http://127.0.0.1:8888/shell/run -d @post_run.json

Request
	POST /shell/run
	{"clients": [ "192.168.2.1", "192.168.2.2" ], "run" : "ls" }
Reply:
	200 OK
2019-05-27 13:02:57 +02:00
OpenGnSys Support Team 5797e0b199 #915 add wol command to REST API in ogAdmServer
Send Wake-On-Lan to clients (through POST method):

Request:
	curl -X POST http://127.0.0.1:8888/wol
	{ "type" : "unicast", "clients" : [ { "addr" : "192.168.2.1", "mac" : "00AABBCCDD01" } ] }
Reply:
	200 OK
2019-05-27 13:02:52 +02:00
OpenGnSys Support Team 7b6fcdbc62 #915 add clients command to REST API in ogAdmServer
Request for existing clients:

	curl -X GET http://127.0.0.1:8888/clients

Request:
	GET /clients
Reply:
	200 OK
	{"clients": [ { "addr" : "192.168.2.1", "state" : "OPG" }, { "addr" : "192.168.2.2", "state" : "OFF" }]}
2019-05-27 13:02:45 +02:00
OpenGnSys Support Team 95e6520c4f #915 add initial REST API for ogAdmServer
Add REST API for ogAdmServer, this API is exposed through port 8888 on
the system that runs the ogAdmServer. The body of the HTTP message is
expressed in JSON format.

This patch implements the command "clients" that maps to the existing
legacy "Sondeo" command, that is used by the web interface to poll
refresh the client state.

This patch also includes an initial test infrastructure using 'curl' to
send commands to the new REST API.

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

This allows to refresh the status of the list of clients.
2019-05-27 13:02:37 +02:00