Commit graph

3533 commits

Author SHA1 Message Date
Kevin Morris
b1baf76998 add util.as_timezone -> as_timezone Jinja2 filter
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-19 09:53:48 -07:00
Kevin Morris
ac67268a28 add util.timezone_to_datetime -> dt Jinja2 filter
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-19 09:53:30 -07:00
Kevin Morris
f89d06d092 setup_test_db: remove mysql-dependent coverage path
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-19 09:09:12 -07:00
Kevin Morris
b7d67bf5fc render_template: convert HTTPStatus objects
This will automate a lot of conversion that happens
around the codebase in terms of status_code.

As of this commit, we should improve usage and remove
int(status_code) casts wherever we can.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-19 09:08:59 -07:00
Kevin Morris
7ae95ac908 bugfix: removed extra space in " My Account" nav link
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-19 09:08:21 -07:00
Kevin Morris
40448ccd34 aurweb.db: add commit(), add() and autocommit arg
With the addition of these two, some code has been swapped
to use these in some of the other db wrappers with an additional
autocommit kwarg in create and delete, to control batch
transactions.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-19 09:08:09 -07:00
Kevin Morris
bd8f528011 add Base.as_dict() and Base.json()
Two utility functions for all of our ORM models that will
allow us to easily convert them to Python structures and
JSON data.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-13 10:48:31 -07:00
Kevin Morris
be3bab2ce0 Merge branch 'master' into pu 2021-06-12 20:11:48 -07:00
Justin Kromlinger
8d9f20939c Add modified packages RSS feed to frontend 2021-06-12 20:09:56 -07:00
Justin Kromlinger
4330fe4f33 Add RSS feed for modified packages 2021-06-12 20:09:48 -07:00
Justin Kromlinger
e7db894eb7 RSS: Add ability to specify isPermaLink="false" for GUID 2021-06-12 20:09:39 -07:00
Justin Kromlinger
537349e124 Add modified packages RSS feed to frontend 2021-06-12 19:14:43 -07:00
Justin Kromlinger
2bb30f9bf5 Add RSS feed for modified packages 2021-06-12 19:14:43 -07:00
Justin Kromlinger
18ec8e3cc8 RSS: Add ability to specify isPermaLink="false" for GUID 2021-06-12 19:14:43 -07:00
Kevin Morris
0c1241f8bb add TUVote SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 22:14:38 -07:00
Kevin Morris
8c345a0448 TUVoteInfo: generalize Quorum
SQLite does not support native DECIMAL columns, and for that
reason, we had to switch to using Strings that can hold the data
in the case we are using sqlite.

This commit sets the TUVoteInfo model up in a generic way, that
it always converts to string when setting Quorum (OK for DECIMAL)
and always converts to float when getting Quorum.

This way, we can treat TUVoteInfo.Quorum as the same thing
everywhere.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 21:48:39 -07:00
Kevin Morris
541c978ac4 add PackageRequest SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 21:21:38 -07:00
Kevin Morris
809939ab03 add TUVoteInfo SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 21:00:26 -07:00
Kevin Morris
65ff0e76da aurweb.schema: Fix off-by-one String impls of DECIMAL
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 19:57:52 -07:00
Kevin Morris
3bf4b3717a add RequestType SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 17:37:51 -07:00
Kevin Morris
511f174c8b add PackageBlacklist SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 17:28:08 -07:00
Kevin Morris
163e4d7389 test_package_comaintainer: sanitize newlines
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 17:15:18 -07:00
Kevin Morris
5b856c7af2 add PackageNotification SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 17:14:28 -07:00
Kevin Morris
229df1adef test_package_vote: remove useless stuff
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 16:56:15 -07:00
Kevin Morris
ebd216edfd add PackageComaintainer SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 16:52:45 -07:00
Kevin Morris
fc28c1e5fd add PackageComment SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-11 00:35:18 -07:00
Kevin Morris
11c4926502 add PackageSource SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-10 17:46:29 -07:00
Kevin Morris
d18cfad63e use djangos method of wiping sqlite3 tables
Django uses a reference graph to determine the order
in table deletions that occur. Do the same here.

This commit also adds in the `REGEXP` sqlite function,
exactly how Django uses it in its reference graphing.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-10 17:26:34 -07:00
Kevin Morris
5de7ff64df add PackageVote SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-10 13:55:07 -07:00
Kevin Morris
888cf5118a use declarative_base for all ORM models
This rewrites the entire model base as declarative models.
This allows us to more easily customize overlay fields
in tables and is more common.

