Skip to content
Snippets Groups Projects
  1. Aug 22, 2022
  2. Jan 08, 2022
  3. Nov 29, 2021
    • Kevin Morris's avatar
      feat(testing): add email testing utilities · 9fb1fbe3
      Kevin Morris authored
      
      Changes:
      - util/sendmail now populates email files in the 'test-emails' directory.
          - util/sendmail does this in a serialized fashion based off of
            the test suite and name retrieved from PYTEST_CURRENT_TEST
            in the format: `<test_suite>_<test_function>.n.txt` where n
            is increased by one every time sendmail is run.
      - pytest conftest fixtures have been added for test email setup;
        it wipes out old emails for the particular test function being run.
      - New aurweb.testing.email.Email class allows developers to test
        against emails stored by util/sendmail. Simple pass the serial
        you want to test against, starting at serial = 1; e.g. Email(serial).
      
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
      Verified
      9fb1fbe3
  4. Nov 15, 2021
  5. Sep 20, 2021
  6. Sep 09, 2021
  7. Jun 25, 2021
    • Kevin Morris's avatar
      Improve Docker ecosystem · 5bd46d18
      Kevin Morris authored
      
      Instead of using Dockerfile for everything, we've introduced
      a docker-compose.yml file and kept the Dockerfile to producing
      a pure base image for the services defined.
      
      docker-compose services:
      
      - `mariadb` - Setup mariadb
      - `sharness` - Run sharness suites
      - `pytest-mysql` - Run pytest suites with MariaDB
      - `pytest-sqlite` - Run pytest suites with SQLite
      - `test` - Run all tests and produce a collective coverage report
          - This target mounts a cache volume and copies any successful
            coverage report back to `./cache/.coverage`. Users can run
            `./util/fix-coverage ./cache/.coverage` to rewrite source
            code paths and move coverage into place to view reports
            on your local system.
      
      == Get Started ==
      
      Build `aurweb:latest`.
      
          $ docker build -t aurweb:latest .
      
      Run all tests via `docker-compose`.
      
          $ docker-compose up test
      
      You can also purely run `pytest` in SQLite or MariaDB modes.
      
          $ docker-compose up pytest-sqlite
          $ docker-compose up pytest-mysql
      
      Or `sharness` alone, which only uses SQLite internally.
      
          $ docker-compose up sharness
      
      After running tests, coverage reports are stored in `./cache/.coverage`.
      This database was most likely created in a different path, and so it
      needs to be sanitized with `./util/fix-coverage`.
      
          $ ./util/fix-coverage cache/.coverage
          Copied coverage db to /path/to/aurweb/.coverage.
          $ coverage report
          ...
          $ coverage html
          $ coverage xml
          ...
      
      Defined components:
      
      **Entrypoints**
      
      - mariadb-entrypoint.sh - setup mariadb and run its daemon
      - test-mysql-entrypoint.sh - setup mysql configurations
      - test-sqlite-entrypoint.sh - setup sqlite configurations
      - tests-entrypoint.sh - setup mysql and sqlite configurations
      
      **Scripts**
      
      - run-mariadb.sh - setup databases
      - run-pytests.sh - run pytest suites
      - run-sharness.sh - run sharness suites
      - run-tests.sh - run both pytests and sharness
      
      **Health**
      
      - mariadb.sh - A healthcheck script for the mariadb service
      - pytest.sh - A healthcheck script for the pytest-* services
      - sharness.sh - A healthcheck script for the sharness service
      
      This Docker configuration is setup for tests, but should be
      extendable for web and git servers.
      
      **Changes to Makefile**
      
      - Remove `.coverage` in the `clean` target
      - Add a `coverage` target which prints a report and outputs xml
      
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
      5bd46d18
  8. Jun 06, 2021
    • Kevin Morris's avatar
      add passreset routes · a33d076d
      Kevin Morris authored
      
      Introduced `get|post` `/passreset` routes. These routes mimic the
      behavior of the existing PHP implementation, with the exception of
      HTTP status code returns.
      
      Routes added:
          GET /passreset
          POST /passreset
      
      Routers added:
          aurweb.routers.accounts
      
      * On an unknown user or mismatched resetkey (where resetkey must ==
        user.resetkey), return HTTP status NOT_FOUND (404).
      * On another error in the request, return HTTP status BAD_REQUEST (400).
      
      Both `get|post` routes requires that the current user is **not**
      authenticated, hence `@auth_required(False, redirect="/")`.
      
      + Added auth_required decorator to aurweb.auth.
      + Added some more utility to aurweb.models.user.User.
      + Added `partials/error.html` template.
      + Added `passreset.html` template.
      + Added aurweb.db.ConnectionExecutor functor for paramstyle logic.
        Decoupling the executor logic from the database connection logic
        is needed for us to easily use the same logic with a fastapi
        database session, when we need to use aurweb.scripts modules.
      
      At this point, notification configuration is now required to complete
      tests involved with notifications properly, like passreset.
      `conf/config.dev` has been modified to include [notifications] sendmail,
      sender and reply-to overrides. Dockerfile and .gitlab-ci.yml have been
      updated to setup /etc/hosts and start postfix before running tests.
      
      * setup.cfg: ignore E741, C901 in aurweb.routers.accounts
      
      These two warnings (shown in the commit) are not dangerous and a bi-product
      of maintaining compatibility with our current code flow.
      
      Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
      a33d076d
Loading