Skip to content

Commit a1ed24b

Browse files
committed
[api] Fix slack API disabling all other URLs
1 parent fad2ae1 commit a1ed24b

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Licensed to Cloudera, Inc. under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. Cloudera, Inc. licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
from nose.tools import assert_true, assert_false, assert_equal, assert_not_equal, assert_raises
20+
from django.urls import reverse
21+
22+
from desktop.lib.django_test_util import make_logged_in_client
23+
from desktop.lib.test_utils import grant_access
24+
25+
from useradmin.models import User
26+
27+
28+
class TestEditorApi():
29+
30+
def setUp(self):
31+
self.client = make_logged_in_client(username="api_user", recreate=True, is_superuser=False)
32+
self.client_not_me = make_logged_in_client(username="not_api_user", recreate=True, is_superuser=False)
33+
34+
self.user = User.objects.get(username="api_user")
35+
self.user_not_me = User.objects.get(username="not_api_user")
36+
37+
grant_access(self.user.username, self.user.username, "desktop")
38+
grant_access(self.user_not_me.username, self.user_not_me.username, "desktop")
39+
40+
def test_urls_exist(self):
41+
assert_equal(reverse('api:editor_execute', args=['hive']), '/api/editor/execute/hive')

desktop/core/src/desktop/api_public_urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
re_path(r'^editor/create_notebook/?$', api_public.create_notebook, name='api_create_notebook'),
4343
re_path(r'^editor/create_session/?$', api_public.create_session, name='api_create_session'),
4444
re_path(r'^editor/close_session/?$', api_public.close_session, name='api_close_session'),
45-
re_path(r'^editor/execute(?:/(?P<dialect>.+))?/?$', api_public.execute, name='api_execute'),
45+
re_path(r'^editor/execute(?:/(?P<dialect>.+))?/?$', api_public.execute, name='editor_execute'),
4646
re_path(r'^editor/check_status/?$', api_public.check_status, name='api_check_status'),
4747
re_path(r'^editor/fetch_result_data/?$', api_public.fetch_result_data, name='api_fetch_result_data'),
4848
re_path(r'^editor/fetch_result_metadata/?$', api_public.fetch_result_metadata, name='api_fetch_result_metadata'),
@@ -75,6 +75,6 @@
7575
]
7676

7777
# Slack install API for using CORS by default
78-
urlpatterns = [
78+
urlpatterns += [
7979
re_path(r'^slack/install/?$', botserver_api.generate_slack_install_link, name='botserver.api.slack_install_link'),
8080
]

desktop/core/src/desktop/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
re_path('^api/token/verify/?$', TokenVerifyView.as_view(), name='token_verify'),
213213
re_path('^api/token/refresh/?$', TokenRefreshView.as_view(), name='token_refresh'),
214214

215-
re_path(r'^api/', include('desktop.api_public_urls')),
215+
re_path(r'^api/', include(('desktop.api_public_urls', 'api'), 'api')),
216216
]
217217

218218
dynamic_patterns += [

0 commit comments

Comments
 (0)