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

uasc: return an error for invalid uri/mode combinations with None #664

Merged
merged 1 commit into from
Jun 15, 2023

Conversation

magiconair
Copy link
Member

The previous code forced security mode None if the URI was None changing
the incoming Config object. While it makes the code more robust it also
has a side effect and we were already checking for other invalid
combinations. This patch puts all checks in one place and returns an
error if the combination is invalid.

@magiconair magiconair requested a review from kung-foo June 14, 2023 06:51
@magiconair magiconair added this to the v0.4.1 milestone Jun 14, 2023
@magiconair
Copy link
Member Author

magiconair commented Jun 14, 2023

I've added https://github.com/stretchr/testify as a dependency for testing. I'm open for using something else like https://github.com/gotestyourself/gotest.tools if there are strong opinions. What do others think?

Update: just in the same file we already use the verify package and if err != nil { t.Fatal(err) } pattern. Adding require would add another pattern for testing the same things which probably adds more confusion than it is worth.

I've implemented the errorContains function which I've needed for the test and removed the stretchr dependency again.

The previous code forced security mode None if the URI was None changing
the incoming Config object. While it makes the code more robust it also
has a side effect and we were already checking for other invalid
combinations. This patch puts all checks in one place and returns an
error if the combination is invalid.
@magiconair magiconair force-pushed the secure-channel-do-not-change-config branch from 3219bac to d5aaaaf Compare June 14, 2023 07:00
@kung-foo
Copy link
Member

FWIW, I really like the testify (require) package and we use it in 100% of our internal go projects.

Copy link
Member

@kung-foo kung-foo left a comment

Choose a reason for hiding this comment

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

LGTM

@kung-foo kung-foo merged commit 807c2da into main Jun 15, 2023
@kung-foo kung-foo deleted the secure-channel-do-not-change-config branch June 15, 2023 09:12
@magiconair
Copy link
Member Author

We use testify as well. For this one I was more concerned with having three different testing strategies in the codebase. Didn't seem worth the effort.

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.

2 participants