Commit Graph

22 Commits

Author SHA1 Message Date
Akihiro Motoki 493a943e6e horizon: Move test files to match corresponding module structure
blueprint relocation-test-codes

The current test file structure in horizon looks random.
This is the first patch of blueprint relocation-test-codes.

This commit proposes to change the structure to match the structure
of test targets (i.e., main codes).
More concretely, a unit test file for {TOP_MODULE}/{MODULE}/{FILENAME}.py
will be located at {TOP_MODULE}/test/units/{MODULE}/test_{FILENAME}.py.
When a module is test as a whole, a location of a corresponding test file
will be {TOP_MODULE}/test/units/{MODULE}/test_{MODULE}.py.
This clarifies locations of test files.

In addition, this commit changes the base class of utils.test_secret_key
from horizon.test.helper.TestCase to unittest.TestCase. This is because
calling secret_key.generate_key() somehow interferes django.test.TestCase
(which is a parent class of horizon.test.helper.TestCase).

Change-Id: I48b9c317645e63a5819c52512b30f25969574817
2017-12-09 21:37:12 +09:00
Ivan Kolodyazhny 8f4e02c96d Show NotAuthorized error message on a separate page
Change-Id: I02d9d610a0e5feff7da14f86d003ec21010ab26a
Closes-Bug: #1709077
2017-08-29 16:37:04 +03:00
Itxaka 70f074e7cb
Fix operation_log middleware tests
There seems to be a couple of errors on the operation_log
middleware tests that were being ignored on the tests
runnners.

On the first we were trying to access a local var from the
OperationLogMiddleware class to compare the default log
format. This is fixed by making it an attribute instead.

The second one was an icorrect use of the delattr function
as it was used as part of the request object, while its a
standalone function.

Change-Id: Ib05cfd1d6acb940a40c8bb1d1bdf3cdf837a0454
2017-07-05 15:49:11 +02:00
Mateusz Kowalski e38f75a6c8 operation_log: Fix wrong reference to ignored urls
Fixes typo in a previous patch where underscore in front
of variable name was ommited.

Change-Id: I050148607bb0016cc4d4c5852784671ad994a078
Closes-Bug: #1688206
2017-06-27 16:43:23 +02:00
Akihiro Motoki 61091388e9 hacking: noqa cleanup in horizon
attribute-level imports are not checked by hacking module now.
most noqa is used to disable warnings on attribute-level imports.
This commit drops noqa for this purpose.

After this, there are 8 noqa under horizon/ :)

In addition to this, the following changes are made.

horizon/exceptions.py: The following imports are dropped.
They are not used anywhere.
  from django.http import HttpRequest
  from django.views.debug import CLEANSED_SUBSTITUTE

horizon/forms/__init__.py:
Some entries were missing in __all__. They are added.

Change-Id: I33b504ef6c396f0675e8a340867e2ca59c77c684
2017-03-17 19:38:47 +00:00
Bin Zhou 9afd7d0875 Modify use of assertTrue(A in B)
Developers should use assertIn(A, B) instead of assertTrue(A in B ).

TrivialFix

Change-Id: I93f3c540e4cc9015162283ea71813613a13e3555
2016-09-03 11:26:52 +08:00
Pablo Iranzo Gómez 9d05c25bf2
Fix typo 'occured' -> 'occurred'
Change-Id: Iee8c45584af36231602e9f94db32cb2a3d0bca9f
2016-06-28 18:37:10 +02:00
Kenji Ishii 5a9c4b0c28 Add feature to log operations of users to Horizon
To enable this feature, you can see the
/doc/source/topics/settings.rst on this patch.

Change-Id: I784b92104be244f7f288d7648c20e61e0a0c1d09
Implements: blueprint operation-history-log
2016-05-31 10:34:08 +00:00
Rob Cresswell fd92d8ec59 Fix remaining Django 1.9 test failures
This patch gets Horizon to a passing state in the Django 1.9 tests

Co-Authored-By: Itxaka <iserrano@redhat.com>
Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com>
Change-Id: Icbc1a3c039de658faa9fba4a2cdd5027345fe94d
Partially-Implements: blueprint drop-dj17
2016-04-09 11:13:16 +00:00
Yves-Gwenael Bourhis 9749d873a6 Fixing timezone awareness
Putting back timezone awareness in the middleware which was accidently removed
by https://review.openstack.org/#/c/179513/

Change-Id: I01424dee71e778969d97cbb38899d898e01177fa
Closes-bug: #1538189
2016-01-26 17:07:26 +01:00
eric b676ac13fa Removing last_activity session flag
This change will simplify horizon session management and lesson
the load on session backends which currently are writing records
with every page request.

Pre-Requisite change: https://review.openstack.org/#/c/179800/

Change-Id: I3ff8ca6b56655c7c68743398fee903d651332867
Closes-bug: #1450914
2015-10-05 04:48:17 +00:00
Akihiro Motoki c228358258 Fix E127 errors in horizon/
E127 continuation line over-indented for visual indent

Partial-Bug: #1375931
Change-Id: Ib9ae85a767a85a360e5a720d8392a20069a8c873
2014-10-01 19:49:41 +09:00
Yves-Gwenael Bourhis 4824239730 Checking session timeout before authentication
If both the keystone token and the session expired, the user was asked to login
twice. This is because the token expiration was not checked.
When a user had timed out both in session and keystone token validity, the user
was asked to log in, then the timestamp was checked, and the user logged out
again and asked to log in a second time.

We now check both the timestamp and keystone token validity before
authentication validity and force back the login page to retrieve a new
keystone token, avoiding the timeout race condition between session and token
validity which was forcing a dual login. A keystone token expiration is now
considered as a session timeout too.

Also, a page can start loading while the token is valid, and finish while it's
invalid. This was leading to errors during the page loading.
We now set a TOKEN_TIMEOUT_MARGIN period in seconds which allows defining
a margin before which we consider the token as expired.
This is a configurable parameter in the django settings because the time a page
takes to render is infra and deployment specific. This margin is preset to
ten seconds.

Requires: https://review.openstack.org/101556

Closes-Bug: 1308918

Change-Id: I0bf0d079a9dc000c1a30f0e20dcaa03b22d63e51
2014-09-25 15:06:19 +02:00
ChenZheng c7d5371b47 Fix order of arguments in assertEqual
Some tests used incorrect order assertEqual(observed, expected).

The correct order expected by testtools is
assertEqual(expected, observed).

Change-Id: Iabf6e55146412b57b6a6544f312f9510f762566a
Partial-Bug: #1259292
2014-09-01 10:41:52 +08:00
He Yongli e790ac070e Remove extraneous vim configuration comments
Remove vim setting:
comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4

at the top of source code files, except for files in
openstack/common.

Change-Id: I9a5c6b17c6ef7ecec601f4503dfc7b31fc72e90a
Close-bug: #1229324
2014-05-06 15:30:10 +08:00
Radomir Dopieralski 028332da4a Remove #noqa from most common imports and add them to import_exceptions
We have a lot of import with #noqa that is there to ignore h302,
because it's traditional to import and use a name directly, instead
of a whole module. This hides other errors and gives people the
impression that it's actually fine to import non-modules, you just
have to slap #noqa on those lines.

I went through the code and identified about a dozen names that are
most commonly imported this way. I remove the #noqa tag from them,
and added them to the list in import_exceptions.

I also removed a few unused imports that were revealed in the process.

Change-Id: I27afb8e2b1d4759ec974ded9464d8f010312ee78
2014-01-07 12:26:35 +01:00
Matthias Runge 13355dacdb add support for Django-1.6
Sessions now store JSON instead of pickled objects.

Partially-implements blueprint django-1point6

Change-Id: I332ba18005284774a53fb3cb8c6e51bca1480ded
2014-01-03 08:21:53 +01:00
Leandro I. Costantino e2508e7334 Add more Horizon unit tests.
Increse horizon base (+2%) and middleware (+10%) coverage by
adding 6 new tests.

Change-Id: Ibd0f7f43885ee447369a9beaccab7befbbc45ca4
2013-12-02 21:56:05 -05:00
ZhiQiang Fan 686cc88fd2 Replace OpenStack LLC with OpenStack Foundation
Change-Id: I6c638f04fb7c97ac986ef31c1190011ed90a43d2
Fixes-Bug: #1214176
2013-09-20 04:19:42 +08:00
Yves-Gwenael Bourhis 4865cb6a09 Redirecting user back to previous screen
After browser session timeout, the user is now redirected back to the previous
screen upon login.
Also added a non regression unittest.

Change-Id: I995bc217803805364967688e9b896b9b54583b36
Closes-Bug: #1201619
2013-09-12 15:17:06 +02:00
Tatiana Mazur 953d1b9793 Enable H302 check
This patch replaces some method imports with module imports and
makes H302 test enabled.

Fixes bug 1188531

Change-Id: Ibfbddeaa19cbbb244da58ffd5c918c41f03a0c65
2013-08-22 17:39:09 +04:00
Kieran Spear 3fbe68f690 Honour LOGIN_URL when redirecting to login page
Currently the redirect is always made to the url of the 'login' view.
This change makes redirects go to LOGIN_URL, so the default login view
can be replaced with a view at another url/name.

Fixes bug 1079444.

Change-Id: Ib56200679668dd053d3c6ac24807d2a2affc0df8
2012-11-19 10:37:14 +11:00