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

fix: Fix example configs and README.md file #2215

Closed
wants to merge 4 commits into from

Conversation

onidoru
Copy link
Contributor

@onidoru onidoru commented Jan 31, 2024

What type of PR is this?
documentation

Which issue does this PR fix:
Example LDAP configs do not represent the actual state of things and are outdated.

# could also run $ make verify-config
# it's also the same problem with `examples/config-ldap-credentials.json`, so it's excluded from the Makefile
$ ./bin/zot-linux-amd64 verify examples/config-example.json 
{"level":"error","error":"1 error(s) decoding:\n\n* 'HTTP.Auth.LDAP' has invalid keys: binddn, bindpassword","time":"2024-01-16T23:36:27+02:00","message":"failed to unmarshaling new config"}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@andaaron andaaron left a comment

Choose a reason for hiding this comment

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

Change looks good, but we should make sure we also call make verify-config in CI.

@onidoru onidoru force-pushed the change_example_ldap_configs branch from d6cd646 to 7a4e289 Compare February 5, 2024 17:05
Copy link

codecov bot commented Feb 5, 2024

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (aafb1a5) 92.80% compared to head (8a61bbc) 92.78%.

Files Patch % Lines
pkg/cli/server/root.go 52.94% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2215      +/-   ##
==========================================
- Coverage   92.80%   92.78%   -0.02%     
==========================================
  Files         166      166              
  Lines       21798    21811      +13     
==========================================
+ Hits        20230    20238       +8     
- Misses        980      984       +4     
- Partials      588      589       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@onidoru onidoru force-pushed the change_example_ldap_configs branch 2 times, most recently from 95eca03 to b3035fa Compare February 5, 2024 22:57
pkg/cli/server/root.go Show resolved Hide resolved
.github/workflows/verify-config.yaml Outdated Show resolved Hide resolved
@onidoru onidoru force-pushed the change_example_ldap_configs branch from 3f38664 to 3528253 Compare February 15, 2024 21:02

return config.LDAPCredentials{}, err
}

if len(metaData.Keys) == 0 {
log.Error().Err(zerr.ErrBadConfig).
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you cover this case? Should be easy enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Covered.

return config.LDAPCredentials{}, zerr.ErrBadConfig
}

if len(metaData.Unused) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you cover this with a test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Covered.

@onidoru onidoru force-pushed the change_example_ldap_configs branch from a7ce686 to 8a61bbc Compare February 16, 2024 20:22
content := []byte(`{
"bindDN":"cn=ldap-searcher,ou=Users,dc=example,dc=org",
"bindPassword":"ldap-searcher-password",
"extraKey": "extraValue"
Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason the test does not cover the lines we expected. Also the comment at line 1326 should probably be removed,

defer os.Remove(tmpCredsFile.Name())

// `bindDN` key is missing
content := []byte(``)
Copy link
Contributor

@andaaron andaaron Feb 16, 2024

Choose a reason for hiding this comment

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

I think this case covers the error on viperInstance.UnmarshalExact( which is good, but we still need a separate test case with a valid empty json content := []byte({}).

@rchincha
Copy link
Contributor

@onidoru fyi, #2322 adopts and supersedes. Thanks for this PR.

@rchincha
Copy link
Contributor

Superseded by #2322
Thanks @onidoru for the PR, closing.

@rchincha rchincha closed this Mar 22, 2024
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.

3 participants