Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests after updates to var names. #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .install_deps
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

if [[ $DEPS_VERSION = "OLD" ]]; then
pip install Jinja2==2.4 jupyterhub==0.9.0 lxml==4.2.1 signxml==2.6.0 pytz==2019.1
pip install Jinja2==2.7 jupyterhub==0.9.0 lxml==4.2.1 signxml==2.6.0 pytz==2019.1
pip install pytest==4.0.0 pytest-asyncio==0.10.0 pytest-cov==2.0.0;
elif [[ $DEPS_VERSION = "AFTER38" ]]; then
pip install Jinja2==2.4 jupyterhub==0.9.0 lxml==4.3.5 signxml==2.6.0 pytz==2019.1
pip install Jinja2==2.7 jupyterhub==0.9.0 lxml==4.3.5 signxml==2.6.0 pytz==2019.1
pip install pytest==4.0.0 pytest-asyncio==0.10.0 pytest-cov==2.0.0;
else
pip install --upgrade --pre -r requirements.txt
Expand Down
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: python
sudo: false
os: linux
cache:
- pip

Expand All @@ -18,9 +18,15 @@ script:
after_success:
- codecov

matrix:
jobs:
fast_finish: true
include:
- name: "Python 3.9 Oldest Dependencies"
python: "3.9"
env: DEPS_VERSION=AFTER38
- name: "Python 3.9 Latest Dependencies"
python: "3.9"
env: DEPS_VERSION=NEW
- name: "Python 3.8 Oldest Dependencies"
python: "3.8"
env: DEPS_VERSION=AFTER38
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Jinja2>=2.4
Jinja2>=2.7
jupyterhub>=0.9.0
lxml>=4.2.1
signxml>=2.6.0
Expand Down
18 changes: 16 additions & 2 deletions samlauthenticator/samlauthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,24 @@ def _optional_user_add(self, username):
# say something like "if adding the user is successful, return username"
return not subprocess.call([self.create_system_user_binary, username])

# JH did a clumsy job of renaming (white|black)list -> (allowed|blocked)_users,
# so it falls on me to paper over their mistakes.
def _check_blocked_users(self, username):
try:
return self.check_blacklist(username)
except DeprecationWarning:
return self.check_blocked_users(username)

def _check_allowed_users(self, username):
try:
return self.check_whitelist(username)
except DeprecationWarning:
return self.check_allowed_users(username)

def _check_username_and_add_user(self, username):
if self.validate_username(username) and \
self.check_blacklist(username) and \
self.check_whitelist(username):
self._check_blocked_users(username) and \
self._check_allowed_users(username):
if self.create_system_users:
if self._optional_user_add(username):
# Successfully added user
Expand Down
4 changes: 4 additions & 0 deletions tests/test_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,14 @@ def test_check_username_valid_username_no_black_lists(self):
a._optional_user_add = MagicMock()
a._optional_user_add.return_value = True
a.whitelist = {'bluedata'}
a.allowed_users = {'bluedata'}

assert a._check_username_and_add_user('bluedata')

a._optional_user_add.assert_called_once_with('bluedata')

a.whitelist = {'not_bluedata'}
a.allowed_users = {'not_bluedata'}
a._optional_user_add.reset_mock()

assert not a._check_username_and_add_user('bluedata')
Expand All @@ -636,12 +638,14 @@ def test_check_username_valid_username_no_white_lists(self):
a._optional_user_add = MagicMock()
a._optional_user_add.return_value = True
a.blacklist = {'bluedata'}
a.blocked_users = {'bluedata'}

assert not a._check_username_and_add_user('bluedata')

a._optional_user_add.assert_not_called()

a.blacklist = {'not_bluedata'}
a.blocked_users = {'blocked_users'}

assert a._check_username_and_add_user('bluedata')

Expand Down