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

Add and use a new IsPathAccessible API before accessing the .git dir #1006

Merged
merged 14 commits into from
Aug 18, 2024

Conversation

eyalbe4
Copy link
Contributor

@eyalbe4 eyalbe4 commented Aug 16, 2024

This is an attempt to fix jfrog/jfrog-cli#2442.
The PR adds a new IsPathAccessible API, in addition to the existing IsPathExists functions. This is because the existing IsPathExists returns false in case of any error that occurred while accessing the directory, and not only in the case that the directory doesn't exist.
The new IsPathAccessible returns false in case the directory exists, but the user doesn't have permissions to access it. The usage of the new API by the Artifactory Upload code flow is expected to resolve the above issue.

@eyalbe4 eyalbe4 added the bug Something isn't working label Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@eyalbe4 eyalbe4 changed the title IsPathExists API returns true if there's no permission to access the directory Add and use a new IsPathAccessible API before accessing the .git dir Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 16, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 16, 2024
utils/io/fileutils/files_test.go Outdated Show resolved Hide resolved
"github.com/stretchr/testify/assert"
)

func TestIsPathExistsAndIsPathAccessible(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

for isAccessible should we create a file without permissions and test that it returns false as expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried adding a test that creates a file without permissions, but you have no idea how challenging it is to test this. The major challenge comes from the fact that Windows and Linux/MacOS treat files without permissions completely differently. It is hard to make all OS work inside a single test. The only option I found was to split the test into two files, so that only one of them compilers for Windows. This is due to a package that can handle Windows locking. I ended up giving up and just testing the IsPathAccessible API with non existing files. It's just not worth the complexity @sverdlov93.

@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 17, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 17, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 17, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 17, 2024
Copy link
Contributor

👍 Frogbot scanned this pull request and did not find any new security issues.


@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 18, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 18, 2024
@eyalbe4 eyalbe4 added the safe to test Approve running integration tests on a pull request label Aug 18, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 18, 2024
@eyalbe4 eyalbe4 merged commit c6062ab into jfrog:dev Aug 18, 2024
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants