config/sysinv/sysinv/sysinv/sysinv/tests/api
Joao Victor Portal 9aee309999 Deprecate old policy engine and restrict access
This commit does two different changes: it changes the policy engine to
oslo_policy and restrict access to sysinv API to users of projects
'admin' or 'services'.

The policy engine deprecated is the one present in the file
"sysinv/sysinv/sysinv/sysinv/openstack/common/policy.py" (780 lines).
This file is no longer used by this repository and was not deleted
because it is used by other repositories, like starlingx/update. The
library oslo_policy is used in its place. In fact, the deprecated engine
seems to be an ancient version of oslo_policy. The library oslo_policy
changed the default format of configuration files from JSON to YAML, so
the configuration files named "policy.json" were changed to
"policy.yaml". The file that initializes and wraps oslo_policy
("sysinv/sysinv/sysinv/sysinv/common/policy.py") contains the minimal
implementation to use this library.

The access to sysinv API, before this commit, was restricted to users
with role "admin" or "administrator" from any project. This commit
restricts the access to users with role "admin" of projects "admin" or
"services". This change should not cause problems, because role
"administrator" doesn't exist and because all users from Starlingx are
from projects "admin" or "services". This change is needed to avoid
access from admin users of other projects.

To test custom policy rules set in the file "/etc/sysinv/policy.yaml",
it will be used the Service Parameter API actions create/apply/modify/
delete/get (commands "system service-parameter-[add/apply/modify/delete/
list]". To test default policy for sysinv API commands, it will be used
the command to change the system description (PATCH "/v1/isystems",
command "system modify --description='test'"). On test plan, these
commands will be reffered as "test commands". Any change in the file
"/etc/sysinv/policy.yaml" is detected by policy engine and rules are
updated.

Test Plan:

PASS: Successfully deploy an AIO-SX using an Debian image with this
commit present. Successfully create, through openstack CLI, the users:
'testreader' with role 'reader' in project 'admin',
'adminsvc' with role 'admin' in project 'services' and
'otheradmin' with role 'admin' in project 'notadminproject'.
Create openrc files for all new users. Note: the other user that will be
used is the already existing 'admin' with role 'admin' in project
'admin'.
PASS: In the deployed AIO-SX, check the behavior of test commands
through different users: for "admin" and "adminsvc" users, all commands
are successful; for user "testreader", only "service-parameter-list"
command is successful and for user "otheradmin" no command is
successful.
PASS: In the deployed AIO-SX, add the following lines in file
"/etc/sysinv/policy.yaml":
config_api:service_parameter:add: role:reader
config_api:service_parameter:apply: role:reader
config_api:service_parameter:delete: role:reader
config_api:service_parameter:get: role:reader
config_api:service_parameter:modify: role:reader
and check the behavior of test commands through different users:
for "admin" and "adminsvc" users, all commands are successful; for users
"testreader" and "otheradmin", all commands are successful except the
change in the system description ("system modify --description='test'").
PASS: In the deployed AIO-SX, to assert that public API works without
authentication, execute the commands:
"curl -v http://<MGMT_IP>:6385/v1/" and
"curl -v http://<MGMT_IP>:6385/v1/isystems/mgmtvlan" and
verify that they are accepted and that the HTTP response is 200,
and execute the commands:
"curl -v http://<MGMT_IP>:6385/v1/isystems/" and
"curl -v http://<MGMT_IP>:6385/v1/service_parameter" and
verify that they are rejected and that the HTTP response is 401.
PASS: Repeat all tests above changing the deploy to AIO-DX using an
CentOS image.
PASS: Successfully execute Debian AIO-SX daily regression and sanity
tests using an image containing this change.

Story: 2010149
Task: 45984

