-
Notifications
You must be signed in to change notification settings - Fork 164
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
[v2.8] [backport] AzureAD support #363
Conversation
bump rancher added dashboard implementation
updated login request removed unused import removed prompt flag
go mod fix
- added getClient func to create once the HTTP client with the same TLS configuration. - added tests for the getAuthProviders func
d95eb33
to
dbf5eed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good I think the error messages can be improved tho'
i++ | ||
data := gjson.GetBytes(response, "data").Array() | ||
|
||
supportedProviders := []TypedProvider{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the nil slice is the preferred style
https://go.dev/wiki/CodeReviewComments#declaring-empty-slices
I'll be honest, this surprises me, and I am guilty of not doing this :-)
|
||
err = json.Unmarshal([]byte(provider.Raw), typedProvider) | ||
if err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could maybe wrap this with something that says "attempting to decode the auth provider of type %s", otherwise these sorts of errors are quite generic (and thus opaque).
if err != nil { | ||
return nil, err | ||
if !gjson.ValidBytes(response) { | ||
return nil, errors.New("invalid JSON input") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "response" here rather than "input"? and could we include the authProviderURL
which might point to why?
func Test_getAuthProviders(t *testing.T) { | ||
|
||
setupServer := func(response string) *httptest.Server { | ||
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The servers created by this aren't .Closed()
?
Probably won't impact in the scope of tests.
Reading the code tho', it feels like you could create and either defer .Close()
or t.Cleanup()
and close?
Ref:
Backport of #346