http://hg.code.sf.net:8000/p/roundup/code/atom-log/tip/test/test_liveserver.py Mercurial Repository: p/roundup/code: test/test_liveserver.py history 2025-08-28T12:39:38-04:00 test - fix parsing of integer param values http://hg.code.sf.net:8000/p/roundup/code/#changeset-98e17dd0197f7f0ae93d61aec3f762e81d26a5e5 John Rouillard rouilj@ieee.org 2025-08-28T12:39:38-04:00 2025-08-28T12:39:38-04:00
changeset 98e17dd0197f
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test - fix parsing of integer param values

CI broke on the string '1\r#' expecting a 400 but got a 200 in
test_element_url_param_accepting_integer_values().

The #, & characters mark a url fragment or start of another parameter
and not part of the value. In a couple of tests, I parse the
hypothesis generated value to remove a # or & and anything after. Then
I set the value to the preceding string. If the string starts with #
or &, the value is set to "0" as the server ignores the parameter and
returns 200. "0" is a value that asserts that status is 200.

The code doing this parsing was different (and broken) between

test_element_url_param_accepting_integer_values
and
test_class_url_param_accepting_integer_values

It's now consistent and if it finds a & or #, it actually tests the
resulting value/status rather than skipping the test.
files
[reauth-confirm_id] feat: fix tests under postgresql. http://hg.code.sf.net:8000/p/roundup/code/#changeset-cc3edb260c1bb4c6ded099532c34edf34423760d John Rouillard rouilj@ieee.org 2025-08-14T10:34:40-04:00 2025-08-14T10:34:40-04:00
changeset cc3edb260c1b
branch reauth-confirm_id
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description feat: fix tests under postgresql.

Wierd issue. Calling self.db.user.lookup('reauth') fails under
posttgresql with a cursor closed error. This same call works with
anydbm.

