diff --git a/pillar/__init__.py b/pillar/__init__.py index fc2e01d7..1fbd964a 100644 --- a/pillar/__init__.py +++ b/pillar/__init__.py @@ -19,7 +19,6 @@ import flask from flask import g, render_template, request from flask_babel import Babel, gettext as _ from flask.templating import TemplateNotFound -import pymongo.collection import pymongo.database from werkzeug.local import LocalProxy @@ -87,7 +86,7 @@ class PillarServer(BlinkerCompatibleEve): self._user_roles: typing.Set[str] = { 'demo', 'admin', 'subscriber', 'homeproject', 'protected', 'org-subscriber', 'video-encoder', - 'service', 'badger', 'svner', 'urler', + 'service', 'badger', 'svner', } self._user_roles_indexable: typing.Set[str] = {'demo', 'admin', 'subscriber'} diff --git a/pillar/api/service.py b/pillar/api/service.py index e97d043c..b5e571fe 100644 --- a/pillar/api/service.py +++ b/pillar/api/service.py @@ -3,7 +3,6 @@ import logging import typing -import bson import blinker import bson @@ -11,8 +10,7 @@ from flask import Blueprint, current_app, request from werkzeug import exceptions as wz_exceptions from pillar.api import local_auth -from pillar.api.utils import mongo -from pillar.api.utils import authorization, authentication, str2id, jsonify +from pillar.api.utils import authorization, authentication blueprint = Blueprint('service', __name__) log = logging.getLogger(__name__) @@ -159,19 +157,6 @@ def do_badger(action: str, *, return '', 204 -@blueprint.route('/urler/', methods=['GET']) -@authorization.require_login(require_roles={'service', 'urler'}, require_all=True) -def urler(project_id): - """Returns the URL of any project.""" - - project_id = str2id(project_id) - project = mongo.find_one_or_404('projects', project_id, - projection={'url': 1}) - return jsonify({ - '_id': project_id, - 'url': project['url']}) - - def manage_user_group_membership(db_user, role, action): """Some roles have associated groups; this function maintains group & role membership. diff --git a/pillar/cli/setup.py b/pillar/cli/setup.py index ada719ce..4b6d9927 100644 --- a/pillar/cli/setup.py +++ b/pillar/cli/setup.py @@ -65,13 +65,6 @@ def create_badger_account(email, badges): create_service_account(email, ['badger'], {'badger': badges.strip().split()}) -@manager_setup.command -def create_urler_account(email): - """Creates a new service account that can fetch all project URLs.""" - - create_service_account(email, ['urler'], {}) - - @manager_setup.command def create_local_user_account(email, password): from pillar.api.local_auth import create_local_user diff --git a/pillar/config.py b/pillar/config.py index 479471a5..30726d4e 100644 --- a/pillar/config.py +++ b/pillar/config.py @@ -183,11 +183,6 @@ GIT = 'git' RENDER_HOME_AS_REGULAR_PROJECT = False -# Authentication token for the Urler service. If None, defaults -# to the authentication token of the current user. -URLER_SERVICE_AUTH_TOKEN = None - - # Blender Cloud add-on version. This updates the value in all places in the # front-end. BLENDER_CLOUD_ADDON_VERSION = '1.4' diff --git a/pillar/tests/config_testing.py b/pillar/tests/config_testing.py index 04555821..34d7c017 100644 --- a/pillar/tests/config_testing.py +++ b/pillar/tests/config_testing.py @@ -5,6 +5,8 @@ BLENDER_ID_ENDPOINT = 'http://127.0.0.1:8001' # nonexistant server, no trailing SERVER_NAME = 'localhost' PILLAR_SERVER_ENDPOINT = 'http://localhost/api/' +MAIN_PROJECT_ID = '5672beecc0261b2005ed1a33' + DEBUG = False TESTING = True diff --git a/tests/test_web/test_jstree.py b/tests/test_web/test_jstree.py index 49368748..a0a73b96 100644 --- a/tests/test_web/test_jstree.py +++ b/tests/test_web/test_jstree.py @@ -9,6 +9,10 @@ from pillar.tests import AbstractPillarTest class JSTreeTest(AbstractPillarTest): + def setUp(self, **kwargs): + super().setUp(**kwargs) + self.project_id, self.project = self.ensure_project_exists() + def test_jstree_parse_node(self): from pillar.web.utils.jstree import jstree_parse_node @@ -19,7 +23,7 @@ class JSTreeTest(AbstractPillarTest): 'picture': ObjectId('55f338f92beb3300c4ff99de'), 'description': 'Play the full movie and see how it was cobbled together.', 'parent': ObjectId('55f338f92beb3300c4ff99f9'), - 'project': ObjectId('55f338f92beb3300c4ff99e5'), + 'project': self.project_id, 'node_type': 'asset', 'user': ObjectId('552b066b41acdf5dec4436f2'), 'properties': {'status': 'published', @@ -27,14 +31,12 @@ class JSTreeTest(AbstractPillarTest): 'content_type': 'file'}, 'name': 'Live Edit'} - # Mocking url_for_node prevents us from setting up a project and an URLer service. - with mock.patch('pillar.web.nodes.routes.url_for_node') as mock_url_for_node: - mock_url_for_node.return_value = '/the/url' + with self.app.test_request_context(): parsed = jstree_parse_node(Node(node_doc)) self.assertEqual(parsed, { 'id': 'n_55f338f92beb3300c4ff99fe', - 'a_attr': {'href': '/the/url'}, + 'a_attr': {'href': f"/p/{self.project['url']}/55f338f92beb3300c4ff99fe"}, 'li_attr': {'data-node-type': 'asset'}, 'text': Markup('Live <strong>Edit</strong>'), 'type': 'file', @@ -52,7 +54,7 @@ class JSTreeTest(AbstractPillarTest): 'picture': ObjectId('55f338f92beb3300c4ff99de'), 'description': 'Play the full movie and see how it was cobbled together.', 'parent': ObjectId('55f338f92beb3300c4ff99f9'), - 'project': ObjectId('55f338f92beb3300c4ff99e5'), + 'project': self.project_id, 'node_type': 'blog', 'user': ObjectId('552b066b41acdf5dec4436f2'), 'properties': {'status': 'published', @@ -60,14 +62,12 @@ class JSTreeTest(AbstractPillarTest): 'content_type': 'file'}, 'name': 'Live Edit'} - # Mocking url_for_node prevents us from setting up a project and an URLer service. - with mock.patch('pillar.web.nodes.routes.url_for_node') as mock_url_for_node: - mock_url_for_node.return_value = '/the/url' + with self.app.test_request_context(): parsed = jstree_parse_node(Node(node_doc)) self.assertEqual(parsed, { 'id': 'n_55f338f92beb3300c4ff99fe', - 'a_attr': {'href': '/the/url'}, + 'a_attr': {'href': '/blog/'}, 'li_attr': {'data-node-type': 'blog'}, 'text': Markup('Live <strong>Edit</strong>'), 'type': 'blog', @@ -82,19 +82,17 @@ class JSTreeTest(AbstractPillarTest): '_created': parse('2015-09-11T22:26:33.000+0200'), '_updated': parse('2015-10-30T22:44:27.000+0100'), '_etag': '5248485b4ea7e55e858ff84b1bd4aae88917a37c', - 'project': ObjectId('55f338f92beb3300c4ff99e5'), + 'project': self.project_id, 'node_type': 'asset', 'user': ObjectId('552b066b41acdf5dec4436f2'), 'name': 'Live Edit'} - # Mocking url_for_node prevents us from setting up a project and an URLer service. - with mock.patch('pillar.web.nodes.routes.url_for_node') as mock_url_for_node: - mock_url_for_node.return_value = '/the/url' + with self.app.test_request_context(): parsed = jstree_parse_node(Node(node_doc)) self.assertEqual(parsed, { 'id': 'n_55f338f92beb3300c4ff99fe', - 'a_attr': {'href': '/the/url'}, + 'a_attr': {'href': f"/p/{self.project['url']}/55f338f92beb3300c4ff99fe"}, 'li_attr': {'data-node-type': 'asset'}, 'text': Markup('Live <strong>Edit</strong>'), 'type': 'asset',