Skip to content

Commit 221b871

Browse files
New parameters and functions, and test setup (#443)
* feature: first test setup * feature: update test setup * feature: update test base admin * feature: add test aac api protection * fix: remove unncessary stuff * fix: pre-commit * fix: pre-commit * fix: remove trailing spaces * fix: pre-commit update * fix: pylint * refactor: pyproject * refactor: pyproject * documentation: start with documentation * refactor: setup build and test WIP * feature: test for risk profiles * documentation: update * documentation: update version * refactor: update tox * refactor: update pylint github action * refactor: avoid error * documentation: typo * feature: support for type=federation * fix: corrections * feature: test for management authentication * fix: add new parameters for oauth configuration of rp * fix: replace .format with f-strings * feature: new module * fix: comments * feature: test for new module * feature: new sms connection module * fix: format to f-string * fix: change compare method * fix: disable all pylint checks * feature: add test for sms connection * feature: update pre-commit * feature: update pylint config * fix: format() -> f-string * fix: pylint generate text report * fix: format() -> f-string * fix: format() -> f-string * fix: format() -> f-string * fix: pytest move commit to fixture * feature: new attributes in 10.0.8 * fix: format() -> f-string * fix: pylint * fix: pylint format -> f-string * fix: ignore error * feature: test for admin ssh keys * fix: small updates, and test * documentation: update pylint and changelog * documentation: move changelog into docs * documentation: update .gitignore (exlcude reports) * feature: tracing configuration (new in 10.0.8) * documentation: wip
1 parent dc79d22 commit 221b871

File tree

174 files changed

+2278
-870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+2278
-870
lines changed

.config/requirements-docs.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
mkdocs
2+
mkdocs-material
3+
markdown-exec
4+
mkdocstrings
5+
pymdown-extensions
6+
markdown_include

.config/requirements-test.in

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
black # IDE support
2+
coverage-enable-subprocess # see https://github.com/nedbat/coveragepy/issues/1341#issuecomment-1228942657
3+
coverage[toml] >= 6.4.4
4+
jmespath
5+
license-expression >= 30.3.0 # Apache 2.0
6+
mypy # IDE support
7+
netaddr # needed by ipwrap filter
8+
pip # tox command
9+
psutil # soft-dep of pytest-xdist
10+
pylint # IDE support
11+
pytest >= 7.2.2
12+
pytest-instafail >= 0.5.0 # only for local development, via PYTEST_ADDOPTS=-edit
13+
pytest-mock
14+
pytest-dotenv
15+
pytest-sugar # shows failures immediately, even with xdist
16+
pytest-xdist[psutil,setproctitle] >= 2.1.0
17+
tox >= 4.0.0
18+
tox-extra>=2.1
19+
tox-uv>=1.25
20+
tox>=4.24.2
21+
types-jsonschema # IDE support
22+
types-pyyaml # IDE support

.config/requirements.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# alphabetically sorted:
2+
black>=24.3.0 # MIT (security)
3+
filelock>=3.8.2 # The Unlicense
4+
importlib-metadata # Apache
5+
jsonschema>=4.10.0 # MIT, version needed for improved errors
6+
packaging>=22.0 # Apache-2.0,BSD-2-Clause
7+
pathspec>=0.10.3 # Mozilla Public License 2.0 (MPL 2.0)
8+
pyyaml>=6.0.2 # MIT (compilation probles with older versions)
9+
requests
10+
jmespath>=1.0.0
11+
PyYAML

.github/workflows/pylint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ["3.8", "3.9", "3.10"]
10+
python-version: ["3.11"]
1111
steps:
1212
- uses: actions/checkout@v4
1313
- name: Set up Python ${{ matrix.python-version }}
@@ -20,4 +20,4 @@ jobs:
2020
pip install pylint
2121
- name: Analysing the code with pylint
2222
run: |
23-
pylint $(git ls-files '*.py')
23+
pylint $(git ls-files 'ibmsecurity/isam/*.py') --exit-zero

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ nosetests.xml
4444
coverage.xml
4545
*,cover
4646
.hypothesis/
47+
report.txt
48+
report_.*.txt
4749

4850
# Translations
4951
*.mo

.pre-commit-config.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ repos:
1212
hooks:
1313
- id: black
1414
stages: [pre-push]
15-
- repo: https://github.com/PyCQA/flake8
16-
rev: 7.1.1
17-
hooks:
18-
- id: flake8
19-
args: ["--ignore=E501"]
15+
#- repo: https://github.com/PyCQA/flake8
16+
# rev: 7.1.1
17+
# hooks:
18+
# - id: flake8
19+
# args: ["--ignore=E501"]
2020
- repo: https://github.com/PyCQA/pylint
21-
rev: v3.3.2
21+
rev: v3.3.7
2222
hooks:
2323
- id: pylint
2424
args: [
25-
"-ry",
26-
"--exit-zero"
25+
"--recursive=y",
26+
"--exit-zero",
27+
"--rcfile=pylintrc",
28+
"--output-format=github:report.txt"
2729
]

conftest.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""PyTest fixtures for testing the project."""
2+
from __future__ import annotations
3+
4+
import os
5+
6+
import pytest
7+
8+
from ibmsecurity.appliance.isamappliance import ISAMAppliance
9+
from ibmsecurity.user.applianceuser import ApplianceUser
10+
import ibmsecurity.isam.appliance
11+
12+
@pytest.fixture(scope="session")
13+
def iviaServer():
14+
"""Initiate an ISAMAppliance."""
15+
# s = IviaLogin()
16+
_username = os.getenv('IVIA_ADMIN')
17+
_pw = os.getenv('IVIA_PW')
18+
_host = os.getenv('IVIA_HOST')
19+
_port = os.getenv('IVIA_PORT') or 443
20+
# Create a user credential for ISAM appliance
21+
u = ApplianceUser(username=_username, password=_pw)
22+
# Create an ISAM appliance with above credential
23+
isam_server = ISAMAppliance(hostname=_host, user=u, lmi_port=_port)
24+
yield isam_server
25+
returnValue = ibmsecurity.isam.appliance.commit(isamAppliance=isam_server)
26+
print('\nCommit result')
27+
print( returnValue )
28+
print('\n')
29+
return returnValue
30+
31+
# ibmsecurity
32+
def pytest_runtest_setup(item):
33+
print("setting up function:", item.name)
34+
yield
35+
36+
37+
# @pytest.fixture(autouse=True)
38+
# def pytest_configure(config: Config) -> None:
39+
# """Register custom markers."""
40+
# print('configure')
41+
42+
#@pytest.fixture(scope="session", autouse=True)
43+
#def ivia_commit(iviaServer):
44+
# """Commit the changes"""
45+
# print('TEST')
46+
# # caplog.set_level(logging.INFO)
47+
48+
# returnValue = ibmsecurity.isam.appliance.commit(isamAppliance=iviaServer)
49+
# # logging.log(logging.DEBUG, returnValue)
50+
# print(returnValue)
51+
52+
#@pytest.hookimpl(hookwrapper=True)
53+
#def pytest_sessionfinish(session, iviaServer):
54+
# """Commit the changes"""
55+
# # caplog.set_level(logging.INFO)
56+
#
57+
# returnValue = ibmsecurity.isam.appliance.commit(isamAppliance=iviaServer)
58+
# yield returnValue
59+
# # logging.log(logging.DEBUG, returnValue)
60+
# print(returnValue)
61+
# print("\nTest session finished!")

changelog.md renamed to docs/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## Latest
44

5+
- feature: base/management_authentication.py - type federation
6+
- build: test setup
7+
- feature: web/reverse_proxy/oauth_configuration.py - add new parameters in 10.0.8
8+
- feature: web/reverse_proxy/oauth2_configuration.py - OAuth2 IBM Security Verify OIDC Provider configuration (new in 10.0.4)
9+
- feature: aac/server_connections/sms.py - SMS Server Connection (new in 10.0.8)
10+
- fix: base/admin_ssh_keys.py - Ignore error when same ssh key exists under different name
11+
- pylint: change format() to f-strings
12+
- feature: base/tracing.py - Get tracing configuration (new in 10.0.8)
513

614
## 2025.3.28.0
715

docs/contributing.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Contributing to ibmsecurity WIP
2+
3+
To contribute to ibmsecurity, please use pull requests on a branch of your own
4+
fork.
5+
6+
After [creating your fork on GitHub], you can do:
7+
8+
```shell-session
9+
$ git clone --recursive [email protected]:your-name/ibmsecurity
10+
$ cd ibmsecurity
11+
$ # Recommended: Initialize and activate a Python virtual environment
12+
$ pip install --upgrade pip
13+
$ pip install -e '.[test]' # Install testing dependencies
14+
$ tox run -e lint
15+
$ git checkout -b your-branch-name
16+
# DO SOME CODING HERE
17+
# Add tests under `test/`
18+
$ tox run -e lint,py
19+
$ git add your new files
20+
$ git commit -v
21+
$ git push origin your-branch-name
22+
```
23+
24+
You will then be able to create a pull request from your commit.
25+
26+
## Setup
27+
28+
### Local appliance
29+
30+
There is no mock code for testing, unfortunately.
31+
So you need a running IBM Verify Access/IBM Identity Verify Access appliance or container to be able to run the tests.
32+
33+
### Env
34+
35+
Create a .env file in the root directory of the project, with the details to connect to your IVIA appliance, for instance :
36+
37+
````properties
38+
IVIA_ADMIN=admin@local
39+
IVIA_PW=admin
40+
IVIA_HOST=<ip address of lmi>
41+
# IVIA_PORT = 80
42+
````
43+
44+
## Standards
45+
46+
Automated tests will be run against all PRs, to run checks locally before
47+
pushing commits, just use [tox](https://tox.wiki/en/latest/).
48+
49+
## Talk to us
50+
51+
52+
53+
## Code of Conduct
54+
55+
56+
57+
## Module dependency graph
58+
59+
60+
61+
## Documentation changes
62+
63+
To build the docs, run `tox -e docs`. At the end of the build, you will see the
64+
local location of your built docs.

docs/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# IBMSecurity Documentation
2+
3+
## About ibmsecurity
4+
5+
This repository contains Python code to manage IBM Security Appliances using their respective REST APIs.
6+
ISAM appliance has the most mature code.
7+
8+
Code for ISDS appliance is under development.
9+
10+
Code for ISVG appliance is brand new (tested with 10.0.1.0 and higher only).

0 commit comments

Comments
 (0)