I tried adding a setup/teardown to open the tracker
(self.instance.open('admin') ...etc. But that made the wasgi server
fail to shut down for some reason.

So I hard coded the id for the reauth user.

Also for the postgresql test case, the reauth triggering auditor and
user setup weren't done. I tried to reuse the WsgiSetup.setup_class
and then add in the few extra things I needed, but it failed.
So I copypastaed the code and modified it.

Also corrected docstring for one of the test classes.
files
[reauth-confirm_id] feat: finish reauth docs, enhance code. http://hg.code.sf.net:8000/p/roundup/code/#changeset-0663a7bcef6c1ac3ff2d11bdbcff893231151377 John Rouillard rouilj@ieee.org 2025-08-13T23:52:49-04:00 2025-08-13T23:52:49-04:00
changeset 0663a7bcef6c
branch reauth-confirm_id
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description feat: finish reauth docs, enhance code.

Decided to keep name Reauth for now.

admin_guide.txt:
add reference mark to roundup admin help. Used for template command
reference in upgrading.txt.

customizing.txt:
added worked example of adding a reauth auditor for address and password.
Also links to OWASP recommendations.

Added link to example code in design.doc on detectors.

glossary.txt:
reference using roundup-admin template command in def for tracker
templates.

pydoc.txt:
Added methods for Client class.

Added class and methods for (cgi) Action, LoginAction and ReauthAction.

reference.txt
Edited and restructured detector section.

Added section on registering a detector and priority use/execution order.
(reference to design doc was used before).

Added/enhanced description of exception an auditor can
raise (includes Reauth).

Added section on Reauth implementation and use (Confirming the User).
Also has paragraph on future ideas.

upgrading.txt
Stripped down the original section. Moved a lot to reference.txt.

Referenced customizing example, mention installation of
_generic.reauth.html and reference reference.txt.

cgi/actions.py:
fixed bad ReST that was breaking pydoc.txt processing

changed doc on limitations of Reauth code.

added docstring for Reauth::verifyPassword

cgi/client.py:
fix ReST for a method breaking pydoc.py processing

cgi/templating.py:
fix docstring on embed_form_fields

templates/*/html/_generic.reauth.html
disable spelling for password field

add timing info to the javascript function that processes file data.

reformat javascript IIFE

templates/jinja2/html/_generic.reauth.html
create a valid jinja2 template. Looks like my original jinja
template got overwritten and committed.

feature parity with the other reauth templates.

test/test_liveserver.py
add test case for Reauth workflow.

Makefile
add doc.
files
test: fix fuzz test http://hg.code.sf.net:8000/p/roundup/code/#changeset-51f277ed8adcb4bb344117d46ca48fa43d094fa6 John Rouillard rouilj@ieee.org 2025-01-18T19:08:16-05:00 2025-01-18T19:08:16-05:00
changeset 51f277ed8adc
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: fix fuzz test

CI found a new condition that passes but isn't filtered as passing.

'0 #stuff'

The space is acceptable at the end of a sring otf numbers.

New filter allows this to pass. Added an example of this type of
value.
files
issue2551391 - checkboxes and radiobutton inputs get wrong id's. http://hg.code.sf.net:8000/p/roundup/code/#changeset-669dfccca89860ec425a3ece589811ef15696df8 John Rouillard rouilj@ieee.org 2025-01-16T02:32:58-05:00 2025-01-16T02:32:58-05:00
changeset 669dfccca898
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description issue2551391 - checkboxes and radiobutton inputs get wrong id's.

Actually it breaks automatic id assignment for all inputs.

Inputs now get an automatic id assignment that matches the name.
It can be overridden by supplting an id parameter in the call to
the field() method.

This is also a partial fix for issue1513369. I think it obsoletes the
changes to templating.py.
files
test: Override Fuzz timeout from env variable. http://hg.code.sf.net:8000/p/roundup/code/#changeset-c70ffbc2a0035541c2afb061cbf853cea9b70d64 John Rouillard rouilj@ieee.org 2025-01-12T14:14:09-05:00 2025-01-12T14:14:09-05:00
changeset c70ffbc2a003
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: Override Fuzz timeout from env variable.

I have a local pytest.ini where I use:

env =
pytest_fuzz_timeout=30000

to set a 30 second timout while keeping the default 10 second for CI
because my machine is slow.

So the test now looks for that env variable and uses it if set.
files
fix: issue2551387 - TypeError: not indexable. http://hg.code.sf.net:8000/p/roundup/code/#changeset-05d8806b25ada1d891922f8d091f163af654d6a7 John Rouillard rouilj@ieee.org 2025-01-12T12:34:52-05:00 2025-01-12T12:34:52-05:00
changeset 05d8806b25ad
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix: issue2551387 - TypeError: not indexable.

Fix crash due to uninitialized list element on a (Mini)FieldStorage
when unexpected input is posted via wsgi. This doesn't happen when
running roundup-server. It might happen under other front ends.

Moved the code that sets '.list = [] if .list == None' to the main
flow. Added an exception hander that logs the value of self.form if
self.form.list raises an AttributeError. This exception should never
happen if I understand the code correctly (but I probably don't).

Fixed a number of test cases that were broken because I was calling
Client and passing '[]' rather than a cgi.formStorage object.

Added test cases:

create a FileStorage (self.form) with .list = None.

check AttributeError exception and verify logging.

Problem reported and debugged by Christof Meerwald.
files
fix(api): issue2551384. Verify REST authorization earlier http://hg.code.sf.net:8000/p/roundup/code/#changeset-35beff3168834a58b57bea4ac44ac499ba7942ab John Rouillard rouilj@ieee.org 2025-01-09T09:30:08-05:00 2025-01-09T09:30:08-05:00
changeset 35beff316883
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix(api): issue2551384. Verify REST authorization earlier

To reduce the ability of bad actors to spam (DOS) the REST endpoint
with bad data and generate logs meant for debugging, modify the flow
in client.py's REST handler to verify authorization earlier.

If the anonymous user is allowed to use REST, this won't make a
difference for a DOS attempt. The templates don't enable REST for the
anonymous user by default. Most admins don't change this.

The validation order for REST requests has been changed.

CORS identfied an handled
User authorization to use REST (return 403 on failure)
REST request validated (Origin header valid etc.) (return 400 for
bad request)

Incorrectly formatted CORS preflight requests (e.g. missing Origin
header) that are not recogized as a CORS request can now return HTTP
status 403 as well as status 400 (when anonymous is allowed
access). Note all CORS preflights are sent without authentication so
appear as anonymous requests.

The tests were updated to compensate, but it is not obvious to me from
specs what the proper evaulation order/return codes should be for this
case. Both 403/400 are failures and cause CORS to fail so there should
be no difference but...
files
fix: issue2551374 - Add error handling for filter expressions. Fix UI http://hg.code.sf.net:8000/p/roundup/code/#changeset-cae1bbf2536bb8a1f20c6c1174e0eeb9fdae6625 John Rouillard rouilj@ieee.org 2025-01-01T02:06:00-05:00 2025-01-01T02:06:00-05:00
changeset cae1bbf2536b
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix: issue2551374 - Add error handling for filter expressions. Fix UI

Errors are now reported using the search template.

This should work in most situations. However if the query was
generated using an alternate search template, the user may not be able
to fix it. I'm not sure how to tell what template was used to submit
the search. By the time I handle the error, I don't think I have
access to an ok template or error template. Might need to add a new
field if this becomes a problem.

Also fixed a couple of tests changing the status code to 200 from 400
since we aren't on an error page anymore.

Updated user_guide including 3 sample error messages for search
expressions and how to understand them.
files
test: issue2551366. Probe for open port in test_liveserver.py http://hg.code.sf.net:8000/p/roundup/code/#changeset-f6923d2ba9a5d7b4b543a6fc3405978898f9340b John Rouillard rouilj@ieee.org 2024-12-31T23:48:38-05:00 2024-12-31T23:48:38-05:00
changeset f6923d2ba9a5
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: issue2551366. Probe for open port in test_liveserver.py

Add a method to probe for an open port to wsgi_liveserver.py. Start
the roundup server under wsgi on the open port. If a port can't be
found, it skips all tests.

Also changed all hardcoded URL references to use the dynamicly
determined tracker url/port value.

I fed my patch to wsgi_liveserver.py upstream at:

https://github.com/jerrykan/wsgi-liveserver/issues/3
files
test: missed change in error wording. http://hg.code.sf.net:8000/p/roundup/code/#changeset-393dfc750d8b32b21baa43a24d5f1e5d1dddf62c John Rouillard rouilj@ieee.org 2024-12-30T20:30:26-05:00 2024-12-30T20:30:26-05:00
changeset 393dfc750d8b
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: missed change in error wording.
files
fix: issue2551374. Error handling for filter expressions. http://hg.code.sf.net:8000/p/roundup/code/#changeset-741ea8a86012d3216274d437d72198b432dc6b8c John Rouillard rouilj@ieee.org 2024-12-30T20:22:55-05:00 2024-12-30T20:22:55-05:00
changeset 741ea8a86012
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix: issue2551374. Error handling for filter expressions.

Errors in filter expressions are now reported. The UI needs some work
but even the current code is helpful when debugging filter
expressions.

mlink_expr:

defines/raises ExpressionError(error string template,
context=dict())

raises ExpressionError when it detects errors when popping arguments
off stack

raises ExpressionError when more than one element left on the stack
before returning

also ruff fix to group boolean expression with parens

back_anydbm.py, rdbms_common.py:

catches ExpressionError, augments context with class and
attribute being searched. raises the exception

for both link and multilink relations

client.py

catches ExpressionError returning a basic error page. The page is a
dead end. There are no links or anything for the user to move
forward. The user has to go back, possibly refresh the page (because
the submit button may be disalbled) re-enter the query and try
again.

This needs to be improved.

test_liveserver.py

test the error page generated by client.py

db_test_base

unit tests for filter with too few arguments, too many arguments,
check all repr and str formats.
files
test: add file encoding marker so python2 can run http://hg.code.sf.net:8000/p/roundup/code/#changeset-9404d56d830f227e5c2aad505a93d5613ce7de57 John Rouillard rouilj@ieee.org 2024-12-17T20:45:28-05:00 2024-12-17T20:45:28-05:00
changeset 9404d56d830f
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: add file encoding marker so python2 can run

http://python.org/dev/peps/pep-0263/
files
fix(REST): issue2551383; improve errors for bad json, fix PUT docs http://hg.code.sf.net:8000/p/roundup/code/#changeset-32aaf5dc562be2b244cc3ee62e26ff2e53a1ae6e John Rouillard rouilj@ieee.org 2024-12-17T19:42:46-05:00 2024-12-17T19:42:46-05:00
changeset 32aaf5dc562b
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix(REST): issue2551383; improve errors for bad json, fix PUT docs

While adding fuzz testing for email addresses via REST
/rest/data/user/1/address, I had an error when setting the address to
the same value it currently had. Traced this to a bug in
userauditor.py. Fixed the bug. Documented in upgrading.txt.

While trying to track down issue, I realized invalid json was being
accepted without error. So I fixed the code that parses the json and
have it return an error. Also modified some tests that broke (used
invalid json, or passed body (e.g. DELETE) but shouldn't have. Add
tests for bad json to verify new code.

Fixed test that wasn't initializing the body_file in each loop, so the
test wasn't actually supplying a body.

Also realised PUT documentation was not correct. Output format isn't
quite like GET.

Fuss tests for email address also added.
files
fix(web) issue2551382 - fix missing hypothesis case http://hg.code.sf.net:8000/p/roundup/code/#changeset-cd76d5d59c375b2f85070711c6ab1c3edf9208ac John Rouillard rouilj@ieee.org 2024-12-16T21:29:07-05:00 2024-12-16T21:29:07-05:00
changeset cd76d5d59c37
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix(web) issue2551382 - fix missing hypothesis case

Syntax error if hypothesis is not importable. Only affects python2 CI.
files
fix(web) issue2551382 - fix more integer param test cases http://hg.code.sf.net:8000/p/roundup/code/#changeset-03020f08a685c4aeaf84170b50205c017eda137d John Rouillard rouilj@ieee.org 2024-12-16T21:24:59-05:00 2024-12-16T21:24:59-05:00
changeset 03020f08a685
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix(web) issue2551382 - fix more integer param test cases

fix bad unicode in second test. Also be smarter about validating
the value I was missing correct handling of other string variants
with # or & embedded in them. E.G. 123#dfg - should return 200
as Roundup sees value 123.
files
fix(web) issue2551382 - handle crash in request call in test http://hg.code.sf.net:8000/p/roundup/code/#changeset-1b15f635ada1c6197027a06dfb81e45df5ca0693 John Rouillard rouilj@ieee.org 2024-12-16T19:19:07-05:00 2024-12-16T19:19:07-05:00
changeset 1b15f635ada1
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix(web) issue2551382 - handle crash in request call in test

due to invalid utf8 with surrogate. Ci reports this failure in the
requests call from the test case:

> string = string.encode(encoding, errors)
E UnicodeEncodeError: 'utf-8' codec can't encode character
'\ud800' in position 48: surrogates not allowed
E Falsifying example:
test_class_url_param_accepting_integer_values(
E self=<test.test_liveserver.FuzzGetUrls
testMethod=test_class_url_param_accepting_integer_values>,
E param='@verbose', # or any other generated value
E value='\ud800',
E )
E Explanation:
E These lines were always and only run by failing
examples:
E
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/site-packages/requests/utils.py:675
E
E You can reproduce this example by temporarily adding
@reproduce_failure('6.122.3', b'AAAAAQDXAA==') as a decorator on your
test case
files
fix(web) issue2551382 - case 1# or 1& failing. http://hg.code.sf.net:8000/p/roundup/code/#changeset-55b0abde56ab489aab4f93440da89cf45d72df43 John Rouillard rouilj@ieee.org 2024-12-15T02:34:57-05:00 2024-12-15T02:34:57-05:00
changeset 55b0abde56ab
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix(web) issue2551382 - case 1# or 1& failing.

HAndle case for integer followed by a url delimiter. e.g. 1# and 1&
files
fix(web) issue2551382 - 409 not 400 errors returned http://hg.code.sf.net:8000/p/roundup/code/#changeset-14e92a59582889b2a14ac7357c4021757af42f65 John Rouillard rouilj@ieee.org 2024-12-15T01:57:42-05:00 2024-12-15T01:57:42-05:00
changeset 14e92a595828
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix(web) issue2551382 - 409 not 400 errors returned

invalid integer values for @verbose, @page_* values in rest uri's
generated a 409 (Update Conflict) error not a generic 400 error.

Found it when I was working on adding fuzz testing to check error
handling for query parameters in REST url's.

This also ads the tests in test_liveserver that found the error. Also
refactored tst_liveserver to allow resuse of session login method for
the new fuzz testing class as well.
files
issue2551370 - prefix session cookie with __Secure- over https http://hg.code.sf.net:8000/p/roundup/code/#changeset-3f0f4746dc7ece6a24ccb5181efb9d2028019f25 John Rouillard rouilj@ieee.org 2024-11-26T17:11:13-05:00 2024-11-26T17:11:13-05:00
changeset 3f0f4746dc7e
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description issue2551370 - prefix session cookie with __Secure- over https

Limit use of roundup session cookie to HTTPS protocol by adding
__Secure- prefix. Automatic testing includes http behavior only.
Https behavious has been manually tested only. Need to be able to spin
up an https server using wsgiref to test https behavior in CI.
issue 2551373 opened to track automatic testing of https behavior.
files
[permission-performance] Fix failing test due to mokey patching http://hg.code.sf.net:8000/p/roundup/code/#changeset-603aa730b067384c5b94f94453419e6b3e0457b2 Ralf Schlatterbeck rsc@runtux.com 2024-10-22T16:10:29+02:00 2024-10-22T16:10:29+02:00
changeset 603aa730b067
branch permission-performance
bookmark
tag
user Ralf Schlatterbeck <rsc@runtux.com>
description Fix failing test due to mokey patching

An earlier test monkey-patched the permission checks which subsequently
failed in another test.
files
fix(security): fix CVE-2024-39124, CVE-2024-39124, and CVE-2024-39125 http://hg.code.sf.net:8000/p/roundup/code/#changeset-28aa76443f58bc1605a9933bb4ea4d599c97af5a John Rouillard rouilj@ieee.org 2024-07-09T09:07:09-04:00 2024-07-09T09:07:09-04:00
changeset 28aa76443f58
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix(security): fix CVE-2024-39124, CVE-2024-39124, and CVE-2024-39125

Directions for fixing:

* `CVE-2024-39124`_ - :ref:`classhelpers (_generic.help.html) are
vulnerable to an XSS attack. <CVE-2024-39124>` Requires fixing
tracker homes.
* `CVE-2024-39125`_ - :ref:`if Referer header is set to a script
tag, it will be executed. <CVE-2024-39125>` Fixed in release 2.4.0,
directions available for fixing in prior versions.
* `CVE-2024-39126`_ - :ref:`PDF, XML and SVG files downloaded from
an issue can contain embedded JavaScript which is
executed. <CVE-2024-39126>` Fixed in release 2.4.0, directions
available for fixing in prior versions.

prior to 2.4.0 release this weekend that fixes the last two CVE's.
files
fix: make If-None-Match work for static file (@@file) case http://hg.code.sf.net:8000/p/roundup/code/#changeset-60c98a8a23bdaebc909723c7b788f1857bd41f5a John Rouillard rouilj@ieee.org 2024-06-02T20:35:47-04:00 2024-06-02T20:35:47-04:00
changeset 60c98a8a23bd
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix: make If-None-Match work for static file (@@file) case

Found by Redbot testing.
files
issue 2551353 - add roundup-classhelper http://hg.code.sf.net:8000/p/roundup/code/#changeset-dd229bbdd32ddc15ddc7a802b9f75edb6462ae27 John Rouillard rouilj@ieee.org 2024-05-22T19:36:00-04:00 2024-05-22T19:36:00-04:00
changeset dd229bbdd32d
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description issue 2551353 - add roundup-classhelper

Add test for rest/data/user/roles endpoint. Fix allow header returned
from endpoint to allow GET only.
files
test: issue1525113 - notation to filter by logged-in user http://hg.code.sf.net:8000/p/roundup/code/#changeset-22354d7fc94a79bfc35485ffa2bc389185c2e45f John Rouillard rouilj@ieee.org 2024-05-06T01:25:27-04:00 2024-05-06T01:25:27-04:00
changeset 22354d7fc94a
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: issue1525113 - notation to filter by logged-in user

Add a test_liveserver test of a @current_user query.

Maybe this will catch the templating change somehow??
files
test: populate db with query using @current_user http://hg.code.sf.net:8000/p/roundup/code/#changeset-f670446b5e50dfa1f56da981334c22336ff277e5 John Rouillard rouilj@ieee.org 2024-05-05T20:57:11-04:00 2024-05-05T20:57:11-04:00
changeset f670446b5e50
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: populate db with query using @current_user

For future testing.
files
test: refactor tests to use create_login_session http://hg.code.sf.net:8000/p/roundup/code/#changeset-6a13cf7bdca53ce8fa95f91e3044aadb1e68aacd John Rouillard rouilj@ieee.org 2024-05-05T20:56:08-04:00 2024-05-05T20:56:08-04:00
changeset 6a13cf7bdca5
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: refactor tests to use create_login_session
files
issue2551334 - get test suite running under windows http://hg.code.sf.net:8000/p/roundup/code/#changeset-4cca0ae9f90139b26d8f4e7979bce18fc300158c John Rouillard rouilj@ieee.org 2024-04-28T19:24:19-04:00 2024-04-28T19:24:19-04:00
changeset 4cca0ae9f901
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description issue2551334 - get test suite running under windows

https://stackoverflow.com/questions/59506097/python-requests-library-is-very-slow-on-windows/75425238#75425238

reports that the requests libary uses urllib3. On windows this
tries (and retries) an IPv6 address if localhost is used in the
url. This takes 2s per request to test IPv6, give up and use
IPv4. At that rate, the rate limit is never reached and the
rest_login_RateLimit test fails.

This patch rewrites the base url to use 127.0.0.1 replacing
localhost. It forced urllib3 to open only an IPv4 address and the
speedup allows the test to pass.
files
issue2551334 - Get test suite to pass using windows python http://hg.code.sf.net:8000/p/roundup/code/#changeset-80cf6098ea65ad2790642b7ed163a126e81b23e1 John Rouillard rouilj@ieee.org 2024-04-28T00:08:42-04:00 2024-04-28T00:08:42-04:00
changeset 80cf6098ea65
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description issue2551334 - Get test suite to pass using windows python

Mark classes that use requests library with skip markers if requests is
not available.
files
issue2551212 - enable wsgi cache_tracker by default http://hg.code.sf.net:8000/p/roundup/code/#changeset-0fe2b9f6e19f4186cb5752ba1936e2b990cb20ae John Rouillard rouilj@ieee.org 2024-03-20T17:13:30-04:00 2024-03-20T17:13:30-04:00
changeset 0fe2b9f6e19f
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description issue2551212 - enable wsgi cache_tracker by default

Switch the code so the wsgi cache_tracker optimization is enabled by
default. Leave the unoptimized/uncached code path available in case it
breaks something. The feature flag can be set to False to disable
caching.

Updated tests to test the disabled (non-cache) code path.

Updated upgrading.txt with info on how to disable caching.
files
test: fix test for invalid etag in if-range. http://hg.code.sf.net:8000/p/roundup/code/#changeset-1b5daee24dc70c36b532b450e2a4ad1d28abb961 John Rouillard rouilj@ieee.org 2024-03-17T00:55:29-04:00 2024-03-17T00:55:29-04:00
changeset 1b5daee24dc7
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: fix test for invalid etag in if-range.

The broken etag was missing the initial ", so the wrong code path was
duplicated. Also add test that correct size of file was returned and
fix comment(s).
files
fix typo http://hg.code.sf.net:8000/p/roundup/code/#changeset-ec59729b3b7e331defad2bc15f0a98718c2f3309 John Rouillard rouilj@ieee.org 2023-07-24T00:37:36-04:00 2023-07-24T00:37:36-04:00
changeset ec59729b3b7e
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix typo
files
only run TestPostgresWsgiServer if ostgresl is available. http://hg.code.sf.net:8000/p/roundup/code/#changeset-0abc225864d1011105bf5809ad1618616713a1d0 John Rouillard rouilj@ieee.org 2023-07-24T00:35:50-04:00 2023-07-24T00:35:50-04:00
changeset 0abc225864d1
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description only run TestPostgresWsgiServer if ostgresl is available.
files
test: fix test_rest_login_RateLimit CI has different char numbers http://hg.code.sf.net:8000/p/roundup/code/#changeset-7b481ec7f169541fec34475b27a0b56358b75d8a John Rouillard rouilj@ieee.org 2023-07-19T21:12:56-04:00 2023-07-19T21:12:56-04:00
changeset 7b481ec7f169
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: fix test_rest_login_RateLimit CI has different char numbers

It looks like the json returned has different spacing when pretty
printed.

Under CI, I get 157 chars under python2 and 161 under python3. On
local development, I get 167. The data is the same in all three
environments. Change test to load json data structure and compare
against a dict that matches the returned data.

Also remove encoding type, not critical to test.
files
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection. http://hg.code.sf.net:8000/p/roundup/code/#changeset-273c8c2b504245a937efbd42604f77cb2d3d0d9d John Rouillard rouilj@ieee.org 2023-07-19T20:37:45-04:00 2023-07-19T20:37:45-04:00
changeset 273c8c2b5042
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.

Failed API login rate limiting with expiring lockout added.
files
- issue2551257: add 'X-Content-Type-Options: nosniff' header for file download http://hg.code.sf.net:8000/p/roundup/code/#changeset-765222ef4cec647b530fd95dc364d6820177ee46 John Rouillard rouilj@ieee.org 2023-02-23T16:20:32-05:00 2023-02-23T16:20:32-05:00
changeset 765222ef4cec
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description - issue2551257: add 'X-Content-Type-Options: nosniff' header for file download

when downloading an attached (user supplied file), make sure that an
'X-Content-Type-Options: nosniff' header is sent.

Added test for header as well.
files
disable and fix errors in test_rest_login_rate_limit http://hg.code.sf.net:8000/p/roundup/code/#changeset-a9be849d4dd2b59f52740208c9dfb2b01f02d69a John Rouillard rouilj@ieee.org 2023-02-21T18:07:37-05:00 2023-02-21T18:07:37-05:00
changeset a9be849d4dd2
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description disable and fix errors in test_rest_login_rate_limit

The test is testing functionality that doesn't yet exist.
So disable for now.

Also with tightening of origin checks in rev: 72a54826ff4f add origin
header to options requests.
files
better rest Origin check; refactor CORS preflight code. http://hg.code.sf.net:8000/p/roundup/code/#changeset-72a54826ff4f5aac67e3d8c6f791f455888d2649 John Rouillard rouilj@ieee.org 2023-02-21T16:42:20-05:00 2023-02-21T16:42:20-05:00
changeset 72a54826ff4f
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description better rest Origin check; refactor CORS preflight code.

A previous version allowed requests without an origin that should
require it (e.g. an OPTIONS or PATCH request). Moved the origin
checking logic into the main flow. It looks like this was limited to
OPTIONS/PATCH requests as handle_csrf() (called later in the main
flow) handles POST, PUT, DELETE verbs.

Refactored CORS preflight request code into functions and call them
from main flow. Also return immediately. Prior code processed the
options request a second time due to falling through.

Modified is_origin_header_ok to return True if origin was missing and
it was a get request.

Fixed tests that make OPTIONS requests to supply origin.

Comment fixups.
files
cange type or arg to assertIn from string to byte. http://hg.code.sf.net:8000/p/roundup/code/#changeset-3c4047cdc77aa766936eb2230638e7910cde1eb1 John Rouillard rouilj@ieee.org 2022-09-14T18:08:27-04:00 2022-09-14T18:08:27-04:00
changeset 3c4047cdc77a
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description cange type or arg to assertIn from string to byte.
files
flake8 - remove re.compile from method arg + test + doc http://hg.code.sf.net:8000/p/roundup/code/#changeset-ff2c8b43073815dcc4be8991cfc1b1e1bcf90c40 John Rouillard rouilj@ieee.org 2022-09-14T17:48:51-04:00 2022-09-14T17:48:51-04:00
changeset ff2c8b430738
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description flake8 - remove re.compile from method arg + test + doc

changed 2 methods defined like:

def method(..., dre=re.compile(r'...')):

moved re.compile to module variables and passed the var name

def method(..., dre=var_name):

while doing this I found out that a url of .../issue0001 will behave
like .../issue1. Who knew. Documented in customizing.

Tested same in test_liveserver. Added msg1 as well so I could verify
msg0001 worked.

Also added some range tests as well.
files
Change method for settin indexer; have test_livetest for pg cleanup http://hg.code.sf.net:8000/p/roundup/code/#changeset-cb2ed1e8c8520907847b9ad4227e6a999713c899 John Rouillard rouilj@ieee.org 2022-09-06T14:43:36-04:00 2022-09-06T14:43:36-04:00
changeset cb2ed1e8c852
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Change method for settin indexer; have test_livetest for pg cleanup

Add code to defer opening the indexer only if indexer is native-fts.
See if this fixes the sqlite OperationalError.

Also under python 2.7 (only), the db from test_livetracker when using
postgres FTS didn't empty the db. This caused the following
test_postgres.py test to fail.

Why it only showed up on 2.7 and not any of the 3.x releases is a
mystery.
files
postgresql native-fts; more indexer tests http://hg.code.sf.net:8000/p/roundup/code/#changeset-9ff091537f43346776e45c325be77f43beb43970 John Rouillard rouilj@ieee.org 2022-09-05T16:25:20-04:00 2022-09-05T16:25:20-04:00
changeset 9ff091537f43
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description postgresql native-fts; more indexer tests

1) Make postgresql native-fts actually work.
2) Add simple stopword filtering to sqlite native-fts indexer.
3) Add more tests for indexer_common get_indexer


Details:

1) roundup/backends/indexer_postgresql_fts.py:

ignore ValueError raised if we try to index a string with a null
character in it. This could happen due to an incorrect text/ mime
type on a file that has nulls in it.

Replace ValueError raised by postgresql with customized
IndexerQueryError if a search string has a null in it.

roundup/backends/rdbms_common.py:

Make postgresql native-fts work. When specified it was using using
whatever was returned from get_indexer(). However loading the
native-fts indexer backend failed because there was no connection to
the postgresql database when this call was made.

Simple solution, move the call after the open_connection call in
Database::__init__().

However the open_connection call creates the schema for the
database if it is not there. The schema builds tables for
indexer=native type indexing. As part of the build it looks at the
indexer to see the min/max size of the indexed tokens. No indexer
define, we get a crash.

So it's a a chicken/egg issue. I solved it by setting the indexer
to the Indexer from indexer_common which has the min/max token size
info. I also added a no-op save_indexer to this Indexer class. I
claim save_indexer() isn't needed as a commit() on the db does all
the saving required. Then after open_connection is called, I call
get_indexer to retrieve the correct indexer and
indexer_postgresql_fts woks since the conn connection property is
defined.

roundup/backends/indexer_common.py:

add save_index() method for indexer. It does nothing but is needed
in rdbms backends during schema initialization.

2) roundup/backends/indexer_sqlite_fts.py:

when this indexer is used, the indexer test in DBTest on the word
"the" fail. This is due to missing stopword filtering. Implement
basic stopword filtering for bare stopwords (like 'the') to make the
test pass. Note: this indexer is not currently automatically run by
the CI suite, it was found during manual testing. However there is a
FIXME to extract the indexer tests from DBTest and run it using this
backend.

roundup/configuration.py, roundup/doc/admin_guide.txt:

update doc on stopword use for sqlite native-fts.

test/db_test_base.py:

DBTest::testStringBinary creates a file with nulls in it. It was
breaking postgresql with native-fts indexer. Changed test to assign
mime type application/octet-stream that prevents it from being
processed by any text search indexer.

add test to exclude indexer searching in specific props. This code
path was untested before.


test/test_indexer.py:

add test to call find with no words. Untested code path.

add test to index and find a string with a null \x00 byte. it was
tested inadvertently by testStringBinary but this makes it explicit
and moves it to indexer testing. (one version each for: generic,
postgresql and mysql)

Renamed Get_IndexerAutoSelectTest to Get_IndexerTest and renamed
autoselect tests to include autoselect. Added tests for an invalid
indexer and using native-fts with anydbm (unsupported combo) to make
sure the code does something useful if the validation in
configuration.py is broken.

test/test_liveserver.py:

add test to load an issue

add test using text search (fts) to find the issue

add tests to find issue using postgresql native-fts

test/test_postgresql.py, test/test_sqlite.py:

added explanation on how to setup integration test using native-fts.

added code to clean up test environment if native-fts test is run.
files
application/javascript is now text/javascript http://hg.code.sf.net:8000/p/roundup/code/#changeset-d9c9f5b81d4da5213cfe10c1161f6e5cb2c31c05 John Rouillard rouilj@ieee.org 2022-09-01T15:06:53-04:00 2022-09-01T15:06:53-04:00
changeset d9c9f5b81d4d
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description application/javascript is now text/javascript

ubuntu-22.04 chnged js file mime type from the depricated
application/javascript. to text/javascript.

client.py cache text/javascript like application/javascript

test_liveserver: use current environment's mapping for .js files to
mimetype.
files
Refactor client.py session cookie code. Remove session db access. http://hg.code.sf.net:8000/p/roundup/code/#changeset-6b636fb2974081d42e19052748cff0dccb9d63b2 John Rouillard rouilj@ieee.org 2022-08-03T17:34:58-04:00 2022-08-03T17:34:58-04:00
changeset 6b636fb29740
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Refactor client.py session cookie code. Remove session db access.

The original code did a session_db.exists test followed by a
session_db.getall.

Refactor does a getall and if a KeyError is thrown, handles the
error. Most likely the session key will be found so exception handling
won't be triggered.

Added test case to test the exception code path and minor
rearrangement of setup code.
files
Mark test__generic_item_template_editbad as xfail http://hg.code.sf.net:8000/p/roundup/code/#changeset-6d4ac1ae2ae8425aa6d6696848fe8b0e9bf0f5ab John Rouillard rouilj@ieee.org 2022-07-05T08:34:39-04:00 2022-07-05T08:34:39-04:00
changeset 6d4ac1ae2ae8
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Mark test__generic_item_template_editbad as xfail

This test passes locally but fails in TravisCI.
Commit as xfail so tests pass and fix later.
files
Split edit ok and edit not ok test into two tests. http://hg.code.sf.net:8000/p/roundup/code/#changeset-f6dd6cd920bce27aba8518328da25ff9ea01873c John Rouillard rouilj@ieee.org 2022-07-05T02:02:38-04:00 2022-07-05T02:02:38-04:00
changeset f6dd6cd920bc
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Split edit ok and edit not ok test into two tests.

Having them combined seems to cause them to fail in CI.
Will splitting them with separate setup for each work better?
files
See if explicit logout prevents fred from having a submit button. http://hg.code.sf.net:8000/p/roundup/code/#changeset-1572568fe146f52624e33231fc8eefdabe23a670 John Rouillard rouilj@ieee.org 2022-07-05T01:50:18-04:00 2022-07-05T01:50:18-04:00
changeset 1572568fe146
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description See if explicit logout prevents fred from having a submit button.

I don't need this on my slow test machine, but perhaps it's a race
condition.
files
Disable rate limit. Tests log in and trip the limit causeing failures. http://hg.code.sf.net:8000/p/roundup/code/#changeset-d308fb5ba9b0f5d731caad56251e3b532d7c1908 John Rouillard rouilj@ieee.org 2022-07-05T01:22:06-04:00 2022-07-05T01:22:06-04:00
changeset d308fb5ba9b0
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Disable rate limit. Tests log in and trip the limit causeing failures.
files
Test _generic.item.html to mke sure submit button displayed properly http://hg.code.sf.net:8000/p/roundup/code/#changeset-bb04638dc78d5195b457eb0b439406dd9ab7344f John Rouillard rouilj@ieee.org 2022-07-05T00:36:22-04:00 2022-07-05T00:36:22-04:00
changeset bb04638dc78d
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Test _generic.item.html to mke sure submit button displayed properly

Login as admin and new fred user. Admin user should see submit button
when viewing /status7. User fred should not see it.

Both should see the word 'done-cbb' which is the name of status7.
Chose that since done-cbb is unliely to occur naturally while unread
(name of /status1) could occur by chance in the future.
files
Test form login failure code path. http://hg.code.sf.net:8000/p/roundup/code/#changeset-c63ddea96fcb466b744f79bf98682ba9a83656f7 John Rouillard rouilj@ieee.org 2022-07-03T22:46:32-04:00 2022-07-03T22:46:32-04:00
changeset c63ddea96fcb
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Test form login failure code path.
files
Add test for incorrect url. http://hg.code.sf.net:8000/p/roundup/code/#changeset-be3fd5e9577eb1300f32c39b3da648913973285c John Rouillard rouilj@ieee.org 2022-07-03T13:13:04-04:00 2022-07-03T13:13:04-04:00
changeset be3fd5e9577e
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Add test for incorrect url.

Test using '/_bad>' url path. Make sure it returns 404 and encodes the '>'
in the returned html.
files
wsgi can cache tracker instance enabled by feature flag. http://hg.code.sf.net:8000/p/roundup/code/#changeset-d32d43e4a5babf1b398d31c3a091262c0d54bd0a John Rouillard rouilj@ieee.org 2022-07-02T14:04:00-04:00 2022-07-02T14:04:00-04:00
changeset d32d43e4a5ba
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description wsgi can cache tracker instance enabled by feature flag.

Patch by Marcus Priesch caches a loaded tracker instance and reuse it
for future client sessions.

It is enabled by a feature flag in wsgi.py since it arrived during the
2.2.0 beta period.

The provided wsgi.py is modified to enable it. Testing is run with
flag enabled and disabled.

Ralf Schlatterbeck and Marcus tested it on one of their larger more
complex trackers and it sped up the response time to a client request
by a factor of 3 (270ms down to about 80-85ms).
files
issue2551203 - Add support for CORS preflight request http://hg.code.sf.net:8000/p/roundup/code/#changeset-9a1f5e496e6c4dbd311434a9636bb3ffa20b01d6 John Rouillard rouilj@ieee.org 2022-06-07T09:39:35-04:00 2022-06-07T09:39:35-04:00
changeset 9a1f5e496e6c
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description issue2551203 - Add support for CORS preflight request

Add support for unauthenticated CORS preflight and fix headers for
CORS.

client.py:

pass through unauthenticated CORS preflight to rest backend. Normal
rest OPTION handlers (including tracker defined extensions) can
see and handle the request.

make some error cases return error json with crrect mime type rather
than plain text tracebacks.

create new functions to verify origin and referer that filter using
allowed origins setting.

remove tracker base url from error message is referer is not at an
allowed origin.

rest.py:

fix up OPTION methods handlers to include
Access-Control-Allow-Methods that are the same as the Allow
header.

set cache to one week for all Access-Control headers for CORS
preflight only.

remove self.client.setHeader("Access-Control-Allow-Origin", "*") and
set Access-Control-Allow-Origin to the client supplied origin if
it passes allowed origin checks. Required for CORS otherwise data
isn't available to caller. Set for all responses.


set Vary header now includes Origin as responses can differ based on
Origin for all responses.

set Access-Control-Allow-Credentials to true on all responses.

test_liveserver.py:

run server with setting to enforce origin csrf header check

run server with setting to enforce x-requested-with csrf header check

run server with setting for allowed_api_origins

requests now set required csrf headers

test preflight request on collections

check new headers and Origin is no longer '*'


rewrite all compression checks to use a single method with argument
to use different compression methods. Reduce a lot of code
duplication and makes updating for new headers easier.


test_cgi:

test new error messages in client.py

account for new headers

test preflight and new code paths
files
Test more range error cases. http://hg.code.sf.net:8000/p/roundup/code/#changeset-a193653d6fa4c53a9cf33214d893530beeb63e69 John Rouillard rouilj@ieee.org 2022-05-02T15:29:12-04:00 2022-05-02T15:29:12-04:00
changeset a193653d6fa4
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Test more range error cases.

check content-range and content-length where applicable

cases:
invalid if-range etag should return whole file with a 200 exit code
invalid range with invalid etag return whole file 200 exit code
invalid range with valid etag return whole file 200 exit code
invalid range with no etag return 416 unable to satify and check valid
content-range.
files
Fix modification of Cache_Control http://hg.code.sf.net:8000/p/roundup/code/#changeset-da6c9050a79e2bc68bcb21f6919306ac9f46a674 Ralf Schlatterbeck rsc@runtux.com 2022-05-02T14:25:15+02:00 2022-05-02T14:25:15+02:00
changeset da6c9050a79e
branch
bookmark
tag
user Ralf Schlatterbeck <rsc@runtux.com>
description Fix modification of Cache_Control

The previous code modified the Cache_Control dictionary in the Client
class (in one of the cgi tests) which made a later test in
test_liveserver fail
files
Make i18n tests work http://hg.code.sf.net:8000/p/roundup/code/#changeset-5be4f9104cf7689be113b81e60af959e61cee76e Ralf Schlatterbeck rsc@runtux.com 2022-05-02T13:46:58+02:00 2022-05-02T13:46:58+02:00
changeset 5be4f9104cf7
branch
bookmark
tag
user Ralf Schlatterbeck <rsc@runtux.com>
description Make i18n tests work

These use installed roundup locales but should use the checked-out
locales. Also revert monkey patches in i18n after the test.
files
Add language test for cookie and accept-header; Test Range header http://hg.code.sf.net:8000/p/roundup/code/#changeset-53c9b62494e69e2fa6752dcd84fb640232680080 John Rouillard rouilj@ieee.org 2022-04-28T18:14:22-04:00 2022-04-28T18:14:22-04:00
changeset 53c9b62494e6
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Add language test for cookie and accept-header; Test Range header

Added tests for start page translated to german using cookies retuened
when @language is used. Checked that @language=none unsets
roundup-langage cookie. Also test Accept-Language makes change to
german.

Add test for Range and If-Range headers. Roundup support for these is
simple:
Range: single range with both endpoints
If-Range: strong etag only
files
Test german translation of start page. http://hg.code.sf.net:8000/p/roundup/code/#changeset-6ac3667706be4034fe363ec9baa1b0e0055c7842 John Rouillard rouilj@ieee.org 2022-04-26T17:22:33-04:00 2022-04-26T17:22:33-04:00
changeset 6ac3667706be
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Test german translation of start page.

Issue 2551199 wants to remove translationService from templating.py.
I wanted to get some translation test in place that went through
templating. AFAICT, translation test are done through the i18n
interface and not via the web interface.
files
fix test_new_issue_with_file_upload http://hg.code.sf.net:8000/p/roundup/code/#changeset-198875530c045e945dec93c0acae62036152a763 John Rouillard rouilj@ieee.org 2021-12-21T18:53:55-05:00 2021-12-21T18:53:55-05:00
changeset 198875530c04
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix test_new_issue_with_file_upload

file designator can change if tests running before this add/remove
files.

Create the issue and use the returned url to extract the issue number
and file number from the redirected url and the @ok_message param
respectively. Use these values for the rest of the steps.
files
Fix test_new_file_via_rest http://hg.code.sf.net:8000/p/roundup/code/#changeset-3ae0c0fb2d0875030216d0ad8a0c5b557c7f83bb John Rouillard rouilj@ieee.org 2021-12-21T02:28:25-05:00 2021-12-21T02:28:25-05:00
changeset 3ae0c0fb2d08
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description Fix test_new_file_via_rest

This test was failing under python2.

The cgi.py module was calling readline(1<<16).

I was using the wasgiref/validate.py validator to make sure the wsgi
protocol was correct. The validator replaces the normal readline with
it's own wrapper. The wrapper doesn't support the max bytes to read
value.

The same module/wrapper in python 3 fixed this bug.

So fixed this by disabling the validator under python2. Keeping it on
python3 so we get its benefit.
files