This effort also brought some DB violations to light which
this commit addresses.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-10 13:54:27 -07:00
Steven Guikal
b32022a176
Add FIDO/U2F ssh keytypes to default config
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-10 15:32:20 -04:00
Steven Guikal
a625df07e2
Source valid ssh prefixes from config
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2021-06-10 15:32:02 -04:00
Kevin Morris
7f7a975614 remove autoflush from aurweb.db.Session
This causes issues with the declarative API.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-10 03:04:50 -07:00
Kevin Morris
4f09e939ae bugfix: gendummydata.py was producing invalid usernames
As per our regex and policies, usernames should consist of
ascii alphanumeric characters and possibly (-, _ or .).

gendummydata.py was creating unicode versions of some
usernames and adding them into the DB. With our newfound
collations, this becomes a problem as it treats them as
the same.

This should have never been the case here, and so,
gendummydata.py has been patched to normalize all of its
usernames and package names.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-06 21:46:16 -07:00
Kevin Morris
83887b97df Merge branch 'php_fix' into pu 2021-06-06 21:44:11 -07:00
Kevin Morris
25937d9543 Merge branch 'master' into pu 2021-06-06 17:21:57 -07:00
Kevin Morris
f9f41dc99b restore TU_VoteInfo -> utf8mb4_general_ci
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-06 16:30:16 -07:00
Jelle van der Waa
889d358a6d
Add missing ) for addvote.php 2021-06-06 21:49:27 +02:00
Kevin Morris
1874e821f5 add case [in]sensitivity tests + add OfficialProvider model
`ci` in this context means "Case Insensitive".
`cs` in this context means "Case Sensitive".

New models created:
    - OfficialProvider
      This was required to write a test for checking that
      OfficialProviders behaves as we expect, which was the starter
      for the original aurblup bug.

New tests created:
    - test_official_provider

Modified tests:
    - test_package_base: add ci test
    - test_package: add ci test
    - test_session: add cs test
    - test_ssh_pub_key: add cs test

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 23:20:18 -07:00
Kevin Morris
e865a6347f .gitlab-ci.yml: enforce isort and flake8 compliance
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 21:31:57 -07:00
Kevin Morris
5ceeb88bee remove unused imports, rectify isort violations
Files got into the branch that violate both PEP-8 guidelines
and isorts. This fixes them.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 21:27:39 -07:00
Kevin Morris
4d1faca447 test both mysql and sqlite in .gitlab-ci.yml
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:17:48 -07:00
Kevin Morris
62e58b122f fix test_accounts_routes test coverage
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:17:48 -07:00
Kevin Morris
228bc8fe7c fix aurweb.auth test coverage
With mysqlclient, we no longer need to account for a user not existing
when an ssh key is found.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:17:48 -07:00
Kevin Morris
aecb649473 use mysql backend in config.dev
First off: This commit changes the default development database
backend to mysql. sqlite, however, is still completely supported
with the caveat that a user must now modify config.dev to use
the sqlite backend.

While looking into this, it was discovered that our SQLAlchemy
backend for mysql (mysql-connector) completely broke model
attributes when we switched to utf8mb4_bin (binary) -- it does
not correct the correct conversion to and from binary utf8mb4.

The new, replacement dependency mysqlclient does. mysqlclient
is also recommended in SQLAlchemy documentation as the "best"
one available.

The mysqlclient backend uses a different exception flow then
sqlite, and so tests expecting IntegrityError has to be modified
to expect OperationalError from sqlalchemy.exc.

So, for each model that we define, check keys that can't be
NULL and raise sqlalchemy.exc.IntegrityError if we have to.
This way we keep our exceptions uniform.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:17:48 -07:00
Kevin Morris
d7481b9649 modify schema primary keys to be nullable+defaulted
This fixes SQLAlchemy warnings related to primary keys not
having an auto_increment or nullable.

We've done this by making all foreign primary keys nullable.

In ApiRateLimit's case, we can set a default str to act as
a null, which seems a bit more sensible.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Kevin Morris
e5df083d45 use String(max_len) for DECIMAL types with sqlite
This solves an issue where DECIMAL is not native
to sqlite by using a string to store values and
converting them to float in user code.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Kevin Morris
a65a60604a add ApiRateLimit SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Kevin Morris
2b83d2fb6b add PackageRelation SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00
Kevin Morris
a9cfbce11e add RelationType SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-06-05 20:11:17 -07:00