-
Notifications
You must be signed in to change notification settings - Fork 24
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
[GT-157] Drop messages from banned dns, and add tests for messages saving to the correct queue #238
base: dev
Are you sure you want to change the base?
Conversation
- compares message signer with dns in banned dns list - which is got from config file and sorted through
- now makes more sense - has an error message - reworking of some if/elif/else statements
unit tests to be written |
Pushed what I was working on as going on holiday |
- Mock out the _handle_msg() function called by _save_msg_to_queue() (the function we are testing), as it fails due to client signers and certificates not matching. - It is easier to mock out the failing function instead, as it is not the function we are testing in this test. - To test _save_msg_to_queue, we are assuming the message's certificate and signer match.
- this was outdated code no longer in use
- we can check the log output matches an expected string - to check the test has passed or failed
- also re-adds the creation of the certificate which was missing
test/test_ssm.py
Outdated
for dn in valid_dns: | ||
# Capture the log output so we can use it in assertions | ||
with LogCapture() as log: | ||
print("Testing dn:", dn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't generally be printing in tests. We only care about the output if something fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
- removes printing in test - rewrites line using with context manager - changes variable name - passes cp as an argument to the fucntion - shortens long lines
updating to latest dev |
ssm/agents.py
Outdated
else: | ||
log.warning('DN in banned dns list is not in ' | ||
'the correct format: %s', line) | ||
finally: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we have a context manager for the file, we can get rid of the try...finally
wrapper (and the `f=None') as the file will close as soon as the handler is exited (whether normally or by exception).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/test_ssm.py
Outdated
|
||
ssm._save_msg_to_queue(message_rejected, empaid) | ||
|
||
print(str(log)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's this and the print below that also need removing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
testfixtures will need adding to requirements-test.txt so it's available in Travis. |
- this makes it available in Travis - used in class TestMsgToQueue
- removes remaining print statements to simplify logging output - adds teardown - also improves comments
- with the addition of a context manager for a file in an earlier commit, this wasn't needed
resolves #184