[GT-157] Drop messages from banned dns, and add tests for messages saving to the correct queue#238
[GT-157] Drop messages from banned dns, and add tests for messages saving to the correct queue#238
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
| 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.
Shouldn't generally be printing in tests. We only care about the output if something fails.
- 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 |
| else: | ||
| log.warning('DN in banned dns list is not in ' | ||
| 'the correct format: %s', line) | ||
| finally: |
There was a problem hiding this comment.
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).
|
|
||
| ssm._save_msg_to_queue(message_rejected, empaid) | ||
|
|
||
| print(str(log)) |
There was a problem hiding this comment.
There's this and the print below that also need removing.
|
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
|
|
||
| self.ca_certpath = os.path.join(TEST_CA_DIR, hash_name.strip() + '.0') | ||
| with open(self.ca_certpath, 'w') as ca_cert: | ||
| ca_cert.write(cert_string) |
Check failure
Code scanning / CodeQL
Clear-text storage of sensitive information
…torage-records [apel#238] Add storage record type for logger






resolves #184