aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_fernet.py
Commit message (Collapse)AuthorAgeFilesLines
* Add a way to pass current time to Fernet (#5256)Jakub Stasiak2020-06-141-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a way to pass current time to Fernet The motivation behind this is to be able to unit test code using Fernet easily without having to monkey patch global state. * Reformat to satisfy flake8 * Trigger a Fernet.encrypt() branch missing from coverage * Revert specifying explicit current time in MultiFernet.rotate() Message's timestamp is not verified anyway since ttl is None. * Change the Fernet's explicit current time API slightly This's been suggested in code review. * Fix a typo * Fix a typo * Restore full MultiFernet test coverage and fix a typo * Restore more coverage time.time() is not called by MultiFernet.rotate() anymore so the monkey patching and lambda need to go, because the patched function is not used and coverage calculation will rightfully notice it. * Remove an unused import * Document when the *_at_time Fernet methods were added
* Add support for extracting timestamp from a Fernet token (#4229)Paul Kehrer2018-05-121-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add API for retrieving the seconds-to-expiry for the token, given a TTL. * Process PR feedback: * Do compute the TTL, but just the age of the token. The caller can decided what to do next. * Factored out the HMAC signature verification to a separate function. * Fixed a copy&paste mistake in the test cases * Tests cleanup. * `struct` no longer needed * Document `def age()` * typo in `age()` documentation * token, not data * remove test for TTL expiry that is already covered by the parameterized `test_invalid()`. * let's call this extract_timestamp and just return timestamp * review comments * it's UNIX I know this
* Add Multifernet.rotate method (#3979)Chris Wolfe2017-10-191-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * add rotate method * add some more tests for the failure modes * start adding some documentation for the rotate method * operate on a single token at a time, leave lists to the caller * add versionadded add versionadded, drop rotate from class doctest * give rotate a doctest * single level, not aligned * add changelog for mf.rotate * show that, once rotated, the old fernet instance can no longer decrypt the token * add the instead of just the how * update docs to reflect removal of ttl from rotate * update tests * refactor internal methods so that we can extract the timestamp * implement rotate * update wordlist (case sensitive?) * lints * consistent naming * get_token_data/get_unverified_token_data -> better name * doc changes * use the static method, do not treat as imethod * move up to MultiFernet docs * add to authors * alter wording * monkeypatch time to make it less possible for the test to pass simply due to calls occuring in less than one second * set the time after encryption to make sure that the time is preserved as part of re-encryption
* pass bytes to modes/algorithms like we shouldPaul Kehrer2016-03-071-2/+2
|
* fernet fix: ignore the timestamp entirely when no ttl is setPaul Kehrer2016-01-211-0/+9
| | | | | | Previously if the token claimed to have been generated more than 60 seconds in the future we would raise InvalidToken even if ttl was set to None.
* Replace the remaining occurrences of six.u with the u prefixEeshan Garg2015-04-291-2/+2
|
* alter vector file loader to support passing read modePaul Kehrer2014-11-271-1/+4
|
* Update the license header for every source file, as well as the documentation.Alex Gaynor2014-11-161-12/+3
| | | | Fixes #1209
* Fixed #1436 -- mark the multifernet tests as requiring the backends they needAlex Gaynor2014-10-241-1/+4
|
* Change how we represented that a test requires a backend.Alex Gaynor2014-10-231-1/+2
| | | | This way is more extensible and requires less maintaince
* flake8 + cleanupAlex Gaynor2014-10-201-7/+6
|
* Handle non-iterable arguments reasonableAlex Gaynor2014-10-201-0/+4
|
* Fixes #1327 -- adds multifernetAlex Gaynor2014-10-201-1/+32
|
* Fixed an issue in fernet where the wrong exception would occur on an ↵Alex Gaynor2014-10-191-2/+7
| | | | | | all-nulls input. Also switched a few tests to not generate a key
* Move the supported marks to class level for fernetAlex Gaynor2014-10-191-52/+11
|
* Move cryptography.vectors to cryptography_vectorsAlex Stapleton2014-03-241-7/+9
| | | | | | | All vectors are now stored in the subpackage in the vectors/ folder. This package is automatically installed by setup.py test and will also be uploaded with a matching version number by the PyPI upload task.
* Load vectors from cryptography.vectorsMatthew Iversen2014-03-221-5/+4
|
* Added future imports and licenses that are missingAlex Gaynor2014-03-081-0/+2
|
* add test marks to fernet so backends without cipher (or AES/CBC) will skipPaul Kehrer2014-01-091-0/+50
|
* Handle invalid timestamp lengthAlex Gaynor2013-12-201-0/+5
|
* Replace assertions with real error checksAlex Gaynor2013-12-161-0/+9
|
* Address dreid's commentsAlex Gaynor2013-12-161-10/+16
|
* An API for generating keysAlex Gaynor2013-11-221-1/+1
|
* fix, technicallyAlex Gaynor2013-11-221-1/+1
|
* Hide the dangerous bitsAlex Gaynor2013-11-221-8/+7
|
* Key in the right placeAlex Gaynor2013-11-201-5/+5
|
* Include the licenseAlex Gaynor2013-11-021-0/+13
|
* py3k fixesAlex Gaynor2013-10-311-2/+2
|
* write more readablyAlex Gaynor2013-10-311-3/+1
|
* A test for roundtrippingAlex Gaynor2013-10-311-0/+7
|
* Fixed pep8 issuesAlex Gaynor2013-10-311-6/+4
|
* Started working on the invalid casesAlex Gaynor2013-10-311-6/+22
|
* Use raw vector filesAlex Gaynor2013-10-311-19/+37
|
* py3k syntax fixAlex Gaynor2013-10-311-2/+2
|
* Address pep8 concernsAlex Gaynor2013-10-311-3/+5
|
* Fixed test and implementationAlex Gaynor2013-10-311-2/+8
|
* Added test cases, fixed a bugAlex Gaynor2013-10-311-0/+23