def test_revoke_from_user_invalid_param(self): """ Test revoke permissions from user with missing required params. """ request = mock.MagicMock() request.body = json.dumps({'operations': ['READ'], 'resource': '/v2/some/'}) revoke = RevokeFromUserView() try: revoke.post(request) except MissingValue, response: self.assertEqual(response.http_status_code, 400) self.assertEqual(response.error_data['property_names'], ['login'])
def test_revoke_from_user(self, mock_factory, mock_resp): """ Test revoke permissions from user. """ request = mock.MagicMock() request.body = json.dumps( {'operations': ['READ'], 'login': '******', 'resource': '/v2/some/'}) mock_factory.permission_manager.return_value.revoke.return_value = None mock_factory.permission_manager.return_value.operation_names_to_values.return_value = [0] revoke = RevokeFromUserView() response = revoke.post(request) mock_resp.assert_called_once_with(None) self.assertTrue(response is mock_resp.return_value) mock_factory.permission_manager.return_value.revoke.assert_called_once_with( '/v2/some/', 'test', [0])
url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/$', ContentUnitResourceView.as_view(), name='content_unit_resource'), url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/pulp_user_metadata/$', ContentUnitUserMetadataResourceView.as_view(), name='content_unit_user_metadata_resource'), url(r'^v2/content/uploads/$', UploadsCollectionView.as_view(), name='content_uploads'), url(r'^v2/content/uploads/(?P<upload_id>[^/]+)/$', UploadResourceView.as_view(), name='content_upload_resource'), url(r'^v2/content/uploads/(?P<upload_id>[^/]+)/(?P<offset>[^/]+)/$', UploadSegmentResourceView.as_view(), name='content_upload_segment_resource'), url(r'^v2/events/$', EventView.as_view(), name='events'), url(r'^v2/events/(?P<event_listener_id>[^/]+)/$', EventResourceView.as_view(), name='event_resource'), url(r'^v2/permissions/$', PermissionView.as_view(), name='permissions'), url(r'^v2/permissions/actions/grant_to_role/$', GrantToRoleView.as_view(), name='grant_to_role'), url(r'^v2/permissions/actions/grant_to_user/$', GrantToUserView.as_view(), name='grant_to_user'), url(r'^v2/permissions/actions/revoke_from_role/$', RevokeFromRoleView.as_view(), name='revoke_from_role'), url(r'^v2/permissions/actions/revoke_from_user/$', RevokeFromUserView.as_view(), name='revoke_from_user'), url(r'^v2/plugins/distributors/$', DistributorsView.as_view(), name='plugin_distributors'), url(r'^v2/plugins/distributors/(?P<distributor_id>[^/]+)/$', DistributorResourceView.as_view(), name='plugin_distributor_resource'), url(r'^v2/plugins/importers/$', ImportersView.as_view(), name='plugin_importers'), url(r'^v2/plugins/importers/(?P<importer_id>[^/]+)/$', ImporterResourceView.as_view(), name='plugin_importer_resource'), url(r'^v2/plugins/types/$', TypesView.as_view(), name='plugin_types'), url(r'^v2/plugins/types/(?P<type_id>[^/]+)/$', TypeResourceView.as_view(), name='plugin_type_resource'), url(r'^v2/repo_groups/$', RepoGroupsView.as_view(), name='repo_groups'), url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/$', RepoGroupResourceView.as_view(), name='repo_group_resource'), url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/actions/associate/$', RepoGroupAssociateView.as_view(), name='repo_group_associate'), url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/actions/publish/$',
url(r'^v2/events/$', EventView.as_view(), name='events'), url(r'^v2/events/(?P<event_listener_id>[^/]+)/$', EventResourceView.as_view(), name='event_resource'), url(r'^v2/permissions/$', PermissionView.as_view(), name='permissions'), url(r'^v2/permissions/actions/grant_to_role/$', GrantToRoleView.as_view(), name='grant_to_role'), url(r'^v2/permissions/actions/grant_to_user/$', GrantToUserView.as_view(), name='grant_to_user'), url(r'^v2/permissions/actions/revoke_from_role/$', RevokeFromRoleView.as_view(), name='revoke_from_role'), url(r'^v2/permissions/actions/revoke_from_user/$', RevokeFromUserView.as_view(), name='revoke_from_user'), url(r'^v2/plugins/distributors/$', DistributorsView.as_view(), name='plugin_distributors'), url(r'^v2/plugins/distributors/(?P<distributor_id>[^/]+)/$', DistributorResourceView.as_view(), name='plugin_distributor_resource'), url(r'^v2/plugins/importers/$', ImportersView.as_view(), name='plugin_importers'), url(r'^v2/plugins/importers/(?P<importer_id>[^/]+)/$', ImporterResourceView.as_view(), name='plugin_importer_resource'), url(r'^v2/plugins/types/$', TypesView.as_view(), name='plugin_types'), url(r'^v2/plugins/types/(?P<type_id>[^/]+)/$',
url(r'^v2/content/units/(?P<type_id>[^/]+)/(?P<unit_id>[^/]+)/pulp_user_metadata/$', ContentUnitUserMetadataResourceView.as_view(), name='content_unit_user_metadata_resource'), url(r'^v2/content/uploads/$', UploadsCollectionView.as_view(), name='content_uploads'), url(r'^v2/content/uploads/(?P<upload_id>[^/]+)/$', UploadResourceView.as_view(), name='content_upload_resource'), url(r'^v2/content/uploads/(?P<upload_id>[^/]+)/(?P<offset>[^/]+)/$', UploadSegmentResourceView.as_view(), name='content_upload_segment_resource'), url(r'^v2/distributors/search/$', RepoDistributorsSearchView.as_view(), name='distributor_search'), url(r'^v2/events/$', EventView.as_view(), name='events'), url(r'^v2/events/(?P<event_listener_id>[^/]+)/$', EventResourceView.as_view(), name='event_resource'), url(r'^v2/permissions/$', PermissionView.as_view(), name='permissions'), url(r'^v2/permissions/actions/grant_to_role/$', GrantToRoleView.as_view(), name='grant_to_role'), url(r'^v2/permissions/actions/grant_to_user/$', GrantToUserView.as_view(), name='grant_to_user'), url(r'^v2/permissions/actions/revoke_from_role/$', RevokeFromRoleView.as_view(), name='revoke_from_role'), url(r'^v2/permissions/actions/revoke_from_user/$', RevokeFromUserView.as_view(), name='revoke_from_user'), url(r'^v2/plugins/distributors/$', DistributorsView.as_view(), name='plugin_distributors'), url(r'^v2/plugins/distributors/(?P<distributor_id>[^/]+)/$', DistributorResourceView.as_view(), name='plugin_distributor_resource'), url(r'^v2/plugins/importers/$', ImportersView.as_view(), name='plugin_importers'), url(r'^v2/plugins/importers/(?P<importer_id>[^/]+)/$', ImporterResourceView.as_view(), name='plugin_importer_resource'), url(r'^v2/plugins/types/$', TypesView.as_view(), name='plugin_types'), url(r'^v2/plugins/types/(?P<type_id>[^/]+)/$', TypeResourceView.as_view(), name='plugin_type_resource'), url(r'^v2/repo_groups/$', RepoGroupsView.as_view(), name='repo_groups'), url(r'^v2/repo_groups/search/$', RepoGroupSearch.as_view(), name='repo_group_search'), url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/$', RepoGroupResourceView.as_view(), name='repo_group_resource'), url(r'^v2/repo_groups/(?P<repo_group_id>[^/]+)/actions/associate/$', RepoGroupAssociateView.as_view(), name='repo_group_associate'),