Commit 103a44be authored by Stevan Radakovic's avatar Stevan Radakovic
Browse files

LAVA-876 - Remove access to Dashboard

Remove all entries from urls.py in dashboard_app.
Remove some of the obsolete tests.
Remove some of the code so that rest of the server works ok.

Change-Id: I74f79f5ce02c4af00416e57299cbe2782fad7ddb
parent 9e904a18
......@@ -3,33 +3,8 @@
{% block content %}
<h1 class="modal-header">Welcome</h1>
<p>The <em>Validation Dashboard</em> is your window to
test results, regardless of how your run your tests you
can upload the results here and analyze them with simple
built-in views. Additionally, you can export data view
the <a href="{% url 'lava.api_help' %}">XML-RPC API</a>
to build your own customized reports.</p>
<h2 class="modal-header">Getting Started</h2>
<p>The dashboard stores results of tests in <em>bundles</em>. These
bundles are then grouped by a thing called <em>bundle streams</em>.
You can drill down by viewing the
<a href="{% url 'lava_dashboard_bundle_stream_list' %}">bundle stream list</a>.
However, that view can present too much data.</p>
<p>There are two good ways to limit the data in order to see the
results you are interested in</p>
<h3 class="modal-header">Filters</h3>
<p><a href="{% url 'lava_dashboard_filters_list' %}">Filters</a>
allow you to create your own list of criteria for what you'd like to look at.
These can be created as "public" so others can use them, or private so only
you can see them.</p>
<h3 class="modal-header">Image Reports</h3>
<p><a href="{% url 'lava_dashboard_image_report_list' %}">Image Reports</a>
are a feature built on top of filters, that allow a nice view of daily jobs
that are being run in LAVA.</p>
<p>The <em>Validation Dashboard</em> is now deprecated.
Plese use <a href="{% url 'lava_results' %}">V2 results</a>
for reviewing LAVA results.</p>
{% endblock %}
......@@ -23,10 +23,6 @@ TEST_MODULES = [
'other.test_deserialization',
'other.test_client',
'regressions.test_LP658917',
'views.test_bundle_stream_list_view',
'views.test_run_detail_view',
'views.test_run_list_view',
'views.test_redirects',
]
......
......@@ -127,23 +127,6 @@ class DashboardAPIBundlesTests(DashboardXMLRPCViewsTestCase):
}),
]
def test_bundles(self):
"""
Make a bunch of bundles (all in a public branch) and check that
they are returned by the XML-RPC request.
"""
with fixtures.created_bundle_streams(self.bundle_streams), fixtures.created_bundles(self.bundles):
results = self.xml_rpc_call('bundles', self.query)
self.assertEqual(len(results), len(self.expected_results))
with fixtures.test_loop(zip(results, self.expected_results)) as loop_items:
for result, expected_result in loop_items:
self.assertEqual(
result['content_filename'],
expected_result['content_filename'])
self.assertEqual(
result['content_sha1'],
expected_result['content_sha1'])
class DashboardAPIBundlesFailureTests(DashboardXMLRPCViewsTestCase):
......
# Copyright (C) 2010 Linaro Limited
#
# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
#
# This file is part of Lava Dashboard.
#
# Lava Dashboard is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License version 3
# as published by the Free Software Foundation
#
# Lava Dashboard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Lava Dashboard. If not, see <http://www.gnu.org/licenses/>.
"""
Unit tests for dashboard_app.views.bundle_stream_list
"""
import unittest
import django
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from dashboard_app.views import bundle_stream_list
from dashboard_app.tests import fixtures
from dashboard_app.tests.utils import (
DashboardViewsTestCase,
TestClient,
django_version_after,
)
# pylint: disable=too-many-ancestors,no-member,invalid-name
def django_message():
return 'django %s is too new for this V1 test.' % django.get_version()
class BundleStreamListViewAnonymousTest(DashboardViewsTestCase):
scenarios = [
('empty', {
'bundle_streams': [],
}),
('public_streams', {
'bundle_streams': [
'/anonymous/',
'/anonymous/name/',
'/public/personal/user/',
'/public/personal/user/name/',
'/public/team/group/',
'/public/team/group/name/',
]
}),
('private_streams', {
'bundle_streams': [
'/private/personal/user/',
'/private/personal/user/name/',
'/private/team/group/',
'/private/team/group/name/',
]
}),
]
def setUp(self):
super(BundleStreamListViewAnonymousTest, self).setUp()
self.url = reverse(bundle_stream_list)
self.user = None
def test_status_code(self):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
def test_template_used(self):
response = self.client.get(self.url)
self.assertTemplateUsed(response,
"dashboard_app/bundle_stream_list.html")
@unittest.skipIf(django_version_after(django.get_version(), '1.11'), django_message())
def test_listed_bundles_are_the_ones_we_should_see(self):
with fixtures.created_bundle_streams(self.bundle_streams) as bundle_streams:
response = self.client.get(self.url)
expected_bsl = sorted(
[bundle_stream.pk for bundle_stream in
bundle_streams if
bundle_stream.is_accessible_by(self.user)])
effective_bsl = sorted(
[bundle_stream.pk for bundle_stream in
response.context['bundle_stream_table'].data.queryset])
self.assertEqual(effective_bsl, expected_bsl)
class BundleStreamListViewAuthorizedTest(BundleStreamListViewAnonymousTest):
def setUp(self):
super(BundleStreamListViewAuthorizedTest, self).setUp()
self.client = TestClient()
self.user = User.objects.create(username='user')
self.user.groups.create(name='group')
self.client.login_user(self.user)
# Copyright (C) 2010 Linaro Limited
#
# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
#
# This file is part of Lava Dashboard.
#
# Lava Dashboard is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License version 3
# as published by the Free Software Foundation
#
# Lava Dashboard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Lava Dashboard. If not, see <http://www.gnu.org/licenses/>.
from django.core.urlresolvers import reverse
from django_testscenarios.ubertest import TestCase
from dashboard_app.tests import fixtures
# pylint: disable=too-many-ancestors,invalid-name
class RedirectTests(TestCase):
_PATHNAME = "/anonymous/"
_BUNDLE_TEXT = """
{
"test_runs": [
{
"test_results": [
{
"test_case_id": "test-case-0",
"result": "pass"
}
],
"analyzer_assigned_date": "2010-10-15T22:04:46Z",
"time_check_performed": false,
"analyzer_assigned_uuid": "00000000-0000-0000-0000-000000000001",
"test_id": "examples"
}
],
"format": "Dashboard Bundle Format 1.0"
}
"""
_BUNDLE_NAME = "whatever.json"
def setUp(self):
super(RedirectTests, self).setUp()
self.bundle = fixtures.create_bundle(self._PATHNAME, self._BUNDLE_TEXT, self._BUNDLE_NAME)
self.bundle.deserialize()
self.assertTrue(self.bundle.is_deserialized)
if not hasattr(self, 'client') and hasattr(self, 'client_class'):
self.client = self.client_class()
def test_bundle_permalink(self):
response = self.client.get(
reverse("lava_dashboard_redirect_to_bundle",
args=(self.bundle.content_sha1, )))
self.assertRedirects(response, self.bundle.get_absolute_url())
self.bundle.delete()
def test_bundle_permalink_trailing(self):
response = self.client.get(
reverse("lava_dashboard_redirect_to_bundle_trailing",
args=(self.bundle.content_sha1, 'trailing/')))
self.assertRedirects(
response, self.bundle.get_absolute_url() + 'trailing/',
target_status_code=404)
self.bundle.delete()
def test_bundle_permalink_query_string(self):
response = self.client.get(
reverse("lava_dashboard_redirect_to_bundle",
args=(self.bundle.content_sha1, )), data={'foo': 'bar'})
self.assertRedirects(
response, self.bundle.get_absolute_url() + '?foo=bar')
self.bundle.delete()
def test_test_run_permalink(self):
test_run = self.bundle.test_runs.all()[0]
response = self.client.get(
reverse("lava_dashboard_redirect_to_test_run",
args=(test_run.analyzer_assigned_uuid, )))
self.assertRedirects(response, test_run.get_absolute_url())
self.bundle.delete()
def test_test_run_permalink_trailing(self):
test_run = self.bundle.test_runs.all()[0]
response = self.client.get(
reverse("lava_dashboard_redirect_to_test_run_trailing",
args=(test_run.analyzer_assigned_uuid, 'trailing/')))
self.assertRedirects(
response, test_run.get_absolute_url() + 'trailing/',
target_status_code=404)
self.bundle.delete()
def test_test_run_permalink_query_string(self):
test_run = self.bundle.test_runs.all()[0]
response = self.client.get(
reverse("lava_dashboard_redirect_to_test_run",
args=(test_run.analyzer_assigned_uuid, )),
data={'foo': 'bar'})
self.assertRedirects(
response, test_run.get_absolute_url() + '?foo=bar')
self.bundle.delete()
def test_test_result_permalink(self):
test_run = self.bundle.test_runs.all()[0]
test_result = test_run.test_results.all()[0]
response = self.client.get(
reverse("lava_dashboard_redirect_to_test_result",
args=(test_run.analyzer_assigned_uuid,
test_result.relative_index)))
self.assertRedirects(response, test_result.get_absolute_url())
self.bundle.delete()
def test_test_result_permalink_trailing(self):
test_run = self.bundle.test_runs.all()[0]
test_result = test_run.test_results.all()[0]
response = self.client.get(
reverse("lava_dashboard_redirect_to_test_result_trailing",
args=(test_run.analyzer_assigned_uuid,
test_result.relative_index, 'trailing/')))
self.assertRedirects(
response, test_result.get_absolute_url() + 'trailing/',
target_status_code=404)
self.bundle.delete()
def test_test_result_permalink_query_string(self):
test_run = self.bundle.test_runs.all()[0]
test_result = test_run.test_results.all()[0]
response = self.client.get(
reverse("lava_dashboard_redirect_to_test_result",
args=(test_run.analyzer_assigned_uuid,
test_result.relative_index)),
data={'foo': 'bar'})
self.assertRedirects(
response, test_result.get_absolute_url() + '?foo=bar')
self.bundle.delete()
# Copyright (C) 2010 Linaro Limited
#
# Author: Deepti B. Kalakeri<deepti.kalakeri@linaro.org>
#
# This file is part of Lava Dashboard.
#
# Lava Dashboard is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License version 3
# as published by the Free Software Foundation
#
# Lava Dashboard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Lava Dashboard. If not, see <http://www.gnu.org/licenses/>.
from django.http import HttpResponseForbidden, HttpResponse
from django_testscenarios.ubertest import (TestCase, TestCaseWithScenarios)
from dashboard_app.models import BundleStream, TestRun
from django.contrib.auth.models import (User, Group)
from dashboard_app.tests.utils import TestClient
# pylint: disable=too-many-ancestors,no-member
class TestRunDetailView(TestCase):
fixtures = ["test_run_detail.json"]
def setUp(self):
super(TestRunDetailView, self).setUp()
self.test_run_url = TestRun.objects.get(pk=1).get_absolute_url()
if not hasattr(self, 'client') and hasattr(self, 'client_class'):
self.client = self.client_class()
def testrun_valid_page_view(self):
response = self.client.get(self.test_run_url)
self.assertEqual(response.status_code, 200)
def test_template_used(self):
response = self.client.get(self.test_run_url)
self.assertTemplateUsed(response,
"dashboard_app/test_run_detail.html")
# def testrun_invalid_page_view(self):
# invalid_uuid = "0000000-0000-0000-0000-000000000000"
# invalid_test_run_url = reverse("lava_dashboard_test_run_detail",
# args=[invalid_uuid])
# response = self.client.get(invalid_test_run_url)
# self.assertEqual(response.status_code, 404)
class TestRunViewAuth(TestCaseWithScenarios):
_USER = "private_owner"
_GROUP = "private_group"
_UNRELATED_USER = "unrelated-user"
fixtures = ["test_run_detail.json"]
accessing_user = None
scenarios = [
("anonymous_accessing_private", {
"accessing_user": None,
"resource_owner": _USER
}),
("anonymous_accessing_shared", {
"accessing_user": None,
"resource_owner": _GROUP
}),
("unrelated_accessing_private", {
"accessing_user": _UNRELATED_USER,
"resource_owner": _USER,
}),
("unrelated_accessing_shared", {
"accessing_user": _UNRELATED_USER,
"resource_owner": _GROUP
}),
]
def setUp(self):
super(TestRunViewAuth, self).setUp()
self.test_run_url = TestRun.objects.get(pk=1).get_absolute_url()
# Set resource ownership to group or user
bundle_stream = BundleStream.objects.get(pk=1)
if self.resource_owner == self._GROUP:
bundle_stream.group = Group.objects.create(name=self._USER)
elif self.resource_owner == self._USER:
bundle_stream.user = User.objects.create(username=self._USER)
bundle_stream.is_public = False
bundle_stream.is_anonymous = False
bundle_stream.save()
if self.accessing_user:
self.accessing_user = User.objects.get_or_create(username=self.accessing_user)[0]
self.client = TestClient()
self.client.login_user(self.accessing_user)
def test_run_unauth_access(self):
"""
The status code can vary by the installed dependencies but the
content of the response is the same.
"""
response = self.client.get(self.test_run_url)
self.assertIsInstance(response, HttpResponseForbidden)
# Copyright (C) 2010 Linaro Limited
#
# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
#
# This file is part of Lava Dashboard.
#
# Lava Dashboard is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License version 3
# as published by the Free Software Foundation
#
# Lava Dashboard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Lava Dashboard. If not, see <http://www.gnu.org/licenses/>.
"""
Unit tests for dashboard_app.views.test_run_list
"""
import unittest
from django.http import HttpResponseForbidden, HttpResponse
from django.contrib.auth.models import User, Group
from django.core.urlresolvers import reverse
from django_testscenarios.ubertest import TestCaseWithScenarios
from dashboard_app.tests import fixtures
from dashboard_app.tests.utils import TestClient
# pylint: disable=too-many-ancestors,no-member
class TestRunListViewAnonymousTest(TestCaseWithScenarios):
scenarios = [
('anonymous_stream', {
'pathname': '/anonymous/',
}),
('anonymous_named_stream', {
'pathname': '/anonymous/name/',
}),
('public_personal_stream', {
'pathname': '/public/personal/user/',
}),
('public_personal_named_stream', {
'pathname': '/public/personal/user/name/',
}),
('public_team_stream', {
'pathname': '/public/team/group/',
}),
('public_team_named_stream', {
'pathname': '/public/team/group/name/',
}),
('private_personal_stream', {
'pathname': '/private/personal/user/',
}),
('private_personal_named_stream', {
'pathname': '/private/personal/user/name/',
}),
('private_team_stream', {
'pathname': '/private/team/group/',
}),
('private_team_named_stream', {
'pathname': '/private/team/group/name/',
}),
]
def setUp(self):
super(TestRunListViewAnonymousTest, self).setUp()
self.bundle_stream = fixtures.create_bundle_stream(self.pathname)
self.user = None
self.url = reverse("lava_dashboard_test_run_list", args=[self.bundle_stream.pathname])
def test_status_code(self):
response = self.client.get(self.url)
if self.bundle_stream.is_accessible_by(self.user):
self.assertEqual(response.status_code, 200)
else:
self.assertIsInstance(response, HttpResponseForbidden)
def test_template_used(self):
response = self.client.get(self.url)
if self.bundle_stream.is_accessible_by(self.user):
self.assertTemplateUsed(response,
"dashboard_app/test_run_list.html")
else:
self.assertIsInstance(response, HttpResponseForbidden)
class TestRunListViewAuthorizedTest(TestRunListViewAnonymousTest):
def setUp(self):
super(TestRunListViewAuthorizedTest, self).setUp()
self.client = TestClient()
self.user = User.objects.get_or_create(username="user")[0]
self.group = Group.objects.get_or_create(name="group")[0]
self.user.groups.add(self.group)
self.client.login_user(self.user)
......@@ -118,109 +118,4 @@ from dashboard_app.views import (
urlpatterns = [
url(r'^$', index, name='lava_dashboard'),
url(r'^filters/$', filters_list, name='lava_dashboard_filters_list'),
url(r'^filters/filters_names_json$', filter_name_list_json, name='filter_name_list_json'),
url(r'^filters/\+add-cases-for-test-json$', filter_add_cases_for_test_json,
name='dashboard_app.views.filters.views.filter_add_cases_for_test_json'),
url(r'^filters/\+get-tests-json$', get_tests_json),
url(r'^filters/\+get-test-cases-json$', get_test_cases_json),
url(r'^filters/\+attribute-name-completion-json$', filter_attr_name_completion_json,
name='dashboard_app.views.filters.views.filter_attr_name_completion_json'),
url(r'^filters/\+attribute-value-completion-json$', filter_attr_value_completion_json,
name='dashboard_app.views.filters.views.filter_attr_value_completion_json'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)$', filter_detail,
name='dashboard_app.views.filters.views.filter_detail'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+subscribe$', filter_subscribe,
name='dashboard_app.views.filters.views.filter_subscribe'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+delete$', filter_delete,
name='dashboard_app.views.filters.views.filter_delete'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+compare/(?P<tag1>[a-zA-Z0-9-_: .+]+)/(?P<tag2>[a-zA-Z0-9-_: .+]+)$',
compare_matches),
url(r'^my-subscriptions$', my_subscriptions, name='lava_dashboard_my_subscriptions'),
url(r'^streams/$', bundle_stream_list, name="lava_dashboard_bundle_stream_list"),
url(r'^streams/mybundlestreams$', mybundlestreams, name='lava_dashboard_mybundlestreams'),
url(r'^streams/bundlestreams-json$', bundlestreams_json),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/$', bundle_list, name='lava_dashboard_bundle_list'),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/+export$', bundle_list_export,
name='lava_dashboard_bundle_list_export'),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/$', bundle_detail,
name='lava_dashboard_bundle_detail'),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/+export$', bundle_export,
name='lava_dashboard_bundle_export'),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/json$', bundle_json),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/$',
test_run_detail, name='lava_dashboard_test_run_detail'),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/+export$',
test_run_export, name='lava_dashboard_test_run_export'),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/\+update-testrun-attribute$',
test_run_update_attribute),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/\+remove-testrun-attribute$',
test_run_remove_attribute),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/result/(?P<relative_index>[0-9]+)/$',
test_result_detail, name='lava_dashboard_test_result_detail'),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/result/(?P<relative_index>[0-9]+)/\+update-comments$',
test_result_update_comments),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/result/(?P<relative_index>[0-9]+)/\+update-units$',
test_result_update_units),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/result/(?P<relative_index>[0-9]+)/\+update-result-attribute$',
test_result_update_attribute),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/result/(?P<relative_index>[0-9]+)/\+remove-result-attribute$',