Merge "Bump network rev on RBAC change"

This commit is contained in:
Jenkins 2017-08-03 21:53:39 +00:00 committed by Gerrit Code Review
commit 8f79a92e45
3 changed files with 19 additions and 1 deletions

View File

@ -262,7 +262,9 @@ class Network(standard_attr.HasStandardAttributes, model_base.BASEV2,
admin_state_up = sa.Column(sa.Boolean) admin_state_up = sa.Column(sa.Boolean)
vlan_transparent = sa.Column(sa.Boolean, nullable=True) vlan_transparent = sa.Column(sa.Boolean, nullable=True)
rbac_entries = orm.relationship(rbac_db_models.NetworkRBAC, rbac_entries = orm.relationship(rbac_db_models.NetworkRBAC,
backref='network', lazy='subquery', backref=orm.backref('network',
load_on_pending=True),
lazy='subquery',
cascade='all, delete, delete-orphan') cascade='all, delete, delete-orphan')
availability_zone_hints = sa.Column(sa.String(255)) availability_zone_hints = sa.Column(sa.String(255))
dhcp_agents = orm.relationship( dhcp_agents = orm.relationship(

View File

@ -94,6 +94,7 @@ class NetworkRBAC(RBACColumns, model_base.BASEV2):
object_id = _object_id_column('networks.id') object_id = _object_id_column('networks.id')
object_type = 'network' object_type = 'network'
revises_on_change = ('network', )
def get_valid_actions(self): def get_valid_actions(self):
actions = (ACCESS_SHARED,) actions = (ACCESS_SHARED,)

View File

@ -423,6 +423,21 @@ class RBACSharedNetworksTest(base.BaseAdminNetworkTest):
target_tenant=self.client2.tenant_id) target_tenant=self.client2.tenant_id)
self.client.delete_port(port['id']) self.client.delete_port(port['id'])
@test.requires_ext(extension="standard-attr-revisions", service="network")
@decorators.idempotent_id('86c3529b-1231-40de-1234-89664291a4cb')
def test_rbac_bumps_network_revision(self):
resp = self._make_admin_net_and_subnet_shared_to_tenant_id(
self.client.tenant_id)
net_id = resp['network']['id']
rev = self.client.show_network(net_id)['network']['revision_number']
self.admin_client.create_rbac_policy(
object_type='network', object_id=net_id,
action='access_as_shared', target_tenant='*')
self.assertGreater(
self.client.show_network(net_id)['network']['revision_number'],
rev
)
@decorators.idempotent_id('86c3529b-1231-40de-803c-aeeeeeee7fff') @decorators.idempotent_id('86c3529b-1231-40de-803c-aeeeeeee7fff')
def test_filtering_works_with_rbac_records_present(self): def test_filtering_works_with_rbac_records_present(self):
resp = self._make_admin_net_and_subnet_shared_to_tenant_id( resp = self._make_admin_net_and_subnet_shared_to_tenant_id(