diff --git a/.travis.yml b/.travis.yml index 18e0f53..f733e25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,5 @@ python: sudo: false install: pip install -r requirements.txt script: - - flake8 securitybot/ + - flake8 --ignore F401 securitybot/ - PYTHONPATH=$(pwd) py.test -v tests/ - diff --git a/README.md b/README.md index b59a1f3..440aa64 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Having a database allows alerts to be persistent and means that the bot doesn't ### Securitybot proper The bot itself performs a small set of functions: + 1. Reads messages, interpreting them as commands. 1. Polls each user object to update their state of applicable. 1. Grabs new alerts from the database and assigns them to users or escalates on an unknown user. @@ -55,7 +56,7 @@ The functions for the commands are defined in `commands.py` and their structure ### Messaging Securitybot is designed to be compatible with a wide variety of messaging systems. We currently provide bindings for Slack, but feel free to contribute any other plugins, like for Gitter or Zulip, upstream. -Messaging is made possible by `securitybot/chat/chat.py` which provides a small number of functions for querying users in a messaging group, messaing those users, and sending messages to a specific channel/room. +Messaging is made possible by `securitybot/chat/chat.py` which provides a small number of functions for querying users in a messaging group, messaging those users, and sending messages to a specific channel/room. To add bindings for a new messaging system, subclass `Chat`. ### 2FA @@ -77,11 +78,11 @@ We keep track of whatever information a messaging system gives to us, but really ### Alerts Alerts are uniquely identified by a SHA-256 hash which comes from some hash of the event that generated them. We assume that a SHA-256 hash is sufficiently random for there to be no collisions. -If you encounter a SHA-256 collision, please contact someone your nearest University and enjoy the fame and fortune it brings upon you. +If you encounter a SHA-256 collision, please contact someone at your nearest University and enjoy the fame and fortune it brings upon you. ## FAQ -pls ask us things +Please ask us things ## Contributing Contributors must abide by the [Dropbox Contributor License Agreement][cla]. diff --git a/securitybot/commands.py b/securitybot/commands.py index c1f1a94..099f052 100644 --- a/securitybot/commands.py +++ b/securitybot/commands.py @@ -66,8 +66,8 @@ def ignore(bot, user, args): # Find correct task in user object task = None - if which == 'last' and user.old_tasks: - task = user.old_tasks[-1] + if which == 'last' and user.tasks: + task = user.tasks[-1] elif which == 'current' and user.pending_task: task = user.pending_task if task is None: diff --git a/tests/user_test.py b/tests/user_test.py index 0f10879..1f129f6 100644 --- a/tests/user_test.py +++ b/tests/user_test.py @@ -3,6 +3,7 @@ from collections import defaultdict from datetime import timedelta +from time import sleep import securitybot.user as user import securitybot.bot @@ -279,8 +280,9 @@ def test_not_allow_2fa_flow(self, auth, mock_task): test_user._last_message.text == '') mock_task.stop() - - @patch('securitybot.user.ESCALATION_TIME', timedelta(seconds=-1)) + # Putting escalation time in the past to make sure tests outsisde of + # business hours won't fail + @patch('securitybot.user.ESCALATION_TIME', timedelta(weeks=-1)) @patch('securitybot.tasker.tasker.Task') @patch('securitybot.auth.auth.Auth', autospec=True) def test_auto_escalate(self, auth, mock_task): @@ -299,7 +301,8 @@ def test_auto_escalate(self, auth, mock_task): assert str(test_user._fsm.state) == 'action_performed_check' # Auto-escalation should happen immediately because escalation time - # is set to be zero seconds + # is set in the past + test_user.step() assert str(test_user._fsm.state) == 'task_finished'