Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

test: add metadata unit tests #45

Merged
merged 11 commits into from
Jul 25, 2023
Merged

Conversation

ivanayov
Copy link
Contributor

@ivanayov ivanayov commented Jun 9, 2023

This change adds unit tests for part of the metadata methods.

@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Patch coverage has no change and project coverage change: +32.24 🎉

Comparison is base (6d84b95) 19.82% compared to head (cc2bfee) 52.06%.

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #45       +/-   ##
===========================================
+ Coverage   19.82%   52.06%   +32.24%     
===========================================
  Files           7        7               
  Lines        1281     1281               
===========================================
+ Hits          254      667      +413     
+ Misses       1017      540      -477     
- Partials       10       74       +64     
Flag Coverage Δ
Go-1.19 52.06% <ø> (+32.24%) ⬆️
Go-1.20 52.06% <ø> (+32.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Owner

@rdimitrov rdimitrov left a comment

Choose a reason for hiding this comment

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

It's a start, but there's still work to be done.

I'd strongly suggest having a look at the existing tests in python-tuf, and tuf-js for inspiration and ideas - that should help you get a better idea of what you should be testing and how the test cases should be organized.

ivanayov and others added 6 commits June 30, 2023 15:29
This change adds repository data to use in unit testing, keeping
it the same as in python-tuf

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change adds a mock for os functions

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change implements client simulator for working with local
repositories

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change adds unit tests for part of the metadata methods

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change implements api unit tests for metadata with the same
logic as in python-tuf

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change fixes go linter error of not checking errors returned
by methods in the file system and test client simulators

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
As the `signature` package allows loading keys from RSA PEM files
only, the keys and roles from the python-tuf implementation are
not suitable for the current implementation. This is why a clean
repo is created with new keys in the appropriate format

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change adds test coverage for signing and verigying metadata
with a pre-set keys

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change removes unused keys and test utils for the metadata
unit tests. The removed test utils include filesystem simulator,
which is replaced by the setup functionality and some tidy-up
around the changes

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change updates error assertions in the metadata api tests
to compare error types rather than only a message

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
@ivanayov
Copy link
Contributor Author

Force-pushed a squash with the fixed roles json an the metadata repository, so that commits between them are not broken.

Copy link
Owner

@rdimitrov rdimitrov left a comment

Choose a reason for hiding this comment

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

I've left several comments on things that need to be addressed but otherwise, it looks great 👍

metadata/metadata_api_test.go Outdated Show resolved Hide resolved
metadata/metadata_api_test.go Show resolved Hide resolved
metadata/metadata.go Outdated Show resolved Hide resolved
metadata/metadata_api_test.go Outdated Show resolved Hide resolved
metadata/metadata_api_test.go Outdated Show resolved Hide resolved
metadata/metadata_api_test.go Outdated Show resolved Hide resolved
metadata/metadata_api_test.go Show resolved Hide resolved
metadata/metadata_api_test.go Outdated Show resolved Hide resolved
metadata/metadata_api_test.go Outdated Show resolved Hide resolved
metadata/metadata_test.go Outdated Show resolved Hide resolved
This change provides improvements to the metadata api tests

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
@rdimitrov rdimitrov changed the title Add metadata unit tests test: add metadata unit tests Jul 25, 2023
@rdimitrov rdimitrov merged commit 99662d4 into rdimitrov:main Jul 25, 2023
10 checks passed
kipz pushed a commit to kipz/go-tuf-metadata that referenced this pull request Jan 29, 2024
* Add test repository data

This change adds repository data to use in unit testing, keeping
it the same as in python-tuf

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Add file system simulator

This change adds a mock for os functions

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Add test client simulator

This change implements client simulator for working with local
repositories

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Add metadata unit tests

This change adds unit tests for part of the metadata methods

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Add metadata api tests

This change implements api unit tests for metadata with the same
logic as in python-tuf

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Fix go linter in test simulators

This change fixes go linter error of not checking errors returned
by methods in the file system and test client simulators

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Create clean test metadata repository

As the `signature` package allows loading keys from RSA PEM files
only, the keys and roles from the python-tuf implementation are
not suitable for the current implementation. This is why a clean
repo is created with new keys in the appropriate format

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Add metadata sign/verify test

This change adds test coverage for signing and verigying metadata
with a pre-set keys

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Cleanup unnecessary functionality

This change removes unused keys and test utils for the metadata
unit tests. The removed test utils include filesystem simulator,
which is replaced by the setup functionality and some tidy-up
around the changes

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Fix metadata api tests to verify error type

This change updates error assertions in the metadata api tests
to compare error types rather than only a message

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

* Improve metadata tests

This change provides improvements to the metadata api tests

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>

---------

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
Co-authored-by: Ivana Atanasova <iyovcheva@iyovcheva7MD6R.vmware.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants