41 Commits

Author SHA1 Message Date
Markus Mäkelä
cd9a84d762 Add tests for direct relationship updating
The tests check that direct updates to the relationships endpoints work.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
7111724851 Fix REST API monitor relationship test
The test did not properly move the relationships from the old monitor to
the new one. The test to passed as the relationship modification was not
really tested.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
b7b50959ac Update REST API tests
Extended the relationship checks in the REST API tests to actually verify
that the returned objects represent what is expected.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
d371ecb30f Only remove explicitly deleted relationships
Only when a relationship is defined as a null JSON value, it should be
deleted. If it is missing, it should be ignored.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
6ee7ed6a38 MXS-1354: Add creation of basic/admin users to maxctrl
The type of the created user can now be specified with the --type option.

Expanded tests that cover the user creation. Also added a test case that
checks that basic users are only allowed to read through the REST API.
2017-08-18 10:28:21 +03:00
Markus Mäkelä
c2a2688b93 Fix duplicate listener checks
Only the protocol, port and address of the listener were used to check if
a listener exists. The check should also use the name of the listener to
be sure that each name is unique.

Expanded tests to check that the creation of duplicate listeners is
detected. Did minor improvements to related test code.
2017-08-09 11:39:25 +03:00
Markus Mäkelä
1308e7a304 Fix resource collection modification times
The resource collection modification times weren't updated when an
individual resource was updated. By tracking back the path of a resource
and updating the modification times, all nodes in the path will get the
correct modification time.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
090de1a0f7 MXS-1220: Make individual listeners resources
The listeners are now a proper sub-resource of the service resource. This
means that it acts like a normal resource and can be queried both as a
collection of resources and as an individual resource.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
67b2654f50 Move REST API test scripts into a common directory
Moved and renamed the starting and stopping scripts from the REST API
tests to a common directory. This way the MaxCtrl tests can use the same
scripts to start and stop MaxScale.

Also moved the test configuration file into the `test/` directory and
changed some of the default directory locations.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
173a97ae70 Refactor REST API test script into a npm test framework
The script can now be used to run an arbitrary set of Node.js tests as
long as they define the `test` npm target. Refactored REST API tests to
fit into this framework.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
01fa1a827a MXS-1300: Move the REST API tests back into the core
As the REST API is a part of the core, it is more appropriate for the
tests to reside there as well. Further refactoring of the testing needs to
be done to allow multiple components to use the same framework but with
different tests.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
d59d3ab638 MXS-1300: Combine REST API and MaxCtrl tests
The REST API tests are now located under the maxctrl directory. This
allows both tests to use the same framework for testing.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
731d19ba70 MXS-1220: Add test for monitor alteration regression
Altering monitor parameters without defining the relationships was
interpreted as an attempt to remove all relationships. This test
reproduces the problem.
2017-07-10 22:23:48 +03:00
Markus Mäkelä
c7b9b7ac4a MXS-1220: Unify resource member naming
All resoures now use the `state` member to describe their internal
state. This includes servers, services and monitors. This means that the
`status` keyword can be reserved for something else and it can be removed
until it is needed again.

Changed the module maturity field to `maturity` to better describe its
purpose.
2017-07-10 22:23:45 +03:00
Markus Mäkelä
a8bfdac49c MXS-1220: Use PUT to set/clear server
The correct method for set/clear endpoints is PUT, not POST, as the
resource always ends up in the desired state, regardless of its current
state.
2017-07-10 22:23:45 +03:00
Markus Mäkelä
63d2eee0e3 MXS-1220: Add endpoint for set/clear of server status
The server status can now be manipulated via the REST API. Added tests for
the state manipulation. Fixed minor issues in related code.
2017-07-10 22:23:44 +03:00
Markus Mäkelä
e4a004097e MXS-1220: Add support for PATCH
The PATCH method should now be used instead the PUT method to update
resources.  As PUT request bodies should represent complete resources, the
use of PUT to update resources is no longer supported.

Altered tests to use PATCH instead of PUT for updating resources.
2017-06-05 13:37:08 +03:00
Markus Mäkelä
6b8b19b439 MXS-1220: Add PUT support for /maxscale/ resource
The /maxscale/ resource now supports PUT requests which modify core
parameters. As not all parameters can be changed at runtime, only
modifications to parameters that support runtime configuration are
allowed.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
1067fd352c MXS-1220: Add creation and deletion of admin users
Admin users can now be created via the REST API. This allows remote
management of the administrative interface itself.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
ead9059eeb MXS-1220: Add /users/ resource
The /users/ resource shows all user accounts that can be used with
MaxScale. This resource is further split into two resource collections,
/users/inet and /users/unix, which contain the network users and Linux
accounts respectively.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
e3c4bd7f72 MXS-1220: Add more validation checks to request JSON
The requests that send a body should define at least a `data` member.

Added a simple test that checks that bad requests are rejected. This test
should be expanded to check that the returned error body contains the
correct members.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
157b7f853b MXS-1220: Fix resource self links
The top level resource self links pointed to the collection instead of the
resource itself. The individual resoures now also have a links field that
contains the self link to the resource. This should make navigation of the
API easier as all objects have valid links in them.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
778631a860 MXS-1220: Add support for conditional HTTP requests
The REST API now supports the If-Modified-Since, If-Unmodified-Since,
If-Match and If-None-Match headers and returns the correct response if the
conditional fails.

Added tests for the date parsing and expanded the HTTP header tests in the
REST API test suite.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
3deb497394 MXS-1220: Add Last-Modified and ETag headers
The resource system now tracks both the time when a resource was last
modified and the revision number of the resource. This allows working
Last-Modified and ETag headers to be generated by the REST API.

The If-Modified-Since and If-None-Match request headers are not yet
processed and using them will always return the resource instead of a 304
Not Modified response.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
461cd6afd9 MXS-1220: Add creation of listeners via REST API
Listeners can now be created via the REST API by doing a POST request to
the service listener resource.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
e3ff3b56bc MXS-1220: Add test for /maxscale/logs/ endpoint
The test alters logging options and flushes the logs.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
efc5461daa MXS-1220: Return 204 No Content for PUT and POST request
Returning 204 No Content removes the cost of always sending back the
modified resource. If the modified resource is required, a GET request
should be made to retrieve it.

Updated tests to account for this change.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
d4212b9c78 MXS-1220: Add request option test
Currently only the `pretty=true` option is supported but it is also
tested.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
16e597d43e MXS-1220: Expand REST API test suite
Added tests for services and extended the monitor test suite to test
actions on monitors.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
08dca8c273 MXS-1220: Treat service listeners as service sub-resources
The listeners under the /services/:service/listeners collection are now
fully JSON API compliant resources.

The listeners could also be exposed as a /listeners collection to easily
group all listener type resources in one place. This approach does has
some semantical and practical problems, namely the fact that each listener
has a many-to-one relationship with its service and listeners by
themselves can't exist alone.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
1d98b4b67b MXS-1220: Return 403 Forbidden for invalid requests
The JSON API specification suggests that the API returns the 403 Forbidden
error when the user does an invalid request. The 400 Bad Request isn't the
ideal error for cases where the syntax is correct but the action being
performed is wrong.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
798ee840a8 MXS-1220: Make /maxscale/ resource conform to JSON API
The /maxscale/ resource now conforms to the JSON API and a test checks
that it the returned JSON is valid.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
7ce20b75d7 MXS-1220: Extend and fix REST API tests
Fixed a few broken tests and extended the monitor tests.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
c1968aac2f MXS-1220: Migrate create/update monitor to JSON API format
The creation and modification of moitor now supports the JSON API
conforming format generated by the GET endpoints.

Also added tests for creating and altering monitors via the REST API.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
9495438f2b MXS-1220: Add server test
The test creates, alters and destroys servers.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
a3c683ab87 MXS-1220: Simplify test creation
The tests now automatically start MaxScale before each test block and stop
it and perform cleanup after the test. This is done by simply calling the
`before.sh` and `after.sh` scripts before each test block.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
6b0fabf834 MXS-1220: Make REST API locally testable
The `test_rest_api` make target creates a discardable installation of
MaxScale which is used to launch a local instance of MaxScale. This local
instance is then used to test the REST API.

This is definitely not an efficient way to test the MaxScale but it allows
local testing without virtual machines or containers.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
432a6d6f28 MXS-1220: Reorganize filter resource
The filter resource now conforms to the JSON API schema. Added a test case
for the individual filter resource.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
b9a5d91fe6 MXS-1220: Reorganize monitor resource
The monitor resource now conforms to the JSON API schema. Added a test
case for the individual monitor resource.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
fb7f283316 MXS-1220: Reorganize service resource
The service resource now conforms to the JSON API schema. Added a test
case for individual resources and resource collections.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
5ae9ff9663 MXS-1220: Add simple REST API validator
The validator uses Node.js to check that the REST API endpoints conform to
the specified schema.
2017-05-09 15:32:41 +03:00