1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

[PR #11285/a55884c9 backport][stable-12] Add support for missing validations in keycloak_userprofile (#11302)

Add support for missing validations in keycloak_userprofile (#11285)

* add missing validations-parameters as config options and add documentation for them; fixes https://github.com/ansible-collections/community.general/issues/9048

* fix parameter names

* extend unit tests

* support for camel casing for new validations and add changelog fragment

* Fix fragment format

* add 'version_added' documentation

* Update changelogs/fragments/11285-extended-keycloak-user-profile-validations.yml

mention fixed issue in fragment



* fix ruff formatting

---------


(cherry picked from commit a55884c921)

Co-authored-by: nwintering <33374766+nwintering@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2025-12-22 11:13:57 +01:00 committed by GitHub
parent 12637fbd23
commit a15ec28169
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 205 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
minor_changes:
- keycloak_userprofile - add support for additional user profile attribute-validations available in Keycloak (https://github.com/ansible-collections/community.general/issues/9048, https://github.com/ansible-collections/community.general/pull/11285).

View file

@ -160,6 +160,50 @@ options:
- Validation to ensure the attribute matches one of the provided options.
type: dict
integer:
description:
- The integer validation for the attribute.
type: dict
version_added: 12.2.0
double:
description:
- The double validation for the attribute.
type: dict
version_added: 12.2.0
iso_date:
description:
- The iso-date validation for the attribute.
type: dict
aliases:
- isoDate
version_added: 12.2.0
local_date:
description:
- The local-date validation for the attribute.
type: dict
aliases:
- localDate
version_added: 12.2.0
multivalued:
description:
- The multivalued validation for the attribute.
type: dict
suboptions:
min:
description:
- The minimum amount of values of the attribute.
type: int
max:
description:
- The maximum amount of values of the attribute.
type: int
required: true
version_added: 12.2.0
annotations:
description:
- Annotations for the attribute.
@ -341,6 +385,22 @@ EXAMPLES = r"""
- user
edit: []
multivalued: false
- name: testAttribute
displayName: ${testAttribute}
validations:
integer:
min: 0
max: 255
annotations: {}
required:
roles:
- user
permissions:
view:
- admin
- user
edit: []
multivalued: false
groups:
- name: user-metadata
displayHeader: User metadata
@ -488,6 +548,17 @@ def main():
"uri": dict(type="dict"),
"pattern": dict(type="dict"),
"options": dict(type="dict"),
"integer": dict(type="dict"),
"double": dict(type="dict"),
"iso_date": dict(type="dict", aliases=["isoDate"]),
"local_date": dict(type="dict", aliases=["localDate"]),
"multivalued": dict(
type="dict",
options={
"min": dict(type="int", required=False),
"max": dict(type="int", required=True),
},
),
},
),
"annotations": dict(type="dict"),
@ -610,6 +681,12 @@ def main():
attribute["validations"]["person-name-prohibited-characters"] = attribute[
"validations"
].pop("personNameProhibitedCharacters")
if "isoDate" in attribute["validations"]:
attribute["validations"]["iso-date"] = attribute["validations"].pop("isoDate")
if "localDate" in attribute["validations"]:
attribute["validations"]["local-date"] = attribute["validations"].pop(
"localDate"
)
changeset[camel(component_param)][config_param].append(kc_user_profile_config[0])
# usual camelCase parameters
else:

View file

@ -148,6 +148,31 @@ class TestKeycloakUserprofile(ModuleTestCase):
"required": {"roles": ["user"]},
"validations": {"length": {"max": 255}, "person_name_prohibited_characters": {}},
},
{
"annotations": {},
"displayName": "${testAttr}",
"multivalued": False,
"name": "testAttr",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"integer": {"min": 0, "max": 255},
"double": {},
"iso_date": {},
"local_date": {},
},
},
{
"annotations": {},
"displayName": "${testAttr2}",
"multivalued": True,
"name": "testAttr2",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"multivalued": {"min": 0, "max": 5},
},
},
],
"groups": [
{
@ -210,6 +235,31 @@ class TestKeycloakUserprofile(ModuleTestCase):
"multivalued": False,
"annotations": {},
},
{
"annotations": {},
"displayName": "${testAttr}",
"multivalued": False,
"name": "testAttr",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"integer": {"min": 0, "max": 255},
"double": {},
"iso_date": {},
"local_date": {},
},
},
{
"annotations": {},
"displayName": "${testAttr2}",
"multivalued": True,
"name": "testAttr2",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"multivalued": {"min": 0, "max": 5},
},
},
],
"groups": [
{
@ -306,6 +356,31 @@ class TestKeycloakUserprofile(ModuleTestCase):
"required": {"roles": ["user"]},
"validations": {"length": {"max": 255}, "person_name_prohibited_characters": {}},
},
{
"annotations": {},
"displayName": "${testAttr}",
"multivalued": False,
"name": "testAttr",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"integer": {"min": 0, "max": 255},
"double": {},
"iso_date": {},
"local_date": {},
},
},
{
"annotations": {},
"displayName": "${testAttr2}",
"multivalued": True,
"name": "testAttr2",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"multivalued": {"min": 0, "max": 5},
},
},
],
"groups": [
{
@ -376,6 +451,31 @@ class TestKeycloakUserprofile(ModuleTestCase):
"multivalued": False,
"annotations": {},
},
{
"annotations": {},
"displayName": "${testAttr}",
"multivalued": False,
"name": "testAttr",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"integer": {"min": 0, "max": 255},
"double": {},
"iso_date": {},
"local_date": {},
},
},
{
"annotations": {},
"displayName": "${testAttr2}",
"multivalued": True,
"name": "testAttr2",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"multivalued": {"min": 0, "max": 5},
},
},
],
"groups": [
{
@ -528,6 +628,31 @@ class TestKeycloakUserprofile(ModuleTestCase):
"multivalued": False,
"annotations": {},
},
{
"annotations": {},
"displayName": "${testAttr}",
"multivalued": False,
"name": "testAttr",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"integer": {"min": 0, "max": 255},
"double": {},
"iso_date": {},
"local_date": {},
},
},
{
"annotations": {},
"displayName": "${testAttr2}",
"multivalued": True,
"name": "testAttr2",
"permissions": {"edit": ["admin", "user"], "view": ["admin", "user"]},
"required": {"roles": ["user"]},
"validations": {
"multivalued": {"min": 0, "max": 5},
},
},
],
"groups": [
{