Merge "Use consistent role schema in token response validation"

This commit is contained in:
Zuul 2018-04-16 20:28:23 +00:00 committed by Gerrit Code Review
commit 780f9710fa
1 changed files with 22 additions and 27 deletions

View File

@ -46,6 +46,20 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
def generate_token_schema(self, system_scoped=False, domain_scoped=False, def generate_token_schema(self, system_scoped=False, domain_scoped=False,
project_scoped=False): project_scoped=False):
"""Return a dictionary of token properties to validate against.""" """Return a dictionary of token properties to validate against."""
ROLES_SCHEMA = {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'id': {'type': 'string', },
'name': {'type': 'string', },
},
'required': ['id', 'name', ],
'additionalProperties': False,
},
'minItems': 1,
}
properties = { properties = {
'audit_ids': { 'audit_ids': {
'type': 'array', 'type': 'array',
@ -111,34 +125,10 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
'all': {'type': 'boolean'} 'all': {'type': 'boolean'}
} }
} }
properties['roles'] = { properties['roles'] = ROLES_SCHEMA
'type': 'array',
'items': {
'type': 'object',
'properties': {
'id': {'type': 'string', },
'name': {'type': 'string', },
},
'required': ['id', 'name', ],
'additionalProperties': False,
},
'minItems': 1,
}
elif domain_scoped: elif domain_scoped:
properties['catalog'] = {'type': 'array'} properties['catalog'] = {'type': 'array'}
properties['roles'] = { properties['roles'] = ROLES_SCHEMA
'type': 'array',
'items': {
'type': 'object',
'properties': {
'id': {'type': 'string', },
'name': {'type': 'string', },
},
'required': ['id', 'name', ],
'additionalProperties': False,
},
'minItems': 1,
}
properties['domain'] = { properties['domain'] = {
'type': 'object', 'type': 'object',
'required': ['id', 'name'], 'required': ['id', 'name'],
@ -151,7 +141,12 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
elif project_scoped: elif project_scoped:
properties['is_admin_project'] = {'type': 'boolean'} properties['is_admin_project'] = {'type': 'boolean'}
properties['catalog'] = {'type': 'array'} properties['catalog'] = {'type': 'array'}
properties['roles'] = {'type': 'array'} # FIXME(lbragstad): Remove this in favor of the predefined
# ROLES_SCHEMA dictionary once bug 1763510 is fixed.
ROLES_SCHEMA['items']['properties']['domain_id'] = {
'type': ['null', 'string', ],
}
properties['roles'] = ROLES_SCHEMA
properties['is_domain'] = {'type': 'boolean'} properties['is_domain'] = {'type': 'boolean'}
properties['project'] = { properties['project'] = {
'type': ['object'], 'type': ['object'],