Skip to content
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

[issue-722] add calculate_package_verification_code() #723

Merged
merged 1 commit into from Jul 12, 2023

Conversation

armintaenzertng
Copy link
Collaborator

also add calculate_file_checksum(), as this is needed by the package verification code

fixes #722

@armintaenzertng
Copy link
Collaborator Author

armintaenzertng commented Jul 5, 2023

It seems that Windows yields different results when using calculate_file_checksum() than Ubuntu does.

Edit: This was due to git clone changing the line-ending depending on the OS. To circumvent this, the test files are now generated on the fly as byte streams.

@armintaenzertng armintaenzertng force-pushed the addVerificationCodeCalculator branch 2 times, most recently from ca98d6c to be46a07 Compare July 11, 2023 08:20

with pytest.raises(FileNotFoundError) as err:
calculate_package_verification_code([file1])
assert unknown_file_name in err.value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is never reached, you need to unindent it one level.
You also have to explicitly convert the error to string, otherwise this assertion fails, i.e. str(err.value)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! :)


def calculate_package_verification_code(files: List[File]) -> str:
list_of_file_hashes = []
hash_algorithm_name = ChecksumAlgorithm.SHA1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a parameter to the function and then consequently used below wherever SHA1 is explicitly mentioned? Or is there a reason we only want to support SHA1 here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

also add calculate_file_checksum(), as this is needed by the package verification code

Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
@fholger fholger merged commit cba5db5 into spdx:main Jul 12, 2023
33 checks passed
@armintaenzertng armintaenzertng deleted the addVerificationCodeCalculator branch July 12, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add back package verification code calculation
2 participants