-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add an __eq__
method
#48
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c9a252d
Add an `__eq__` method
DarkaMaul a4f6816
Merge branch 'main' into dm/add-equality-method
DarkaMaul 636ab8e
Add missing tests
DarkaMaul 3984f73
Fix type hint
DarkaMaul 1e4ce3c
Fix name
DarkaMaul b5f7ca2
Merge branch 'main' into dm/add-equality-method
woodruffw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from datetime import datetime, timezone | ||
from pathlib import Path | ||
|
||
from rfc3161_client import TimeStampRequest, decode_timestamp_response | ||
from rfc3161_client._rust import parse_timestamp_request | ||
|
||
_HERE = Path(__file__).parent.resolve() | ||
_FIXTURE = _HERE / "fixtures" | ||
|
||
|
||
class TestTimestampResponse: | ||
def test_parsing_good(self): | ||
timestamp_response = decode_timestamp_response((_FIXTURE / "response.tsr").read_bytes()) | ||
assert timestamp_response.status == 0 | ||
|
||
tst_info = timestamp_response.tst_info | ||
assert tst_info.name.value.rfc4514_string() == "CN=Test TSA Timestamping,O=local" | ||
assert tst_info.nonce == 3937359519792308179 | ||
assert not tst_info.ordering | ||
assert tst_info.policy.dotted_string == "1.3.6.1.4.1.57264.2" | ||
assert tst_info.serial_number == 693290210947147715387173185458430793885588677084 | ||
assert tst_info.version == 1 | ||
assert datetime(2024, 10, 8, 15, 40, 32, tzinfo=timezone.utc) == tst_info.gen_time | ||
assert tst_info.message_imprint.message.hex().startswith("9b71d224bd62f3785d96d") | ||
|
||
assert tst_info.accuracy.seconds == 1 | ||
assert tst_info.accuracy.millis is None | ||
assert tst_info.accuracy.micros is None | ||
|
||
def test_equality(self): | ||
timestamp_response = decode_timestamp_response((_FIXTURE / "response.tsr").read_bytes()) | ||
other_response = decode_timestamp_response((_FIXTURE / "other_response.tsr").read_bytes()) | ||
|
||
assert timestamp_response != other_response | ||
assert decode_timestamp_response( | ||
(_FIXTURE / "response.tsr").read_bytes() | ||
) == decode_timestamp_response((_FIXTURE / "response.tsr").read_bytes()) | ||
|
||
|
||
class TestTimestampRequest: | ||
def test_parsing_good(self): | ||
timestamp_request: TimeStampRequest = parse_timestamp_request( | ||
(_FIXTURE / "request.der").read_bytes() | ||
) | ||
assert timestamp_request.version == 1 | ||
assert timestamp_request.cert_req | ||
assert timestamp_request.nonce == 3937359519792308179 | ||
assert timestamp_request.policy is None | ||
assert timestamp_request.message_imprint.message.hex().startswith("9b71d224bd62f3785d96d") | ||
|
||
def test_equality(self): | ||
timestamp_request = parse_timestamp_request((_FIXTURE / "request.der").read_bytes()) | ||
other_request = parse_timestamp_request((_FIXTURE / "other_request.der").read_bytes()) | ||
|
||
assert timestamp_request != other_request |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
FLAG: The annotation was wrong but I didn't think we had to create a whole new PR just for it :)