Example #1
0
    def test__verify_resource_permission_owner(self, mock_gro, mock_authorize,
                                               mock_is_resource_admin):

        OffersController._verify_resource_permission(
            owner_ctx.to_policy_values(), test_offer.to_dict())

        mock_gro.assert_called_once_with(test_offer.resource_type,
                                         test_offer.resource_uuid)
        mock_is_resource_admin.assert_called_once_with(test_offer.project_id)
        assert not mock_authorize.called
Example #2
0
    def test__verify_resource_permission_admin(self, mock_gro, mock_authorize,
                                               mock_is_resource_admin):

        bad_test_offer = offer.Offer(resource_type='test_node',
                                     resource_uuid=test_node_2._uuid,
                                     project_id=owner_ctx.project_id)

        assert OffersController._verify_resource_permission(
            admin_ctx.to_policy_values(), bad_test_offer.to_dict()) is None

        mock_gro.assert_called_once_with(bad_test_offer.resource_type,
                                         bad_test_offer.resource_uuid)
        mock_is_resource_admin.assert_called_once_with(
            bad_test_offer.project_id)
        mock_authorize.assert_called_once_with('esi_leap:offer:offer_admin',
                                               admin_ctx.to_policy_values(),
                                               admin_ctx.to_policy_values())