It could happen that test data is already generated by a previous test.
(running in the same worker)
Make sure we clear everything before performing our checks.
Signed-off-by: moson <moson@archlinux.org>
All tests within a file run in the same worker and out test DB names
are unique per file as well. We don't really need a locking
mechanism here.
Same is valid for the test-emails. The only potential issue is that it
might try to create the same directory multiple times and thus run
into an error. However, that can be covered by specifying
"exist_ok=True" with os.makedirs such that those errors are ignored.
Signed-off-by: moson <moson@archlinux.org>
We should check if a user (target) exists before validating permissions.
Otherwise things crash when a TU is trying to edit an account that
does not exist.
Fixes: aurweb-errors#529
Signed-off-by: moson <moson@archlinux.org>
Problem is that we join with PackageBase, thus we are missing
requests for packages that were deleted.
Fixes: #483
Signed-off-by: moson <moson@archlinux.org>
The new module/class helps us constructing queries and count records to
expose various statistics on the homepage. We also utilize for some new
prometheus metrics (package and user gauges).
Record counts are being cached with Redis.
Signed-off-by: moson <moson@archlinux.org>
We currently validate all commits going from latest -> oldest.
It would be nicer to go oldest -> latest so that, in case of errors,
we would indicate which commit "introduced" the problem.
Signed-off-by: moson <moson@archlinux.org>
The current query is a bit mixed up. The intention was to return the
number of unaccepted records. Now it does also count all records
that were accepted by some other user though.
Let's check the total number of terms vs. the number of accepted
records (by our user) instead.
Signed-off-by: moson <moson@archlinux.org>
The chance of finding multiple object IDs when performing lookups with
a shortened SHA1 hash (7 digits) seems to be quite high.
In those cases pygit2 will throw an error.
Let's catch those exceptions and gracefully handle them.
Fixes: aurweb-errors#496 (and alike)
Signed-off-by: moson <moson@archlinux.org>
In some translations we might be missing replacement placeholders (%).
This turns out to be problematic when calling the format function.
Wrap the jinja2 format function and just return the string unformatted
when % is missing.
Fixes: #341
Signed-off-by: moson <moson@archlinux.org>
Our set of keys returned by "util.parse_ssh_keys" is unordered so we
have to adapt our test to not rely on a specific order for multiple keys.
Fixes: 5ccfa7c0fd ("fix: same ssh key entered multiple times")
Signed-off-by: moson <moson@archlinux.org>
Users might accidentally past their ssh key multiple times
when they try to register or edit their account.
Convert our of list of keys to a set, removing any double keys.
Signed-off-by: moson <moson@archlinux.org>
Package requests are sent to the ML as well as users (CC).
For those who chose to hide their mail address,
we should add them to the BCC list instead.
Signed-off-by: moson-mo <mo-son@mailbox.org>
Fix order of recipients for "FlagNotification" test.
Apply sorting to the recipients query.
(only relevant for tests, but who knows when they change things again)
MariaDB 11 includes some changes related to the
query optimizer. Turns out that this might have effects
on how records are ordered for certain queries.
(in case no ORDER BY clause was specified)
https://mariadb.com/kb/en/mariadb-11-0-0-release-notes/
Signed-off-by: moson <moson@archlinux.org>
The queries being done on the package search page are quite costly.
(Especially the default one ordered by "Popularity" when navigating to /packages)
Let's add the search results to the Redis cache:
Every result of a search query is being pushed to Redis until we hit our maximum of 50k.
An entry expires after 3 minutes before it's evicted from the cache.
Lifetime an Max values are configurable.
Signed-off-by: moson-mo <mo-son@mailbox.org>
We're currently creating a "PackageBases" when the "restore" command is executed.
This is problematic for pkgbases that never existed before.
In those cases it will create the record but fail in the update.py script.
Thus it leaves an orphan "PackageBases" record in the DB
(which does not have any related "Packages" record(s))
Navigating to such a packages /pkgbase/... URL will result in a crash
since it is not foreseen to have "orphan" pkgbase records.
We can safely remove the early creation of that record because
it'll be taken care of in the update.py script that is being called
We'll also fix some tests. Before it was executing a dummy script
instead of "update.py" which might be a bit misleading
since it did not check the real outcome of our "restore" action.
Signed-off-by: moson-mo <mo-son@mailbox.org>
This allows migration of git history for packages dropped from a repo to AUR
in case they contain PGP key material
Signed-off-by: moson-mo <mo-son@mailbox.org>
Use "contains" filtering instead of an exact match
when a package name filter is given.
This makes it easier to find requests for a "group" of packages.
Signed-off-by: moson-mo <mo-son@mailbox.org>
This is done in order to relax the constraints so that dropping packages
from the official repos can be done with preserving their history.
Its sufficient to also have this present in the latest commit of a push.
Signed-off-by: Christian Heusel <christian@heusel.eu>
This should match more closely the expectation of a user.
A session cookie should vanish on browser close
and you thus they need to authenticate again.
There is no need to bump the expiration of AURSID either,
so we can remove that part.
Signed-off-by: moson-mo <mo-son@mailbox.org>
- Add package name textbox for filtering requests (with auto-suggest)
- Make "x pending requests" a link for TU/Dev on the package details page
Signed-off-by: moson-mo <mo-son@mailbox.org>
Currently, the "Repo" column in "OfficialProviders" is not updated
when a package is moved from one repository to another.
Note that we only save a package/provides combination once,
hence if a package is available in core and testing at the same time,
it would only put just one record into the OfficialProviders table.
We iterate through the repos one by one and the last value
is kept for mapping a (package/provides) combination to a repo.
Due to that, the repos listed in the "sync-db" config setting
should be ordered such that the "testing" repos are listed first.
Signed-off-by: moson-mo <mo-son@mailbox.org>
TUs and Devs can delete and merge packages directly.
Currently the comments they enter, don't end up in the ML notification.
Include the comment in the notifications for direct deletion / merge
Signed-off-by: moson-mo <mo-son@mailbox.org>
middleware must be added before startup:
fixes: "RuntimeError: Cannot add middleware after an application has started"
https://fastapi.tiangolo.com/release-notes/#0910
Signed-off-by: moson-mo <mo-son@mailbox.org>
Currently, in the sharness test suites, we use double-quotes
for string literals in SQL statements passed to sqlite3.
With sqlite version 3.41 the usage of double-quotes for string literals
is deactivated by default:
We'll need to switch to single-quotes in our tests.
Ref: Section 6.f. at https://www.sqlite.org/releaselog/3_41_0.html
Signed-off-by: moson-mo <mo-son@mailbox.org>
Data for packages that do not have a "Last Packager"
(e.g. because the user account was deleted)
should still be available from the /rpc and metadata archives.
Signed-off-by: moson-mo <mo-son@mailbox.org>
With the removal of the "setup-repo" command this script becomes obsolete,
because it is not possible to reserve a repo anymore.
Hence we don't need cleanup.
We've also seen issues in case the last packager's user account is removed,
leading to the deletion of a Package.
Let's deactivate this for now.
Issue report: #425
Signed-off-by: moson-mo <mo-son@mailbox.org>
Fixes errors that might occur when loading the package details page.
Problem:
We are querying a list of "Required by" packages.
This list is loaded with all details for a "PackageDependency" record.
Now we also have a reference to some attributes from the
related package (PackageDependency.Package.xxx)
This will effectively trigger the ORM to run another query (lazyload),
to fetch the missing Package data (for each PackageDependency record).
At that point it might have happened that a referenced package
got deleted / updated so that we can't retrieve this data anymore and
our dep.Package object is "None"
Fix:
We can force our query to include Package data right away.
Thus we can avoid running a separate query (per "required by"...)
As a side-effect we get better performance.
Signed-off-by: moson-mo <mo-son@mailbox.org>
When we edit a comment we can enable notifications (if not yet enabled).
We should also do this when the comment text is not changed.
Signed-off-by: moson-mo <mo-son@mailbox.org>
Currently, the "Enable notifications" checkbox
is only shown when editing a comment.
We should also show it when a new comment is about to be added.
Signed-off-by: moson-mo <mo-son@mailbox.org>
Provides a convenient way to check for responses on the
mailing list prior to Accepting/Rejecting requests.
We compute the Message-ID hash that can be used to
link back to the article in the mailing list archive.
Signed-off-by: moson-mo <mo-son@mailbox.org>
Improves performance for queries with large result sets.
The "group by" clause can be removed for all search types but the keywords.
Signed-off-by: moson-mo <mo-son@mailbox.org>
Fixes:
Keyword-links on the package page pass wrong query-parameter.
Thus a name/description search is performed instead of keywords
Issue report: #397
Signed-off-by: moson-mo <mo-son@mailbox.org>