@@ -14,10 +14,10 @@ If you plan on contributing, please follow these basic requirements
1414
1515Testing
1616-------
17- It is preferred that any API endpoints or core features of this package include unit tests at the time they are written.
17+ It is preferred that any API endpoints or core features of this package include E2E tests at the time they are written.
1818This will help speed up pull requests, and assist in future regression testing. For example, if you write a new API
19- endpoint please include a unit test that will thoroughly test the extent of that endpoint. Python3 is the preferred
20- language for unit tests. Seeing as changes will primarily be to API endpoints, please consider Python3's ` requests `
19+ endpoint please include a E2E test that will thoroughly test the extent of that endpoint. Python3 is the preferred
20+ language for E2E tests. Seeing as changes will primarily be to API endpoints, please consider Python3's ` requests `
2121module.
2222
2323Proposing Changes
@@ -92,6 +92,13 @@ utilizes the same permissions as the pfSense webConfigurator. Specify the privil
9292format. Defaults to ` ["page-all"] ` which requires client to have the 'WebCfg - All Pages' permission. A list of pfSense
9393privileges can be found here: https://github.com/pfsense/pfsense/blob/master/src/etc/inc/priv.defs.inc
9494
95+ - ` $this->packages ` : Allows you to specify any add-on packages required for the model to operate. This must use the
96+ full pfSense package name (including ` pfSense-pkg- ` ). All packages must be present on the system in order for the API
97+ model to operate. If any packages are missing, the API will return a 500 error. Defaults to ` [] ` .
98+
99+ - ` $this->package_includes ` : Allows you to specify additional PHP files to include for add-on packages. These files
100+ will only attempt to be included if ALL packages specified in ` $this->packages ` are present. Defaults to ` [] ` .
101+
95102- ` $this->requires_auth ` : Specify whether authentication and authorization is required for the API model. If set to
96103` false ` clients will not have to authenticate or have privilege to access. Defaults to ` true ` .
97104
@@ -360,26 +367,26 @@ Often times you will need to create functions to condense redundant tasks. You c
360367` $some_variable = APITools\your_custom_tool_function(); `
361368
362369
363- ## Writing API Unit Tests ##
364- Unit tests are written using Python3. pfSense API includes a an unit_test_framework module in the ` tests ` directory to make
365- this process simple. Unit tests help to ensure each endpoint remains functional when changes have been made.
370+ ## Writing API E2E Tests ##
371+ E2E tests are written using Python3. pfSense API includes a an e2e_test_framework module in the ` tests ` directory to make
372+ this process simple. E2E tests help to ensure each endpoint remains functional when changes have been made.
366373
367374#### Getting Started ####
368- To get started creating a new API unit test, you first need to create a new Python3 file in ` /tests ` . This file must
375+ To get started creating a new API E2E test, you first need to create a new Python3 file in ` /tests ` . This file must
369376start with ` test ` and end with ` .py ` to be included in the ` run_all_tests.py ` script. Once you have created this file,
370- you must create a new class that extends our APIUnitTest framework class:
377+ you must create a new class that extends our APIE2ETest framework class:
371378
372379``` python
373- import unit_test_framework
380+ import e2e_test_framework
374381
375- class NewAPIUnitTest ( unit_test_framework . APIUnitTest ):
382+ class NewAPIE2ETest ( e2e_test_framework . APIE2ETest ):
376383 # ...
377384```
378385
379386#### Overriding Base Model Properties ####
380- The APIUnitTest class requires you to override a some properties to function correctly:
387+ The APIE2ETest class requires you to override a some properties to function correctly:
381388
382- - ` url ` : A string specifying the URL this unit test will be testing
389+ - ` url ` : A string specifying the URL this E2E test will be testing
383390- ` time_delay ` : An integer specifying how many seconds should be waited between requests. Defaults to ` 1 ` .
384391- ` get_tests ` : A list of dictionary formatted test parameters for GET requests. If this endpoint does not support
385392GET requests, you do not need to override this property. If this endpoint does support GET request, but does not require
@@ -438,7 +445,7 @@ included.
438445included.
439446
440447#### Other Base Model Properties
441- The APIUnitTest class also contains a few properties that are not intended to be overridden:
448+ The APIE2ETest class also contains a few properties that are not intended to be overridden:
442449
443450- ` uid ` : a unique ID that can be used for payload fields that required a unique value
444451
@@ -456,14 +463,14 @@ overridden:
456463- ` pre_delete() ` : Runs before the DELETE request is made.
457464- ` post_delete() ` : Runs after the DELETE request is made.
458465
459- #### Running Unit Tests ####
460- Once you have written your unit test class, you must ensure you create the unit test object at the end of the file
466+ #### Running E2E Tests ####
467+ Once you have written your E2E test class, you must ensure you create the E2E test object at the end of the file
461468you've created like so:
462469
463470``` python
464- import unit_test_framework
471+ import e2e_test_framework
465472
466- class NewAPIUnitTest ( unit_test_framework . APIUnitTest ):
473+ class NewAPIE2ETest ( e2e_test_framework . APIE2ETest ):
467474 url = " /api/v1/your_endpoint"
468475 get_requests = [{}]
469476 post_requests = [
@@ -512,16 +519,16 @@ class NewAPIUnitTest(unit_test_framework.APIUnitTest):
512519 },
513520 ]
514521
515- NewAPIUnitTest ()
522+ NewAPIE2ETest ()
516523```
517524
518- Once this is done, you can run the unit test via command line by running:<br >
519- ` python3 test/test_your_unit_test_framework .py --host <ENTER PFSENSE IP/HOSTNAME HERE> `
525+ Once this is done, you can run the E2E test via command line by running:<br >
526+ ` python3 test/test_your_e2e_test_framework .py --host <ENTER PFSENSE IP/HOSTNAME HERE> `
520527
521- Or you may run all the unit tests by running:<br >
528+ Or you may run all the E2E tests by running:<br >
522529` python3 test/run_all_tests.py `
523530
524- Unit tests will check API responses for the following:
531+ E2E tests will check API responses for the following:
525532- Ability to connect to API endpoint
526533- API responses properly return data in a JSON format
527534- API responses include the correct HTTP status code
@@ -536,12 +543,10 @@ directories needed to build our package from the `files` directory. For more inf
536543to ` tools/README.md `
537544
538545## Creating or Updating Documentation ##
539- Documentation is written and maintained using Postman. The JSON export of the Postman collection can be found in
540- ` tools/templates/documentation.json ` . Both the README.md and embedded documentation are generated using this JSON file. To update
541- or add documentation, you can either import this collection to Postman, make your changes in Postman and then export the
542- updated collection as JSON, or you may edit the JSON file directly if you are familiar with the structure. To generate
543- the README.md and embedded documentation pages, you may use the ` tools/make_documentation.py ` script. For more info on
544- running the script, refer to ` tools/README.md `
546+ Documentation is written using Swagger/OpenAPIv3. The OpenAPI configuration can be found at
547+ ` pfSense-pkg-API/files/usr/local/www/api/documentation/openapi.yml ` . Whenever new functionality is added or updated,
548+ the OpenAPI configuration must also be updated to reflect the changes. The OpenAPI configuration
549+ must be in OpenAPIv3 spec at all times.
545550
546551Questions
547552---------
0 commit comments