Merge "Enhance federation group mapping validation"
This commit is contained in:
commit
5fc66792bd
|
@ -61,12 +61,7 @@ MAPPING_SCHEMA = {
|
||||||
"name": {"type": "string"},
|
"name": {"type": "string"},
|
||||||
"email": {"type": "string"},
|
"email": {"type": "string"},
|
||||||
"domain": {
|
"domain": {
|
||||||
"type": "object",
|
"$ref": "#/definitions/domain"
|
||||||
"properties": {
|
|
||||||
"id": {"type": "string"},
|
|
||||||
"name": {"type": "string"}
|
|
||||||
},
|
|
||||||
"additionalProperties": False,
|
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -78,19 +73,10 @@ MAPPING_SCHEMA = {
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"oneOf": [
|
||||||
"id": {"type": "string"},
|
{"$ref": "#/definitions/group_by_id"},
|
||||||
"name": {"type": "string"},
|
{"$ref": "#/definitions/group_by_name"}
|
||||||
"domain": {
|
]
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {"type": "string"},
|
|
||||||
"name": {"type": "string"}
|
|
||||||
},
|
|
||||||
"additionalProperties": False,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"additionalProperties": False,
|
|
||||||
},
|
},
|
||||||
"groups": {
|
"groups": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -98,14 +84,7 @@ MAPPING_SCHEMA = {
|
||||||
"group_ids": {
|
"group_ids": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"domain": {
|
"domain": {"$ref": "#/definitions/domain"},
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {"type": "string"},
|
|
||||||
"name": {"type": "string"}
|
|
||||||
},
|
|
||||||
"additionalProperties": False
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -195,6 +174,31 @@ MAPPING_SCHEMA = {
|
||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"domain": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {"type": "string"},
|
||||||
|
"name": {"type": "string"}
|
||||||
|
},
|
||||||
|
"additionalProperties": False
|
||||||
|
},
|
||||||
|
"group_by_id": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"id": {"type": "string"}
|
||||||
|
},
|
||||||
|
"additionalProperties": False,
|
||||||
|
"required": ["id"]
|
||||||
|
},
|
||||||
|
"group_by_name": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {"type": "string"},
|
||||||
|
"domain": {"$ref": "#/definitions/domain"}
|
||||||
|
},
|
||||||
|
"additionalProperties": False,
|
||||||
|
"required": ["name", "domain"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ from keystone import exception
|
||||||
from keystone.federation import utils as mapping_utils
|
from keystone.federation import utils as mapping_utils
|
||||||
from keystone.tests import unit
|
from keystone.tests import unit
|
||||||
from keystone.tests.unit import mapping_fixtures
|
from keystone.tests.unit import mapping_fixtures
|
||||||
from keystone.tests.unit import utils as test_utils
|
|
||||||
|
|
||||||
|
|
||||||
FAKE_MAPPING_ID = uuid.uuid4().hex
|
FAKE_MAPPING_ID = uuid.uuid4().hex
|
||||||
|
@ -630,14 +629,30 @@ class MappingRuleEngineTests(unit.BaseTestCase):
|
||||||
mapping = mapping_fixtures.MAPPING_GROUP_NAMES
|
mapping = mapping_fixtures.MAPPING_GROUP_NAMES
|
||||||
mapping_utils.validate_mapping_structure(mapping)
|
mapping_utils.validate_mapping_structure(mapping)
|
||||||
|
|
||||||
@test_utils.wip('waiting for fix the validator '
|
def test_mapping_validation_bad_domain(self):
|
||||||
'to choke on group name without domain')
|
mapping = mapping_fixtures.MAPPING_BAD_DOMAIN
|
||||||
|
self.assertRaises(exception.ValidationError,
|
||||||
|
mapping_utils.validate_mapping_structure,
|
||||||
|
mapping)
|
||||||
|
|
||||||
|
def test_mapping_validation_bad_group(self):
|
||||||
|
mapping = mapping_fixtures.MAPPING_BAD_GROUP
|
||||||
|
self.assertRaises(exception.ValidationError,
|
||||||
|
mapping_utils.validate_mapping_structure,
|
||||||
|
mapping)
|
||||||
|
|
||||||
def test_mapping_validation_with_group_name_without_domain(self):
|
def test_mapping_validation_with_group_name_without_domain(self):
|
||||||
mapping = mapping_fixtures.MAPPING_GROUP_NAME_WITHOUT_DOMAIN
|
mapping = mapping_fixtures.MAPPING_GROUP_NAME_WITHOUT_DOMAIN
|
||||||
self.assertRaises(exception.ValidationError,
|
self.assertRaises(exception.ValidationError,
|
||||||
mapping_utils.validate_mapping_structure,
|
mapping_utils.validate_mapping_structure,
|
||||||
mapping)
|
mapping)
|
||||||
|
|
||||||
|
def test_mapping_validation_with_group_id_and_domain(self):
|
||||||
|
mapping = mapping_fixtures.MAPPING_GROUP_ID_WITH_DOMAIN
|
||||||
|
self.assertRaises(exception.ValidationError,
|
||||||
|
mapping_utils.validate_mapping_structure,
|
||||||
|
mapping)
|
||||||
|
|
||||||
def test_mapping_validation_no_local(self):
|
def test_mapping_validation_no_local(self):
|
||||||
mapping = mapping_fixtures.MAPPING_MISSING_LOCAL
|
mapping = mapping_fixtures.MAPPING_MISSING_LOCAL
|
||||||
self.assertRaises(exception.ValidationError,
|
self.assertRaises(exception.ValidationError,
|
||||||
|
|
|
@ -607,6 +607,81 @@ MAPPING_GROUP_NAME_WITHOUT_DOMAIN = {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MAPPING_GROUP_ID_WITH_DOMAIN = {
|
||||||
|
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"local": [
|
||||||
|
{
|
||||||
|
"group": {
|
||||||
|
"id": EMPLOYEE_GROUP_ID,
|
||||||
|
"domain": {
|
||||||
|
"id": DEVELOPER_GROUP_DOMAIN_ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"remote": [
|
||||||
|
{
|
||||||
|
"type": "orgPersonType",
|
||||||
|
"any_one_of": [
|
||||||
|
"Employee"
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
MAPPING_BAD_GROUP = {
|
||||||
|
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"local": [
|
||||||
|
{
|
||||||
|
"group": {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"remote": [
|
||||||
|
{
|
||||||
|
"type": "orgPersonType",
|
||||||
|
"any_one_of": [
|
||||||
|
"Employee"
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
MAPPING_BAD_DOMAIN = {
|
||||||
|
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"local": [
|
||||||
|
{
|
||||||
|
"group": {
|
||||||
|
"id": EMPLOYEE_GROUP_ID,
|
||||||
|
"domain": {
|
||||||
|
"id": DEVELOPER_GROUP_DOMAIN_ID,
|
||||||
|
"badkey": "badvalue"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"remote": [
|
||||||
|
{
|
||||||
|
"type": "orgPersonType",
|
||||||
|
"any_one_of": [
|
||||||
|
"Employee"
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
MAPPING_EPHEMERAL_USER = {
|
MAPPING_EPHEMERAL_USER = {
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue