Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions setup.cfg → .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ commit = True
tag = False

[bumpversion:file:mozilla_django_oidc/__init__.py]

[wheel]
universal = 1

[flake8]
max-line-length = 99
exclude = docs,build
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ common_steps: &common_steps
command: echo 127.0.0.1 testprovider | tee -a /etc/hosts
- run:
name: Install latest lib build
command: . /testrp_env/bin/activate && pip install /tmp/workspace/mozilla-django-oidc-dev.tar.gz
command: . /testrp_env/bin/activate && pip install /tmp/workspace/mozilla-django-oidc-dev.tar.gz[test]
- run:
name: Override django version
command: . /testrp_env/bin/activate && pip install $DJANGO_VERSION
Expand Down Expand Up @@ -45,8 +45,9 @@ jobs:
steps:
- checkout
- run: mkdir workspace
- run: pip install '.[dev]'
- run: make sdist
- run: mv dist/mozilla-django-oidc-* workspace/mozilla-django-oidc-dev.tar.gz
- run: mv dist/mozilla_django_oidc-* workspace/mozilla-django-oidc-dev.tar.gz
- persist_to_workspace:
root: workspace
paths:
Expand Down
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 99
exclude = docs,build
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
name: Python ${{ matrix.python_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
name: Codecov
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: pip install codecov tox tox-gh-actions
- name: Run tox
run: tox
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v5
with:
verbose: true
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
name: Mozilla Django OIDC Release
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
Expand All @@ -28,7 +28,7 @@ jobs:
--outdir dist/
.
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
uses: pypa/gh-action-pypi-publish@v1
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
with:
user: __token__
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Contributors
* Antti Palola (`@anttipalola <https://github.com/anttipalola>`_)
* Bono de Visser (`@kerrermanisNL <https://github.com/kerrermanisNL>`_)
* Chris Brantley (`@chrisbrantley <https://github.com/chrisbrantley>`_)
* Ryan Johnson (`@escattone <https://github.com/escattone>`_)
27 changes: 14 additions & 13 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ Ready to contribute? Here's how to set up `mozilla-django-oidc` for local develo

$ git clone git@github.com:your_name_here/mozilla-django-oidc.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
3. Create a virtual environment and install the package with its
development dependencies. This command will install all the tools
needed for testing and linting::

$ mkvirtualenv mozilla-django-oidc
$ cd mozilla-django-oidc/
$ python setup.py develop
$ python -m venv .venv
$ source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
$ pip install -e .[dev]

4. Create a branch for local development::

Expand All @@ -77,12 +80,10 @@ Ready to contribute? Here's how to set up `mozilla-django-oidc` for local develo
5. When you're done making changes, check that your changes pass flake8 and the
tests, including testing other Python versions with tox::

$ flake8 mozilla_django_oidc tests
$ python setup.py test
$ make lint
$ make test
$ tox

To get flake8 and tox, just pip install them into your virtualenv.

6. Make sure you update ``HISTORY.rst`` with your changes in the following categories

* Backwards-incompatible changes
Expand All @@ -106,9 +107,9 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.6+ and for PyPy. Check
`<https://github.com/mozilla/mozilla-django-oidc/actions>`_
and make sure that the tests pass for all supported Python versions.
3. The pull request should work for Python 3.8+. Check
`<https://github.com/mozilla/mozilla-django-oidc/actions>`_ and make sure
that the tests pass for all supported Python versions.

Tips
----
Expand All @@ -120,14 +121,14 @@ We use tox to run tests::

To run a specific environment, use the ``-e`` argument::

$ tox -e py27-django111
$ tox -e py312-django420


You can also run the tests in a virtual environment without tox::

$ DJANGO_SETTINGS_MODULE=tests.settings django-admin test
$ make test


You can specify test modules to run rather than the whole suite::

$ DJANGO_SETTINGS_MODULE=tests.settings django-admin test tests.test_views
$ DJANGO_SETTINGS_MODULE=tests.settings python -m django test tests.test_views
6 changes: 5 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
recursive-include mozilla_django_oidc *.html *.png *.gif *js *.css *jpg *jpeg *svg *py

include .flake8
include .bumpversion.cfg
recursive-include docs *
recursive-include integration_tests *
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -rf {} +

lint: ## check style with flake8
flake8 mozilla_django_oidc tests

test: ## run tests quickly with the default Python
DJANGO_SETTINGS_MODULE=tests.settings django-admin test
DJANGO_SETTINGS_MODULE=tests.settings python -m django test

test-all: ## run tests on every Python version with tox
tox

coverage: ## check code coverage quickly with the default Python
DJANGO_SETTINGS_MODULE=tests.settings coverage run --source mozilla_django_oidc `which django-admin` test
coverage run --source mozilla_django_oidc -m django test --settings=tests.settings
coverage report -m
coverage html
open htmlcov/index.html
Expand All @@ -37,10 +38,13 @@ docs: ## generate Sphinx HTML documentation, including API docs
$(MAKE) -C docs clean
$(MAKE) -C docs html

release: clean ## package and upload a release
python setup.py sdist upload
python setup.py bdist_wheel upload
build: clean ## build the sdist and wheel
python -m build . --sdist --wheel
ls -l dist

release: build ##package and upload a release
twine upload dist/*

sdist: clean ## package
python setup.py sdist
python -m build . --sdist
ls -l dist
14 changes: 5 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,16 @@ Django of your choice. Here is such an example:

.. code-block:: shell

$ virtualenv -p /path/to/bin/python3.8 venv
$ source venv
(venv) $ pip install -r requirements/requirements_dev.txt
(venv) $ DJANGO_SETTINGS_MODULE=tests.settings django-admin test
$ python -m venv venv
$ source ./venv/bin/activate
(venv) $ pip install '.[dev]'
(venv) $ make test

Measuring code coverage, continuing the steps above:

.. code-block:: shell

(venv) $ pip install coverage
(venv) $ DJANGO_SETTINGS_MODULE=tests.settings coverage run --source mozilla_django_oidc `which django-admin` test
(venv) $ coverage report
(venv) $ coverage html
(venv) $ open htmlcov/index.html
(venv) $ make coverage

Local development
-----------------
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Based in the `docker-test-mozilla-django-oidc` images
# https://github.com/mozilla/docker-test-mozilla-django-oidc

version: '3'
services:
testprovider:
stdin_open: true
Expand Down Expand Up @@ -36,7 +35,8 @@ services:
- testrp
- testprovider
command: >-
bash -c "cd /integration_tests &&
bash -c "pip install 'splinter[selenium]' &&
cd /integration_tests &&
wait-for-it -t 60 -p 8080 -h testprovider &&
wait-for-it -t 60 -p 8081 -h testrp &&
python integration_tests.py"
11 changes: 6 additions & 5 deletions integration_tests/integration_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from splinter import Browser
from splinter import Browser, Config


class IntegrationTest(unittest.TestCase):
Expand All @@ -13,10 +13,11 @@ def __init__(self, *args, **kwargs):
"password": "example_p@ssw0rd",
"email": "example@example.com",
}
self.splinter_config = Config(headless=True)

def setUp(self):
"""Create test account in `testprovider` instance"""
with Browser(self.webdriver, headless=True) as browser:
with Browser(self.webdriver, config=self.splinter_config) as browser:
browser.visit("http://testprovider:8080/account/signup")
browser.find_by_css("#id_username").fill(self.account["username"])
browser.find_by_css("#id_password").fill(self.account["password"])
Expand All @@ -26,7 +27,7 @@ def setUp(self):

def tearDown(self):
"""Remove test account from `testprovider` instance"""
with Browser(self.webdriver, headless=True) as browser:
with Browser(self.webdriver, config=self.splinter_config) as browser:
self.perform_login(browser)
browser.visit("http://testprovider:8080/account/delete")
browser.find_by_css(".btn-danger").click()
Expand All @@ -46,7 +47,7 @@ def perform_logout(self, browser):

def test_login(self):
"""Test logging in `testrp` using OIDC"""
browser = Browser(self.webdriver, headless=True)
browser = Browser(self.webdriver, config=self.splinter_config)

# Check that user is not logged in
browser.visit("http://testrp:8081")
Expand All @@ -63,7 +64,7 @@ def test_login(self):

def test_logout(self):
"""Test logout functionality of OIDC lib"""
browser = Browser(self.webdriver, headless=True)
browser = Browser(self.webdriver, config=self.splinter_config)

# Check that user is not logged in
browser.visit("http://testrp:8081")
Expand Down
90 changes: 90 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
[build-system]
requires = [
"setuptools>=61.0.0",
"wheel"
]
build-backend = "setuptools.build_meta"

[project]
name = "mozilla-django-oidc"
dynamic = ["version", "readme"]
description = "A lightweight authentication and access management library for integration with OpenID Connect enabled authentication services."
authors = [
{ name = "Tasos Katsoulas", email = "akatsoulas@mozilla.com" },
{ name = "John Giannelos", email = "jgiannelos@mozilla.com" }
]
license = { text = "MPL-2.0" }
keywords = ["mozilla-django-oidc"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.2",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Intended Audience :: Developers",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

dependencies = [
"Django >= 3.2",
"pyjwt",
"requests",
"cryptography",
]

[project.urls]
Homepage = "https://github.com/mozilla/mozilla-django-oidc"
Documentation = "https://mozilla-django-oidc.readthedocs.io"
Changelog = "https://github.com/mozilla/mozilla-django-oidc/releases"

[project.optional-dependencies]
drf = [
"djangorestframework>=3.14",
]
test = [
"bumpversion",
"ipython",
"ipdb",
"djangorestframework>=3.14",
"pre-commit",
"responses",
"importlib-metadata; python_version < '3.10'",
"splinter[selenium]>=0.21.0",
"coverage",
"tox",
]
lint = [
"flake8",
]
build = [
"build",
]
docs = [
"sphinx",
"sphinx_rtd_theme",
"readthedocs-sphinx-search",
]
dev = [
"mozilla-django-oidc[test,docs,drf,lint,build]",
]

[tool.setuptools]
include-package-data = true
zip-safe = false

[tool.setuptools.dynamic]
version = { attr = "mozilla_django_oidc.__version__" }
readme = { file = ["README.rst"], "content-type" = "text/x-rst" }

[tool.setuptools.packages.find]
include = ["mozilla_django_oidc", "mozilla_django_oidc.*"]
exclude = ["build*", "dist*", "*.egg-info*"]
Loading