Skip to content

Commit

Permalink
fix: Ci/fix tests (#506)
Browse files Browse the repository at this point in the history
* chore: deps update

* test: fix tests

* ci: update

* fix: dependencies

* ci: drop python 3.7

* fix: docs, lint etc

* test: fixed exchange

* chore: docs lint

* ci: ignore e231

* fix: upgrade sphinx

* docs: read the docs updated

* chore: removed setuptools
  • Loading branch information
ryshoooo authored Nov 13, 2023
1 parent 5d4b9d1 commit 03c317c
Show file tree
Hide file tree
Showing 16 changed files with 658 additions and 894 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
keycloak-version: ["20.0", "21.0", "latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
keycloak-version: ["20.0", "21.0", "22.0", "latest"]
env:
KEYCLOAK_DOCKER_IMAGE_TAG: ${{ matrix.keycloak-version }}
steps:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: webiny/action-conventional-commits@v1.0.3
- uses: webiny/action-conventional-commits@v1.1.0

check-linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -37,10 +37,10 @@ jobs:
- check-linting
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -55,8 +55,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
keycloak-version: ["20.0", "21.0", "latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
keycloak-version: ["20.0", "21.0", "22.0", "latest"]
needs:
- check-commits
- check-linting
Expand Down Expand Up @@ -88,10 +88,10 @@ jobs:
- check-docs
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2

build:
os: "ubuntu-20.04"
os: "ubuntu-22.04"
tools:
python: "3.10"
python: "3.12"
jobs:
post_install:
- pip install -U poetry
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ keycloak_admin.get_users() # Get users in realm 'demo'
keycloak_admin.create_user(...) # Creates a new user in 'demo'

# Get User events
keycloak_admin.get_events(query={'type': 'LOGIN',
'user': user['id'],
keycloak_admin.get_events(query={'type': 'LOGIN',
'user': user['id'],
'dateFrom': '2023-08-02'})

# Get Admin events
Expand Down
1,374 changes: 599 additions & 775 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,19 @@ Documentation = "https://python-keycloak.readthedocs.io/en/latest/"
"Issue tracker" = "https://github.com/marcospereirampj/python-keycloak/issues"

[tool.poetry.dependencies]
python = ">=3.7,<4.0"
setuptools = "*"
python = ">=3.8,<4.0"
requests = ">=2.20.0"
python-jose = ">=3.3.0"
mock = {version = "^4.0.3", optional = true}
alabaster = {version = "^0.7.12", optional = true}
commonmark = {version = "^0.9.1", optional = true}
recommonmark = {version = "^0.7.1", optional = true}
Sphinx = {version = "^5.3.0", optional = true}
Sphinx = {version = "^6.1.0", optional = true}
sphinx-rtd-theme = {version = "^1.0.0", optional = true}
readthedocs-sphinx-ext = {version = "^2.1.9", optional = true}
m2r2 = {version = "^0.3.2", optional = true}
sphinx-autoapi = {version = "^2.0.0", optional = true}
requests-toolbelt = "*"
sphinx-autoapi = {version = "^3.0.0", optional = true}
requests-toolbelt = ">=0.6.0"
deprecation = ">=2.1.0"

[tool.poetry.extras]
Expand Down
4 changes: 2 additions & 2 deletions src/keycloak/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import pkg_resources
from importlib import metadata

__version__ = pkg_resources.get_distribution("python-keycloak").version
__version__ = metadata.version("python-keycloak")
6 changes: 4 additions & 2 deletions src/keycloak/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class ConnectionManager(object):
:type headers: dict
:param timeout: Timeout to use for requests to the server.
:type timeout: int
:param verify: Boolean value to enable or disable certificate validation or a string containing a path to a CA bundle to use
:param verify: Boolean value to enable or disable certificate validation or a string
containing a path to a CA bundle to use
:type verify: Union[bool,str]
:param proxies: The proxies servers requests is sent by.
:type proxies: dict
Expand All @@ -58,7 +59,8 @@ def __init__(self, base_url, headers={}, timeout=60, verify=True, proxies=None):
:type headers: dict
:param timeout: Timeout to use for requests to the server.
:type timeout: int
:param verify: Boolean value to enable or disable certificate validation or a string containing a path to a CA bundle to use
:param verify: Boolean value to enable or disable certificate validation or a string
containing a path to a CA bundle to use
:type verify: Union[bool,str]
:param proxies: The proxies servers requests is sent by.
:type proxies: dict
Expand Down
52 changes: 6 additions & 46 deletions src/keycloak/keycloak_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class KeycloakAdmin:
:type realm_name: str
:param client_id: client id
:type client_id: str
:param verify: Boolean value to enable or disable certificate validation or a string containing a path to a CA bundle to use
:param verify: Boolean value to enable or disable certificate validation or a string
containing a path to a CA bundle to use
:type verify: Union[bool,str]
:param client_secret_key: client secret key
(optional, required only for access type confidential)
Expand Down Expand Up @@ -119,7 +120,8 @@ def __init__(
:type realm_name: str
:param client_id: client id
:type client_id: str
:param verify: Boolean value to enable or disable certificate validation or a string containing a path to a CA bundle to use
:param verify: Boolean value to enable or disable certificate validation or a string
containing a path to a CA bundle to use
:type verify: Union[bool,str]
:param client_secret_key: client secret key
(optional, required only for access type confidential)
Expand Down Expand Up @@ -1239,7 +1241,7 @@ def get_sessions(self, user_id):
return raise_error_from_response(data_raw, KeycloakGetError)

def get_server_info(self):
"""Get themes, social providers, auth providers, and event listeners available on this server.
"""Get themes, social providers, etc. on this server.
ServerInfoRepresentation
https://www.keycloak.org/docs-api/18.0/rest-api/index.html#_serverinforepresentation
Expand Down Expand Up @@ -1783,48 +1785,6 @@ def create_client_authz_resource_based_permission(self, client_id, payload, skip
data_raw, KeycloakPostError, expected_codes=[201], skip_exists=skip_exists
)

def create_client_authz_scope_based_permission(self, client_id, payload, skip_exists=False):
"""Create scope-based permission of client.
Payload example::
payload={
"type": "resource",
"logic": "POSITIVE",
"decisionStrategy": "UNANIMOUS",
"name": "Permission-Name",
"resources": [
resource_id
],
"policies": [
policy_id
],
"scopes": [
scope_id
]
:param client_id: id in ClientRepresentation
https://www.keycloak.org/docs-api/18.0/rest-api/index.html#_clientrepresentation
:type client_id: str
:param payload: PolicyRepresentation
https://www.keycloak.org/docs-api/18.0/rest-api/index.html#_policyrepresentation
:type payload: dict
:param skip_exists: Skip creation in case the object already exists
:type skip_exists: bool
:return: Keycloak server response
:rtype: bytes
"""
params_path = {"realm-name": self.realm_name, "id": client_id}

data_raw = self.connection.raw_post(
urls_patterns.URL_ADMIN_CLIENT_AUTHZ_SCOPE_BASED_PERMISSION.format(**params_path),
data=json.dumps(payload),
)
return raise_error_from_response(
data_raw, KeycloakPostError, expected_codes=[201], skip_exists=skip_exists
)

def get_client_authz_scopes(self, client_id):
"""Get scopes from client.
Expand Down Expand Up @@ -4272,7 +4232,7 @@ def create_client_authz_scope_permission(self, payload, client_id):
urls_patterns.URL_ADMIN_ADD_CLIENT_AUTHZ_SCOPE_PERMISSION.format(**params_path),
data=json.dumps(payload),
)
return raise_error_from_response(data_raw, KeycloakPutError, expected_codes=[201])
return raise_error_from_response(data_raw, KeycloakPostError, expected_codes=[201])

def update_client_authz_scope_permission(self, payload, client_id, scope_id):
"""Update permissions for a given scope.
Expand Down
8 changes: 4 additions & 4 deletions src/keycloak/keycloak_openid.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class KeycloakOpenID:
:param client_id: client id
:param realm_name: realm name
:param client_secret_key: client secret key
:param verify: Boolean value to enable or disable certificate validation or a string containing a path to a CA bundle to use
:param verify: Boolean value to enable or disable certificate validation or a string
containing a path to a CA bundle to use
:param custom_headers: dict of custom header to pass to each HTML request
:param proxies: dict of proxies to sent the request by.
:param timeout: connection timeout in seconds
Expand All @@ -96,7 +97,8 @@ def __init__(
:type realm_name: str
:param client_secret_key: client secret key
:type client_secret_key: str
:param verify: Boolean value to enable or disable certificate validation or a string containing a path to a CA bundle to use
:param verify: Boolean value to enable or disable certificate validation or a string
containing a path to a CA bundle to use
:type verify: Union[bool,str]
:param custom_headers: dict of custom header to pass to each HTML request
:type custom_headers: dict
Expand Down Expand Up @@ -715,7 +717,6 @@ def register_client(self, token: str, payload: dict):
)
return raise_error_from_response(data_raw, KeycloakPostError)


def device(self):
"""Get device authorization grant.
Expand Down Expand Up @@ -743,7 +744,6 @@ def device(self):
data_raw = self.connection.raw_post(URL_DEVICE.format(**params_path), data=payload)
return raise_error_from_response(data_raw, KeycloakPostError)


def update_client(self, token: str, client_id: str, payload: dict):
"""Update a client.
Expand Down
3 changes: 2 additions & 1 deletion src/keycloak/openid_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def __init__(
:type realm_name: str
:param client_id: client id
:type client_id: str
:param verify: Boolean value to enable or disable certificate validation or a string containing a path to a CA bundle to use
:param verify: Boolean value to enable or disable certificate validation or a string
containing a path to a CA bundle to use
:type verify: Union[bool,str]
:param client_secret_key: client secret key
(optional, required only for access type confidential)
Expand Down
1 change: 0 additions & 1 deletion src/keycloak/urls_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
URL_ADMIN_CLIENT_AUTHZ_RESOURCE_BASED_PERMISSION = (
URL_ADMIN_CLIENT_AUTHZ + "/permission/resource?max=-1"
)
URL_ADMIN_CLIENT_AUTHZ_SCOPE_BASED_PERMISSION = URL_ADMIN_CLIENT_AUTHZ + "/permission/scope?max=-1"
URL_ADMIN_CLIENT_AUTHZ_POLICY = URL_ADMIN_CLIENT_AUTHZ + "/policy/{policy-id}"
URL_ADMIN_CLIENT_AUTHZ_POLICY_SCOPES = URL_ADMIN_CLIENT_AUTHZ_POLICY + "/scopes"
URL_ADMIN_CLIENT_AUTHZ_POLICY_RESOURCES = URL_ADMIN_CLIENT_AUTHZ_POLICY + "/resources"
Expand Down
Loading

0 comments on commit 03c317c

Please sign in to comment.