Signed-off-by: Joao Victor Portal <Joao.VictorPortal@windriver.com>
Change-Id: Id7aa387e154afb1441a8484b076cdc97f2fc46cb
2022-08-10 11:18:38 -03:00
..
data rootca update upload cert API 2021-06-17 16:06:53 -03:00
__init__.py StarlingX open source release updates 2018-05-31 07:35:52 -07:00
base.py Deprecate old policy engine and restrict access 2022-08-10 11:18:38 -03:00
test_acl.py Adding pylint checking to the sysinv unit tests 2020-01-14 08:32:12 -06:00
test_address.py Fixed address interface foreign key inconsistency 2020-03-03 16:50:12 -05:00
test_base.py StarlingX open source release updates 2018-05-31 07:35:52 -07:00
test_certificate.py Temporary skip part of SAN certificates tests for DebianOS 2021-08-17 07:42:36 +00:00
test_controller_fs.py Fixed error responses in controller-fs 2020-02-19 15:06:02 -05:00
test_device.py Allow de-provisioning of FEC device 2022-04-06 06:02:42 -04:00
test_device_image.py Device image upload with bmc type error 2022-07-06 20:13:18 +00:00
test_device_label.py Allow applying device image with non-device label 2020-07-28 11:27:28 -04:00
test_dns.py Forbid IPv4 DNS in an IPv6 OAM config 2020-02-06 10:27:04 -05:00
test_helm_charts.py Fix helm charts tests for DebianOS 2021-08-17 07:39:31 +00:00
test_host.py Prevent a new host to be added to AIO-SX 2022-06-22 13:12:04 -04:00
test_host_fs.py Add a new filesystem for image conversion 2020-04-29 09:52:35 +00:00
test_interface.py Disallow with sriov_numvfs is 0 or less when creating vf interface 2022-07-25 16:08:32 +09:00
test_interface_datanetwork.py Support data network assignment on an unlocked host 2021-02-02 07:52:28 -05:00
test_interface_network.py Clean up interface network assignment 2019-06-13 09:43:57 -04:00
test_kube_cluster.py Config API for Kubernetes cluster access information 2021-03-01 07:29:12 -06:00
test_kube_cmd_version.py sysinv: update constant name to be more accurate 2021-10-01 09:14:05 -06:00
test_kube_host_upgrade.py Skip storage nodes when listing per-host k8s upgrade info 2021-11-18 13:42:18 -06:00
test_kube_rootca_update.py k8s upgrade health: Check trident compatibility 2022-04-28 19:58:02 -04:00
test_kube_upgrade.py k8s upgrade health: Check trident compatibility 2022-04-28 19:58:02 -04:00
test_kube_version.py Allow recovery from failures during kubernetes upgrade 2019-12-11 14:30:50 -06:00
test_label.py Remove stx-monitor constants and logic 2020-07-28 08:30:35 -04:00
test_network.py Add RPCAPI calls to apply LDAP client and DNS runtime manifest 2021-04-27 11:21:54 -04:00
test_ntp.py Add unit test for NTP api 2020-01-23 10:54:06 -05:00
test_oamnetwork.py Add support for AIO-SX to DX migration on subcloud 2021-03-29 14:00:52 -04:00
test_partition.py sysinv: Add support for mpath device 2022-05-24 08:25:18 -04:00
test_ptp.py [PTP dual NIC config] Patching PTP configuration 2022-02-10 11:51:08 -03:00
test_ptp_instance.py Fix PTP parameter deletion error messages 2022-02-22 07:04:01 -05:00
test_ptp_instance_update.py Fix PTP parameter deletion error messages 2022-02-22 07:04:01 -05:00
test_ptp_interface.py Fix PTP parameter deletion error messages 2022-02-22 07:04:01 -05:00
test_ptp_parameter.py [PTP dual NIC config] Manage parameter life-cycle 2022-01-19 13:18:24 -03:00
test_pv.py Refactor unit test API example to use unit test mixins 2020-01-15 13:02:22 -06:00
test_root.py StarlingX open source release updates 2018-05-31 07:35:52 -07:00
test_route.py Disallow route config during upgrade states 2022-05-05 10:39:45 -04:00
test_sensorgroup.py Align API types with database types 2022-07-14 18:27:31 -03:00
test_service_parameters.py Configurable coredump parameters with validation 2022-05-10 14:00:58 -04:00
test_storage_backends.py Allow configurable ceph storage backend network 2021-05-07 14:31:39 +03:00
test_storage_tier.py Merge "Allow configurable ceph storage backend network" 2021-05-12 13:30:29 +00:00
test_system.py Add validation of special chars on system values 2022-01-26 11:06:37 -03:00
test_upgrade.py Support passing an ignore alarm list to kube upgrade start API 2021-01-13 09:12:47 -06:00
utils.py StarlingX open source release updates 2018-05-31 07:35:52 -07:00